xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: libxl: translate xvd[a-d] to hd[a-d] for new qemu
@ 2011-03-31 11:31 Ian Campbell
  2011-03-31 18:38 ` Ian Jackson
  0 siblings, 1 reply; 13+ messages in thread
From: Ian Campbell @ 2011-03-31 11:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell

# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1301571089 -3600
# Node ID d0dd569bfcb0f5f8e2d903c8b6f9999ff1290e96
# Parent  7b5c5a365f2a0a57e83479f69e5b56beb07752c1
tools: libxl: translate xvd[a-d] to hd[a-d] for new qemu

xvde+ are ignored.

Old qemu did this itself internally. Fixes "qemu: -xvda: invalid
option" and allows PVHVM to work with new qemu.

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

diff -r 7b5c5a365f2a -r d0dd569bfcb0 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c	Thu Mar 31 11:57:29 2011 +0100
+++ b/tools/libxl/libxl_dm.c	Thu Mar 31 12:31:29 2011 +0100
@@ -175,6 +175,7 @@ static char ** libxl__build_device_model
                                                   libxl_device_nic *vifs,
                                                   int num_vifs)
 {
+    libxl_ctx *ctx = libxl__gc_owner(gc);
     flexarray_t *dm_args;
     libxl_device_disk *disks;
     int nb, i;
@@ -318,8 +319,25 @@ 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));
+                char hd_dev[] = "hdX";
+                const char *vdev = NULL;
+
+                if (strncmp(disks[i].vdev, "xvd", 3) == 0) {
+                    if (disks[i].vdev[3] >= 'a' && disks[i].vdev[3] <= 'd') {
+                        hd_dev[2] = disks[i].vdev[3];
+                        vdev = &hd_dev[0];
+                        LIBXL__LOG(ctx, LIBXL__LOG_INFO, "translated disk device %s to %s", disks[i].vdev, vdev);
+                    } else {
+                        LIBXL__LOG(ctx, LIBXL__LOG_INFO, "ignored disk device %s", disks[i].vdev);
+                    }
+                } else {
+                    vdev = disks[i].vdev;
+                }
+
+                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]);
         }

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-04-05 17:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-31 11:31 [PATCH] tools: libxl: translate xvd[a-d] to hd[a-d] for new qemu Ian Campbell
2011-03-31 18:38 ` Ian Jackson
2011-04-01 12:01   ` Ian Campbell
2011-04-01 13:09     ` Ian Campbell
2011-04-01 15:22       ` Stefano Stabellini
2011-04-01 15:28         ` Ian Campbell
2011-04-04 13:21           ` [PATCH 0 of 5] libxl: fixes to upstream qemu disk configuration Ian Campbell
2011-04-04 13:21             ` [PATCH 1 of 5] libxl: explicitly set disk format in libxl__append_disk_list_of_type Ian Campbell
2011-04-04 13:21             ` [PATCH 2 of 5] libxl: return raw disk and partition number from libxl__device_disk_dev_number Ian Campbell
2011-04-04 13:21             ` [PATCH 3 of 5] libxl: pass list of disks to libxl__build_device_model_args Ian Campbell
2011-04-04 13:21             ` [PATCH 4 of 5] libxl: specify disks using supported command line syntax for new qemu Ian Campbell
2011-04-04 13:21             ` [PATCH 5 of 5] libxl: specific explicit disk image format to " Ian Campbell
2011-04-05 17:18               ` Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).