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

[Xen-devel] [PATCH 2 of 5] libxl: return raw disk and partition number from libxl__device_disk_dev_number



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1301923169 -3600
# Node ID 8f5c77edff0b52d90cdf081891b37323df6beef3
# Parent  0191af544eee4c50fce1843099d7cd1ea98a2afd
libxl: return raw disk and partition number from libxl__device_disk_dev_number

Optional parameters, caller to follow.

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

diff -r 0191af544eee -r 8f5c77edff0b tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Apr 04 14:19:29 2011 +0100
+++ b/tools/libxl/libxl.c       Mon Apr 04 14:19:29 2011 +0100
@@ -611,7 +611,7 @@ int libxl_wait_for_disk_ejects(libxl_ctx
     for (i = 0; i < num_disks; i++) {
         if (asprintf(&(waiter[i].path), "%s/device/vbd/%d/eject",
                      libxl__xs_get_dompath(&gc, domid),
-                     libxl__device_disk_dev_number(disks[i].vdev)) < 0)
+                     libxl__device_disk_dev_number(disks[i].vdev, NULL, NULL)) 
< 0)
             goto out;
         if (asprintf(&(waiter[i].token), "%d", LIBXL_EVENT_DISK_EJECT) < 0)
             goto out;
@@ -965,7 +965,7 @@ int libxl_device_disk_add(libxl_ctx *ctx
     }
 
     backend_type = libxl__device_disk_string_of_backend(disk->backend);
-    devid = libxl__device_disk_dev_number(disk->vdev);
+    devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     if (devid==-1) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
                " virtual disk identifier %s", disk->vdev);
@@ -1081,7 +1081,7 @@ int libxl_device_disk_del(libxl_ctx *ctx
     libxl__device device;
     int devid, rc;
 
-    devid = libxl__device_disk_dev_number(disk->vdev);
+    devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     device.backend_domid    = disk->backend_domid;
     device.backend_devid    = devid;
     device.backend_kind     =
@@ -1816,7 +1816,7 @@ int libxl_device_disk_getinfo(libxl_ctx 
     char *val;
 
     dompath = libxl__xs_get_dompath(&gc, domid);
-    diskinfo->devid = libxl__device_disk_dev_number(disk->vdev);
+    diskinfo->devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
 
     /* tap devices entries in xenstore are written as vbd devices. */
     diskpath = libxl__sprintf(&gc, "%s/device/vbd/%d", dompath, 
diskinfo->devid);
diff -r 0191af544eee -r 8f5c77edff0b tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Mon Apr 04 14:19:29 2011 +0100
+++ b/tools/libxl/libxl_device.c        Mon Apr 04 14:19:29 2011 +0100
@@ -200,7 +200,7 @@ static int device_virtdisk_matches(const
     return 1;
 }
 
-int libxl__device_disk_dev_number(char *virtpath)
+int libxl__device_disk_dev_number(char *virtpath, int *pdisk, int *ppartition)
 {
     int disk, partition;
     char *ep;
@@ -214,6 +214,8 @@ int libxl__device_disk_dev_number(char *
         device_virtdisk_matches(virtpath, "xvd",
                                 &disk, (1<<20)-1,
                                 &partition, 255)) {
+        if (pdisk) *pdisk = disk;
+        if (ppartition) *ppartition = partition;
         if (disk <= 15 && partition <= 15)
             return (202 << 8) | (disk << 4) | partition;
         else
@@ -228,11 +230,15 @@ int libxl__device_disk_dev_number(char *
     if (device_virtdisk_matches(virtpath, "hd",
                                 &disk, 3,
                                 &partition, 63)) {
+        if (pdisk) *pdisk = disk;
+        if (ppartition) *ppartition = partition;
         return ((disk<2 ? 3 : 22) << 8) | ((disk & 1) << 6) | partition;
     }
     if (device_virtdisk_matches(virtpath, "sd",
                                 &disk, 15,
                                 &partition, 15)) {
+        if (pdisk) *pdisk = disk;
+        if (ppartition) *ppartition = partition;
         return (8 << 8) | (disk << 4) | partition;
     }
     return -1;
diff -r 0191af544eee -r 8f5c77edff0b tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Apr 04 14:19:29 2011 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Apr 04 14:19:29 2011 +0100
@@ -197,7 +197,7 @@ _hidden char *libxl__device_disk_string_
 _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);
 
 _hidden int libxl__device_physdisk_major_minor(const char *physpath, int 
*major, int *minor);
-_hidden int libxl__device_disk_dev_number(char *virtpath);
+_hidden int libxl__device_disk_dev_number(char *virtpath, int *disk, int 
*partition);
 
 _hidden int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
                              char **bents, char **fents);

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


 


Rackspace

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