WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: Special case tap/aio for disk validation

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] xl: Special case tap/aio for disk validation
From: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
Date: Wed, 26 Jan 2011 14:46:14 -0500
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Wed, 26 Jan 2011 11:47:20 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=5nOUymZGUDBirtw8rTuGSxj7ZyHkp5lgtuxb/jw5wy0=; b=jIhkm4SxPQNiTdLSLkYnqwSkejGskEM1jyOl+rQ4pKyigZlu3+9vmt8PIqg5PClUgS Gujy2pQKp3WVTTBAz8F5MBAy42zmCtM0gn1iGigjat16qkxZUJzOBSg55IJXEtsPfNab x+YBuaqhMh72f0CK9IdoobyAIy0WUEikkw/yA=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=IcZ/Js+sIFX4t8opuiK3cNZ/YtTe/USms1BfjZwK1/rmvvn7EQP0E/MOhuU90K+j3Q gMiYXQ8eTLEmqEVYN7hPSd5WS7IZnnnh/oXHyqP6nIuzVvxericRgXgOUP+giZNL/NQ9 c5N3RuLQOJRs8iCnjKCjcg7+tJeTM5yk8Ny9Y=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.24 (X11/20101027)
Current disk validation code will fail when the disk file path is prefixed with 
tap:aio:vhd in the disk configuration file option.  This patch special cases 
tap:aio validation.

Note:  It appears qcow/qcow2 file format does not work with the current 
tapdisk.  So, I am checking only for vhd file format.  If there are other 
formats to check also, let me know.

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxxx>

Kamala

diff -r 67d5b8004947 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Jan 26 11:58:45 2011 +0000
+++ b/tools/libxl/libxl.c       Wed Jan 26 14:26:57 2011 -0500
@@ -836,22 +836,40 @@ static int validate_virtual_disk(libxl_c
 static int validate_virtual_disk(libxl_ctx *ctx, char *file_name, 
libxl_disk_phystype disk_type)
 {
     struct stat stat_buf;
+    const char *fname;

     if ( (file_name[0] == '\0') && (disk_type == PHYSTYPE_EMPTY) )
         return 0;

-    if ( stat(file_name, &stat_buf) != 0 ) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", 
file_name);
+    if ( disk_type == PHYSTYPE_AIO ) {
+        fname = strchr(file_name, ':');
+        if ( fname == NULL ) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "missing file format prefix!"
+                   " tap:aio disk option must be followed by file format 
type");
+            return ERROR_INVAL;
+        }
+        fname++;
+        if ( strncmp(file_name, "vhd:", sizeof("vhd:")-1) != 0 ) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Only vhd file format supported"
+                   " with tapdisk");
+            return ERROR_INVAL;
+        }
+    }
+    else
+        fname = file_name;
+
+    if ( stat(fname, &stat_buf) != 0 ) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", fname);
         return ERROR_INVAL;
     }
     if ( disk_type == PHYSTYPE_PHY ) {
         if ( !(S_ISBLK(stat_buf.st_mode)) ) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a block 
device!\n",
-                file_name);
+                fname);
             return ERROR_INVAL;
         }
     } else if ( S_ISREG(stat_buf.st_mode) && stat_buf.st_size == 0 ) {
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", 
file_name);
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", 
fname);
         return ERROR_INVAL;
     }



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel