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] libxl: fix cd insert/eject

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl: fix cd insert/eject
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 17 Feb 2011 15:38:29 +0000
Delivery-date: Thu, 17 Feb 2011 07:39:16 -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)
libxl: fix cd insert/eject

When multiple disks are passed to libxl_wait_for_disk_ejects, watch the
correct disk paths.

Parse the backend type and backend domid from xenstore in
libxl_event_get_disk_eject_info.

libxl_event_get_disk_eject_info must return a valid string in
disk->vdev, while at the moment is free'ed before returning.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

diff -r 20b0f74bc31c tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Feb 17 12:25:09 2011 +0000
+++ b/tools/libxl/libxl.c       Thu Feb 17 15:31:43 2011 +0000
@@ -592,7 +592,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx
             goto out;
         if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0)
             goto out;
-        xs_watch(ctx->xsh, waiter->path, waiter->token);
+        xs_watch(ctx->xsh, waiter[i].path, waiter[i].token);
     }
     rc = 0;
 out:
@@ -654,6 +654,7 @@ int libxl_event_get_disk_eject_info(libx
     char *path;
     char *backend;
     char *value;
+    char backend_type[5];
 
     value = libxl__xs_read(&gc, XBT_NULL, event->path);
 
@@ -666,12 +667,20 @@ int libxl_event_get_disk_eject_info(libx
     path[strlen(path) - 6] = '\0';
     backend = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend", 
path));
 
-    disk->backend_domid = 0;
+    sscanf(backend, "/local/domain/%d/backend/%5[a-z]/%*d/%*d", 
&disk->backend_domid, backend_type);
+       if (!strcmp(backend_type, "tap") || !strcmp(backend_type, "vbd")) {
+               disk->backend = DISK_BACKEND_TAP;
+       } else if (!strcmp(backend_type, "qdisk")) {
+               disk->backend = DISK_BACKEND_QDISK;
+       } else {
+               disk->backend = DISK_BACKEND_UNKNOWN;
+       } 
+
     disk->domid = domid;
     disk->pdev_path = strdup("");
     disk->format = DISK_FORMAT_EMPTY;
     /* this value is returned to the user: do not free right away */
-    disk->vdev = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", 
backend));
+    disk->vdev = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/dev", 
backend), NULL);
     disk->unpluggable = 1;
     disk->readwrite = 0;
     disk->is_cdrom = 1;

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

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