[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH, v2] libxl: sane disk backend selection and validation



Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v2] libxl: sane disk 
backend selection and validation"):
> TAP should only be used for raw or vhd formats, not for qcow or qcow2.

Fixed in this changeset, I think.

Ian.

# HG changeset patch
# User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
# Date 1310146524 -3600
# Node ID 00d2c5ca26fd40f55f4255ac883ad882a5207cc8
# Parent  443c6a7b6079f490d9adbb46352c20c2628fb144
libxl: do not use tap disk backend other than for raw and vhd

tap does not support qcow/qcow2; update disk_try_backend accordingly.

Break out the "backend not suitable for this format" message so it can
be reused.  Remove now-redundant reporting from
libxl_device_disk_local_attach and replace with abort().

Reported-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

diff -r 443c6a7b6079 -r 00d2c5ca26fd tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jul 08 18:12:26 2011 +0100
+++ b/tools/libxl/libxl.c       Fri Jul 08 18:35:24 2011 +0100
@@ -1089,9 +1089,7 @@ char * libxl_device_disk_local_attach(li
                 break;
             case LIBXL_DISK_FORMAT_QCOW:
             case LIBXL_DISK_FORMAT_QCOW2:
-                LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach"
-                           " a qcow or qcow2 disk image");
-                break;
+                abort(); /* prevented by libxl__device_disk_set_backend */
             default:
                 LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                            "unrecognized disk format: %d", disk->format);
diff -r 443c6a7b6079 -r 00d2c5ca26fd tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Fri Jul 08 18:12:26 2011 +0100
+++ b/tools/libxl/libxl_device.c        Fri Jul 08 18:35:24 2011 +0100
@@ -134,11 +134,7 @@ static int disk_try_backend(disk_try_bac
     case LIBXL_DISK_BACKEND_PHY:
         if (!(a->disk->format == LIBXL_DISK_FORMAT_RAW ||
               a->disk->format == LIBXL_DISK_FORMAT_EMPTY)) {
-            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend phy"
-                       " unsuitable due to format %s",
-                       a->disk->vdev,
-                       libxl_disk_format_to_string(a->disk->format));
-            return 0;
+            goto bad_format;
         }
         if (a->disk->format != LIBXL_DISK_FORMAT_EMPTY &&
             !S_ISBLK(a->stab.st_mode)) {
@@ -157,12 +153,9 @@ static int disk_try_backend(disk_try_bac
                        a->disk->vdev);
             return 0;
         }
-        if (a->disk->format == LIBXL_DISK_FORMAT_EMPTY ||
-            (S_ISREG(a->stab.st_mode) && !a->stab.st_size)) {
-            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend tap"
-                       " unsuitable because empty devices not supported",
-                       a->disk->vdev);
-            return 0;
+        if (!(a->disk->format == LIBXL_DISK_FORMAT_RAW ||
+              a->disk->format == LIBXL_DISK_FORMAT_VHD)) {
+            goto bad_format;
         }
         return backend;
 
@@ -175,6 +168,15 @@ static int disk_try_backend(disk_try_bac
         return 0;
         
     }
+    abort(); /* notreached */
+
+ bad_format:
+    LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Disk vdev=%s, backend %s"
+               " unsuitable due to format %s",
+               a->disk->vdev,
+               libxl_disk_backend_to_string(backend),
+               libxl_disk_format_to_string(a->disk->format));
+    return 0;
 }            
 
 int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.