[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 16:22 +0100, Stefano Stabellini wrote:
> On Fri, 1 Apr 2011, Ian Campbell wrote:
> > # 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]);
> >          }
> 
> I don't think qemu uses -sd as the cli option to specify scsi drive and
> -hd[a-d] is only there for backward compatibility.

OK, that was a bug before this change too...

> The new cli option to specify drives is -drive:
> 
> -drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]
> [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]
> [,cache=writethrough|writeback|none|unsafe][,format=f]
> [,serial=s][,addr=A][,id=name][,aio=threads|native]
> [,readonly=on|off]

According to qemu(1) "-hd[a-d] file" maps to:
        qemu -drive file=file,index=0,media=disk
        qemu -drive file=file,index=1,media=disk
        qemu -drive file=file,index=2,media=disk
        qemu -drive file=file,index=3,media=disk

And apparently SCSI is:

        qemu -drive file=file,if=scsi,bus=0,unit=6

While I'm at it I suppose -cdrom ought to become:

        qemu -drive file=file,index=2,media=cdrom

I'll fix this in a separate patch though.

Ian.


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