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

Re: [Xen-devel] [PATCH] tools: libxl: translate xvd[a-d] to hd[a-d] for new qemu



On Fri, 2011-04-01 at 13:01 +0100, Ian Campbell wrote:
> On Thu, 2011-03-31 at 19:38 +0100, Ian Jackson wrote:
> > Ian Campbell writes ("[Xen-devel] [PATCH] tools: libxl: translate xvd[a-d] 
> > to hd[a-d] for new qemu"):
> > > tools: libxl: translate xvd[a-d] to hd[a-d] for new qemu
> > > 
> > > xvde+ are ignored.
> > 
> > I don't think this is strictly speaking correct.  According to the
> > spec doc/misc/vbd-interface.txt, we are supposed to support vdevs in a
> > variety of formats.
> > 
> > What this code ought to be doing is using the parsing function and
> > then reconstituting the vdev name for qemu's benefit.
> 
> makes sense, I'd forgotten about the parsing function.
> 
> I guess for everything other than the sdX syntax I should translate the
> result of libxl__device_disk_dev_number into an -hd[a-d] for values < 4
> and ignore anything greater, but for sdX syntax I want to pass it
> through as is? And is the limit 4 or 16 in that case? (I'm not 100% sure
> of the old qemu's behaviour...)

qemu-xen translates up to MAX_SCSI_DEVS into sdX devices, MAX_SCSI_DEVS
is 7 in qemu-xen and 256 in upstream qemu, so I think for xl I'll just
translate sd devices with no limits -- adding more sd devices than the
particular qemu can cope with seems like user error to me.

8<------------------------------------------

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1301663315 -3600
# Node ID cd7f020e44b051542b82d54b8a4ef526cf403608
# Parent  356becdb49de5ac69f174ec8d0804882fef1ef3c
tools: libxl: translate disk device names to hd[a-d] for new qemu

We convert the first four non-SCSI disks to hd[a-d] and ignore any
additional non-SCSI disks.

SCSI disks are passed through as is. qemu-xen was limited to 7 SCSI
devices but upstream supports 256.

qemu-xen did all this itself internally.

Fixes "qemu: -xvda: invalid option" and allows PVHVM to work with
upstream qemu.

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

diff -r 356becdb49de -r cd7f020e44b0 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Fri Apr 01 14:05:22 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Fri Apr 01 14:08:35 2011 +0100
@@ -318,8 +318,27 @@ static char ** libxl__build_device_model
                 flexarray_append(dm_args, "-cdrom");
                 flexarray_append(dm_args, libxl__strdup(gc, 
disks[i].pdev_path));
             } else {
-                flexarray_append(dm_args, libxl__sprintf(gc, "-%s", 
disks[i].vdev));
-                flexarray_append(dm_args, libxl__strdup(gc, 
disks[i].pdev_path));
+                int dev_number = libxl__device_disk_dev_number(disks[i].vdev);
+                char *vdev;
+
+                /* Explicit sd disks are passed through as is.
+                 *
+                 * For other disks we translate devices 0..3 into
+                 * hd[a-d] and ignore the rest.
+                 */
+                if (dev_number == -1)
+                    vdev = NULL;
+                else if (strncmp(disks[i].vdev, "sd", 2) == 0)
+                    vdev = libxl__sprintf(gc, "-%s", vdev);
+                else if (dev_number < 4)
+                    vdev = libxl__sprintf(gc, "-hd%c", 'a' + dev_number);
+                else
+                    vdev = NULL;
+
+                if (vdev) {
+                    flexarray_append(dm_args, libxl__sprintf(gc, "-%s", vdev));
+                    flexarray_append(dm_args, libxl__strdup(gc, 
disks[i].pdev_path));
+                }
             }
             libxl_device_disk_destroy(&disks[i]);
         }



_______________________________________________
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®.