# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1301923169 -3600
# Node ID 4243987a85117cb2fe417e5290a0e894f035f85d
# Parent 8abca96d78c1368cee94c3ac5984a92aebbb2711
libxl: specify disks using supported command line syntax for new qemu
The -hdX syntax is only retained for compatibility reasons and the
-sdX syntax doesn't even exist.
Additionally convert the first four non-SCSI disks to hd[a-d] and
ignore any further non-SCSI disks (since qemu only supports 4 IDE
devices).
SCSI disks are passed through as is. qemu-xen was limited to 7 SCSI
devices but upstream qemu supports 256, therefore do not limit the
number of disks on the libxl side.
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 8abca96d78c1 -r 4243987a8511 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Mon Apr 04 14:19:29 2011 +0100
+++ b/tools/libxl/libxl_dm.c Mon Apr 04 14:19:29 2011 +0100
@@ -175,6 +175,7 @@ static char ** libxl__build_device_model
libxl_device_disk *disks,
int num_disks,
libxl_device_nic *vifs, int
num_vifs)
{
+ libxl_ctx *ctx = libxl__gc_owner(gc);
flexarray_t *dm_args;
int i;
@@ -312,13 +313,43 @@ static char ** libxl__build_device_model
if (info->type == XENFV) {
for (i; i < num_disks; i++) {
+ int disk, part;
+ int dev_number = libxl__device_disk_dev_number(disks[i].vdev,
&disk, &part);
+ char *drive;
+
+ if (dev_number == -1) {
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine disk
number for %s", disks[i].vdev);
+ continue;
+ }
+
if (disks[i].is_cdrom) {
- flexarray_append(dm_args, "-cdrom");
- flexarray_append(dm_args, libxl__strdup(gc,
disks[i].pdev_path));
+ if (disks[i].format == DISK_FORMAT_EMPTY)
+ drive = libxl__sprintf(gc, "if=ide,index=%d,media=cdrom",
disk);
+ else
+ drive = libxl__sprintf(gc,
"file=%s,if=ide,index=%d,media=cdrom",
+ disks[i].pdev_path, disk);
} else {
- flexarray_append(dm_args, libxl__sprintf(gc, "-%s",
disks[i].vdev));
- flexarray_append(dm_args, libxl__strdup(gc,
disks[i].pdev_path));
+ if (disks[i].format == DISK_FORMAT_EMPTY)
+ continue;
+
+ /*
+ * 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 (strncmp(disks[i].vdev, "sd", 2) == 0)
+ drive = libxl__sprintf(gc, "file=%s,if=scsi,bus=0,unit=%d",
+ disks[i].pdev_path, disk);
+ else if (disk < 4)
+ drive = libxl__sprintf(gc,
"file=%s,if=ide,index=%d,media=disk",
+ disks[i].pdev_path, disk);
+ else
+ continue; /* Do not emulate this disk */
}
+
+ flexarray_append(dm_args, "-drive");
+ flexarray_append(dm_args, drive);
}
}
flexarray_append(dm_args, NULL);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|