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 3 of 7] libxl: convert an empty tap disk into a qdisk

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 3 of 7] libxl: convert an empty tap disk into a qdisk
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 07 Apr 2011 10:52:29 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 07 Apr 2011 02:56:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1302169946@xxxxxxxxxxxxxxxxxxxxx>
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: <patchbomb.1302169946@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302167196 -3600
# Node ID f5418873be3d097cbb374009898ce9c74255e047
# Parent  76d363a113e5ee6111bc9e0eca5a314644ce6295
libxl: convert an empty tap disk into a qdisk

I'm not sure that empty disks which are is_cdrom are especially valid,
or that a cdrom can ever be handled by tapdisk anyway but try to do
something sane since it seems that xl's parse_disk_config() routine
could potentially generate such a configuration (although whether from
a valid input string or not I'm not sure).

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 76d363a113e5 -r f5418873be3d tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Apr 07 10:06:35 2011 +0100
+++ b/tools/libxl/libxl.c       Thu Apr 07 10:06:36 2011 +0100
@@ -983,6 +983,14 @@ int libxl_device_disk_add(libxl_ctx *ctx
     if (disk->backend == DISK_BACKEND_TAP && !libxl__blktap_enabled(&gc))
         disk->backend = DISK_BACKEND_QDISK;
 
+    /*
+     * blktap cannot handle empty disks (aka cdroms). Fall back to
+     * qdisk because qemu-xen creates the disk based on the xenstore
+     * entries.
+     */
+    if (disk->backend == DISK_BACKEND_TAP && disk->format == DISK_FORMAT_EMPTY)
+        disk->backend == DISK_BACKEND_QDISK;
+
     switch (disk->backend) {
         case DISK_BACKEND_PHY: 
             libxl__device_physdisk_major_minor(disk->pdev_path, &major, 
&minor);
@@ -995,7 +1003,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
             device.backend_kind = DEVICE_VBD;
             break;
         case DISK_BACKEND_TAP:
-            if (disk->format != DISK_FORMAT_EMPTY) {
+            {
                 const char *dev = libxl__blktap_devpath(&gc,
                                                disk->pdev_path, disk->format);
                 if (!dev) {
@@ -1003,8 +1011,8 @@ int libxl_device_disk_add(libxl_ctx *ctx
                     goto out_free;
                 }
                 flexarray_append(back, "tapdisk-params");
-                flexarray_append(back, libxl__sprintf(&gc, "%s:%s", 
-                    libxl__device_disk_string_of_format(disk->format), 
+                flexarray_append(back, libxl__sprintf(&gc, "%s:%s",
+                    libxl__device_disk_string_of_format(disk->format),
                     disk->pdev_path));
                 flexarray_append(back, "params");
                 flexarray_append(back, libxl__strdup(&gc, dev));
@@ -1013,8 +1021,6 @@ int libxl_device_disk_add(libxl_ctx *ctx
                 flexarray_append(back, "physical-device");
                 flexarray_append(back, libxl__sprintf(&gc, "%x:%x", major, 
minor));
                 device.backend_kind = DEVICE_VBD;
-
-                break;
             }
             break;
         case DISK_BACKEND_QDISK:

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