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/xl: support empty disk paths

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl/xl: support empty disk paths
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Tue, 25 Jan 2011 13:52:10 +0000
Delivery-date: Tue, 25 Jan 2011 05:52:29 -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)
Support empty disk paths for compatibility with xend

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

diff -r b59f04eb8978 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/libxl.c       Tue Jan 25 13:50:29 2011 +0000
@@ -638,8 +638,8 @@ int libxl_event_get_disk_eject_info(libx
 
     disk->backend_domid = 0;
     disk->domid = domid;
-    disk->physpath = NULL;
-    disk->phystype = 0;
+    disk->physpath = strdup("");
+    disk->phystype = PHYSTYPE_EMPTY;
     /* this value is returned to the user: do not free right away */
     disk->virtpath = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, 
"%s/dev", backend));
     disk->unpluggable = 1;
@@ -863,6 +863,8 @@ int libxl_device_disk_add(libxl_ctx *ctx
             device.backend_kind = DEVICE_VBD;
             break;
         }
+        case PHYSTYPE_EMPTY:
+            break;
         case PHYSTYPE_FILE:
             /* let's pretend is tap:aio for the moment */
             disk->phystype = PHYSTYPE_AIO;
@@ -1587,7 +1589,7 @@ static unsigned int libxl_append_disk_li
             pdisk->backend_domid = 0;
             pdisk->domid = domid;
             physpath_tmp = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, 
"%s/%s/params", be_path, *dir), &len);
-            if (strchr(physpath_tmp, ':')) {
+            if (physpath_tmp && strchr(physpath_tmp, ':')) {
                 pdisk->physpath = strdup(strchr(physpath_tmp, ':') + 1);
                 free(physpath_tmp);
             } else {
@@ -1665,7 +1667,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u
 
     if (!disk->physpath) {
         disk->physpath = strdup("");
-        disk->phystype = PHYSTYPE_PHY;
+        disk->phystype = PHYSTYPE_EMPTY;
     }
     disks = libxl_device_disk_list(ctx, domid, &num);
     for (i = 0; i < num; i++) {
diff -r b59f04eb8978 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/libxl.h       Tue Jan 25 13:50:29 2011 +0000
@@ -178,6 +178,7 @@ typedef enum {
     PHYSTYPE_AIO,
     PHYSTYPE_FILE,
     PHYSTYPE_PHY,
+    PHYSTYPE_EMPTY,
 } libxl_disk_phystype;
 
 typedef enum {
diff -r b59f04eb8978 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/libxl_device.c        Tue Jan 25 13:50:29 2011 +0000
@@ -130,6 +130,7 @@ char *libxl__device_disk_string_of_physt
         case PHYSTYPE_AIO: return "aio";
         case PHYSTYPE_FILE: return "file";
         case PHYSTYPE_PHY: return "phy";
+        case PHYSTYPE_EMPTY: return "file";
         default: return NULL;
     }
 }
@@ -143,6 +144,7 @@ char *libxl__device_disk_backend_type_of
         case PHYSTYPE_AIO: return "tap";
         /* let's pretend file is tap:aio */
         case PHYSTYPE_FILE: return "tap";
+        case PHYSTYPE_EMPTY: return "tap";
         case PHYSTYPE_PHY: return "phy";
         default: return NULL;
     }
diff -r b59f04eb8978 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Tue Jan 25 13:50:29 2011 +0000
@@ -456,6 +456,11 @@ static int parse_disk_config(libxl_devic
                     fprintf(stderr, "Unknown disk type: %s\n", tok);
                     return 0;
                 }
+                tok = p + 1;
+            } else if (*p == ',') {
+                state = DSTATE_VIRTPATH;
+                disk->phystype = PHYSTYPE_EMPTY;
+                disk->physpath = strdup("");
                 tok = p + 1;
             }
             break;
@@ -1834,8 +1839,8 @@ static void cd_insert(const char *dom, c
             libxl_string_to_phystype(&ctx, phys, &disk.phystype);
         }
     } else {
-            disk.physpath = NULL;
-            disk.phystype = 0;
+            disk.physpath = strdup("");
+            disk.phystype = PHYSTYPE_EMPTY;
     }
     disk.virtpath = (char*)virtdev;
     disk.unpluggable = 1;

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

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