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: Perform minimal validation of virtual disk f

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file
From: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
Date: Wed, 26 Jan 2011 13:02:05 -0500
Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Wed, 26 Jan 2011 10:05:23 -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 :content-transfer-encoding; bh=iTlaLQdYMcjLct2D7fFCuEBUtHIWWLLmGuQqKwVgLEc=; b=cGo6l+paOZuQmEkrBuCV4xiu4YUITox8FaXrQ6nVxja8AqcC43IBHtDfqoUWzMGgUT l9V/wG1IN3sEiTYXaWU6VrlPatxvDTacWqtKLszJi6f7gAVwwkRUulE+iU9g5qdeBCJ8 t1/fHQB8j/B9KwinxldmD2ektCKlVvBZuCR84=
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:content-transfer-encoding; b=GJAmIDw2ScIvponWJ94CLNZh/39x0MNUP6BaVloJJX315ijIznJY1GQg1f8ngqLj/8 5HjgWnwXcb/Bs10fwdkWJP6VYdkt16dqdq3e8GZOzVP2wQDN+Ufp5pl9OJxgRzY0GYhM jfY7OC+0L9Ra01nq/2hpu4T9WH25JdFPqG/D4=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <19776.2283.897281.370509@xxxxxxxxxxxxxxxxxxxxxxxx>
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: <AANLkTimSUym0u+SNm0AvNp3AZQQFspetAaXmNShkPJd4@xxxxxxxxxxxxxx> <1294995912.8240.86.camel@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTikfUHHc+-gVkgnRJc722wObLF3TumpK5WSfJVAE@xxxxxxxxxxxxxx> <1295024348.12018.222.camel@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTikf3TVJwE_N-OyuS-UhyA8+cgzAG__9hz3AETeM@xxxxxxxxxxxxxx> <AANLkTinJ=PYsC6vbPvU8g2T8NmyohLa=4rd9zfhTMCCO@xxxxxxxxxxxxxx> <AANLkTin1AGxH26158mn37_Oar1PgSSJoJOnGHs+XnxsV@xxxxxxxxxxxxxx> <19768.22912.878633.622270@xxxxxxxxxxxxxxxxxxxxxxxx> <AANLkTinnrmAxaOVu1fN2qt4N2t-EzpF31sKE-Jpn-y2f@xxxxxxxxxxxxxx> <AANLkTi=1b+amdCA4A3AKxAnR6C65xv2+O3BNbGsp-T7i@xxxxxxxxxxxxxx> <19769.31094.274199.464586@xxxxxxxxxxxxxxxxxxxxxxxx> <1295616468.12018.352.camel@xxxxxxxxxxxxxxxxxxxxxx> <4D3A4203.2050706@xxxxxxxxx> <19775.4623.927492.247420@xxxxxxxxxxxxxxxxxxxxxxxx> <AANLkTike5rxaw4QpOVzh0p9_qX6fGebUri_WNROQEsNf@xxxxxxxxxxxxxx> <19776.2283.897281.370509@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.24 (X11/20101027)
Here is a patch that special cases tap/aio during validation.

I am not taking into account qcow and qcow2 as I hear they are broken with tap 
and shouldn't be used for that reason.

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 12:07:54 2011 -0500
@@ -836,22 +836,26 @@ 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;
+    int count = 0;

     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 )
+        count = strlen("vhd:");
+
+    if ( stat(&file_name[count], &stat_buf) != 0 ) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", 
&file_name[count]);
         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);
+                &file_name[count]);
             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", 
&file_name[count]);
         return ERROR_INVAL;
     }



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

<Prev in Thread] Current Thread [Next in Thread>