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] tools: libxl: translate xvd[a-d] to hd[a-d] for

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.
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]

see qemu-config.c:qemu_drive_opts

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