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 11 of 27 v2] libxl: reimplement devid->disk in terms

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 11 of 27 v2] libxl: reimplement devid->disk in terms of from_xs_be function
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 13 Oct 2011 10:53:36 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 13 Oct 2011 03:22:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1318499605@xxxxxxxxxxxxxxxxxxxxx>
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>
References: <patchbomb.1318499605@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1318499565 -3600
# Node ID 521f9749c03271cc3de0b95e2bf1ea574080fd90
# Parent  0ffea6ba20dddbf2a79cfed884a5444446c196ba
libxl: reimplement devid->disk in terms of from_xs_be function.

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

diff -r 0ffea6ba20dd -r 521f9749c032 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Oct 13 10:52:45 2011 +0100
+++ b/tools/libxl/libxl.c       Thu Oct 13 10:52:45 2011 +0100
@@ -1656,6 +1656,33 @@ static void libxl__device_disk_from_xs_b
     disk->format = LIBXL_DISK_FORMAT_UNKNOWN;
 }
 
+int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid,
+                               const char *devid, libxl_device_disk *disk)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    char *dompath, *path;
+    int rc = ERROR_FAIL;
+
+    memset(disk, 0, sizeof (libxl_device_disk));
+    dompath = libxl__xs_get_dompath(&gc, domid);
+    if (!dompath) {
+        goto out;
+    }
+    path = libxl__xs_read(&gc, XBT_NULL,
+                          libxl__sprintf(&gc, "%s/device/vbd/%s/backend",
+                                         dompath, devid));
+    if (!path)
+        goto out;
+
+    libxl__device_disk_from_xs_be(&gc, path, disk);
+
+    rc = 0;
+out:
+    libxl__free_all(&gc);
+    return rc;
+}
+
+
 static int libxl__append_disk_list_of_type(libxl__gc *gc,
                                            uint32_t domid,
                                            const char *type,
diff -r 0ffea6ba20dd -r 521f9749c032 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Thu Oct 13 10:52:45 2011 +0100
+++ b/tools/libxl/libxl_utils.c Thu Oct 13 10:52:45 2011 +0100
@@ -483,50 +483,6 @@ int libxl_mac_to_device_nic(libxl_ctx *c
     return rc;
 }
 
-int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid,
-                               const char *devid, libxl_device_disk *disk)
-{
-    libxl__gc gc = LIBXL_INIT_GC(ctx);
-    char *val;
-    char *dompath, *diskpath, *be_path;
-    unsigned int devid_n;
-    int rc = ERROR_INVAL;
-
-    devid_n = libxl__device_disk_dev_number(devid, NULL, NULL);
-    if (devid_n < 0) {
-        goto out;
-    }
-    rc = ERROR_FAIL;
-    dompath = libxl__xs_get_dompath(&gc, domid);
-    diskpath = libxl__sprintf(&gc, "%s/device/vbd/%d", dompath, devid_n);
-    if (!diskpath) {
-        goto out;
-    }
-
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend-id", 
diskpath));
-    if (!val)
-        goto out;
-    disk->backend_domid = strtoul(val, NULL, 10);
-    be_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend", 
diskpath));
-    disk->pdev_path = xs_read(ctx->xsh, XBT_NULL,
-                              libxl__sprintf(&gc, "%s/params", be_path), NULL);
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/type", 
be_path));
-    libxl_string_to_backend(ctx, val, &(disk->backend));
-    disk->vdev = xs_read(ctx->xsh, XBT_NULL,
-                         libxl__sprintf(&gc, "%s/dev", be_path), NULL);
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/removable", 
be_path));
-    disk->removable = !strcmp(val, "1");
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/mode", 
be_path));
-    disk->readwrite = !!strcmp(val, "w");
-    val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/device-type", 
diskpath));
-    disk->is_cdrom = !strcmp(val, "cdrom");
-    rc = 0;
-
-out:
-    libxl__free_all(&gc);
-    return rc;
-}
-
 int libxl_cpumap_alloc(libxl_ctx *ctx, libxl_cpumap *cpumap)
 {
     int max_cpus;

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

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