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

[Xen-changelog] [xen-unstable] xl: fix cdrom_insert parsing



# HG changeset patch
# User Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
# Date 1297972140 0
# Node ID 0e52f58dead5f54d62e124ad1c2e84ca567af663
# Parent  acec8a17879633d26e83b869f9db036a16ff74f2
xl: fix cdrom_insert parsing

Reuse the same code used to parse the disk line from the VM config file
in cd_insert.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   37 ++++++++++---------------------------
 1 files changed, 10 insertions(+), 27 deletions(-)

diff -r acec8a178796 -r 0e52f58dead5 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Feb 17 19:48:05 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Thu Feb 17 19:49:00 2011 +0000
@@ -1849,40 +1849,23 @@ static void cd_insert(const char *dom, c
 static void cd_insert(const char *dom, const char *virtdev, char *phys)
 {
     libxl_device_disk disk; /* we don't free disk's contents */
-    char *p;
+    char *buf = NULL;
 
     find_domain(dom);
 
+    if (asprintf(&buf, "%s,%s:cdrom,r", phys ? phys : "", virtdev) < 0) {
+        fprintf(stderr, "out of memory\n");
+        return;
+    }
+    if (!parse_disk_config(&disk, buf)) {
+        fprintf(stderr, "format error\n");
+        return;
+    }
     disk.backend_domid = 0;
     disk.domid = domid;
-    if (phys) {
-        p = strchr(phys, ':');
-        if (!p) {
-            fprintf(stderr, "No type specified, ");
-            disk.pdev_path = phys;
-            if (!strncmp(phys, "/dev", 4)) {
-                fprintf(stderr, "assuming phy:\n");
-                disk.backend = DISK_BACKEND_PHY;
-            } else {
-                fprintf(stderr, "assuming file:\n");
-                disk.backend = DISK_BACKEND_TAP; 
-            }
-        } else {
-            *p = '\0';
-            p++;
-            disk.pdev_path = p;
-            libxl_string_to_backend(&ctx, phys, &disk.backend);
-        }
-    } else {
-            disk.pdev_path = strdup("");
-            disk.format = DISK_FORMAT_EMPTY;
-    }
-    disk.vdev = (char*)virtdev;
-    disk.unpluggable = 1;
-    disk.readwrite = 0;
-    disk.is_cdrom = 1;
 
     libxl_cdrom_insert(&ctx, domid, &disk);
+    free(buf);
 }
 
 int main_cd_eject(int argc, char **argv)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.