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

[Xen-devel] [PATCH 21 of 29 RFC] libxl: add libxl__parse_hotplug_path



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1328178994 -3600
# Node ID 346d86654b1dd81b5aba821bf9732844bb35c7a3
# Parent  bc38aa2e11e21b34dbc29a81f069133a3276848a
libxl: add libxl__parse_hotplug_path

Generate libxl__device from hotplug path.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

diff -r bc38aa2e11e2 -r 346d86654b1d tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Thu Feb 02 11:33:27 2012 +0100
+++ b/tools/libxl/libxl_device.c        Thu Feb 02 11:36:34 2012 +0100
@@ -66,6 +66,24 @@ int libxl__parse_backend_path(libxl__gc 
     return libxl__device_kind_from_string(strkind, &dev->backend_kind);
 }
 
+int libxl__parse_hotplug_path(libxl__gc *gc,
+                              const char *path,
+                              libxl__device *dev)
+{
+    /* /hotplug/<backend_domid>/<frontend_domid>/<kind> */
+    char strkind[16]; /* Longest is actually "console" */
+    int rc = sscanf(path, "/hotplug/%u/%u/%15[^/]/%d",
+                    &dev->backend_domid,
+                    &dev->domid,
+                    strkind,
+                    &dev->devid);
+
+    if (rc != 4)
+        return ERROR_FAIL;
+
+    return libxl__device_kind_from_string(strkind, &dev->backend_kind);
+}
+
 int libxl__device_generic_add(libxl__gc *gc, libxl__device *device,
                              char **bents, char **fents)
 {
diff -r bc38aa2e11e2 -r 346d86654b1d tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Feb 02 11:33:27 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Thu Feb 02 11:36:34 2012 +0100
@@ -307,6 +307,9 @@ typedef struct {
 _hidden char *libxl__device_hotplug_path(libxl__gc *gc, libxl__device *device);
 _hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
                                       libxl__device *dev);
+_hidden int libxl__parse_hotplug_path(libxl__gc *gc,
+                                      const char *path,
+                                      libxl__device *dev);
 _hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid);

_______________________________________________
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®.