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

[Xen-devel] [PATCH] xl: fix cdrom_insert parsing

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: fix cdrom_insert parsing
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 17 Feb 2011 12:22:31 +0000
Delivery-date: Thu, 17 Feb 2011 04:25:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
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>

diff -r d90cbea3df03 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Feb 16 19:49:14 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Wed Feb 16 20:51:07 2011 +0000
@@ -1847,40 +1847,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;
-
-    find_domain(dom);
-
+    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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>