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

Re: [xen-devel][PATCH] xl - Special case vhd images validation

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: Re: [xen-devel][PATCH] xl - Special case vhd images validation
From: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
Date: Mon, 14 Feb 2011 15:34:31 -0500
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 14 Feb 2011 12:36:33 -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:references:in-reply-to:content-type; bh=SGfx1a/w7Oxtv8JQaGviiCyCikq267uzeq+UH+KUUB8=; b=qTPZQlrb2ZhgmnrTsQ5FWh6/LLfjvKpyK7UiFNBJE77XGk1vtgYm+8SSb+ilaT+iO0 lq7E/8wBApiydNKbcIOBgi8Sq3cnSSqZ/8qpEhIQAmSnr5cwbvQLmECQy9Klx+XxxpNL sAAuOk7JI3XBGOC03C5Ev0kxez9jHRpZmGtfk=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=mZwDnqkzG483XT7D2MJtvMF4xx81nFVDysHx+mf9KPXBTs2w/pnizoRydYHMHH4Hxz OWGBmgj20+ycliYM4V0U0OgeJCyAlp9oqnJmcoW3M+KjCddlkk4JewHW/ECnDrMVgcyx ZRCp9+2sYZUiCGVqLjppgDUdNYDxxj108ERrc=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4D5442B6.2070900@xxxxxxxxx>
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>
References: <4D541D56.4090109@xxxxxxxxx> <19796.15622.618084.147420@xxxxxxxxxxxxxxxxxxxxxxxx> <4D5442B6.2070900@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.24 (X11/20101027)
Resending this patch as the one I sent earlier won't apply given the changes we 
just made to "[PATCH 2/5] Xl interface change plus changes to code it impacts".

Description - Special case how we validate vhd image files.  Without this patch 
when tap:aio:vhd prefixed image files are specified in the config file, disk 
validation and thus vm creation will fail.

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

Kamala
diff -r a60ad215181c tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Feb 14 15:15:19 2011 -0500
+++ b/tools/libxl/libxl.c       Mon Feb 14 15:18:33 2011 -0500
@@ -863,19 +863,30 @@ int libxl_vncviewer_exec(libxl_ctx *ctx,
 
 
/******************************************************************************/
 
-static int validate_virtual_disk(libxl_ctx *ctx, char *file_name, 
-    libxl_disk_backend backend_type, libxl_disk_format format)
+static int validate_virtual_disk(libxl_ctx *ctx, char *file_name,
+    libxl_device_disk *disk) 
 {
     struct stat stat_buf;
+    char *delimiter;
 
-    if ((file_name[0] == '\0') && (format == DISK_FORMAT_EMPTY))
+    if (disk->format == DISK_FORMAT_EMPTY)
         return 0;
+
+    if (disk->format == DISK_FORMAT_RAW) {
+        delimiter = strchr(file_name, ':');
+        if (delimiter) {
+            if (!strncmp(file_name, "vhd:", sizeof("vhd:")-1)) {
+                disk->format = DISK_FORMAT_VHD;
+                file_name = ++delimiter;
+            }
+        }
+    }
 
     if ( stat(file_name, &stat_buf) != 0 ) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", 
file_name);
         return ERROR_INVAL;
     }
-    if (backend_type == DISK_BACKEND_PHY) {
+    if (disk->backend == DISK_BACKEND_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);
@@ -899,8 +910,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
     libxl__device device;
     int major, minor, rc;
 
-    rc = validate_virtual_disk(ctx, disk->pdev_path, disk->backend, 
-             disk->format);
+    rc = validate_virtual_disk(ctx, disk->pdev_path, disk); 
     if (rc)
         return rc;
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel