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

[Xen-devel] [PATCH 24 of 29 RFC] libxl: add libxl_setup_hotplug_listener



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1328179503 -3600
# Node ID 1506b1f2ab0fe5f4cd5bcd86a566d5a7be5f838b
# Parent  2708343292be6facb6a2d8aaf9a9d95afa61b7f6
libxl: add libxl_setup_hotplug_listener

Setup a xenstore watch on /hotplug/<domid> to react to hotplug
changes.

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

diff -r 2708343292be -r 1506b1f2ab0f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Feb 02 11:42:13 2012 +0100
+++ b/tools/libxl/libxl.c       Thu Feb 02 11:45:03 2012 +0100
@@ -949,6 +949,40 @@ int libxl_vncviewer_exec(libxl_ctx *ctx,
 }
 
 
/******************************************************************************/
+/*
+ * Hotplug functions
+ *
+ */
+
+int libxl_setup_hotplug_listener(libxl_ctx *ctx)
+{
+    GC_INIT(ctx);
+    char *hotplug_path, *id;
+    int rc;
+
+    id = libxl__xs_read(gc, XBT_NULL, "domid");
+    if (!id) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to get domid");
+        rc = -1;
+        goto out;
+    }
+    hotplug_path = libxl__sprintf(gc, "/hotplug/%s", id);
+
+    xs_mkdir(ctx->xsh, XBT_NULL, hotplug_path);
+
+    if (!xs_watch(ctx->xsh, hotplug_path, hotplug_path)) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to watch /hotplug/%s", id);
+        rc = -1;
+        goto out;
+    }
+
+    rc = 0;
+out:
+    GC_FREE;
+    return rc;
+}
+
+/******************************************************************************/
 
 int libxl_device_disk_init(libxl_ctx *ctx, libxl_device_disk *disk)
 {
diff -r 2708343292be -r 1506b1f2ab0f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Feb 02 11:42:13 2012 +0100
+++ b/tools/libxl/libxl.h       Thu Feb 02 11:45:03 2012 +0100
@@ -456,6 +456,14 @@ libxl_vminfo * libxl_list_vm(libxl_ctx *
  *
  *   Requests de destruction of the given device and waits for the result.
  *
+ * Hotplug
+ * -------
+ *
+ * libxl_setup_hotplug_listener(ctx):
+ *
+ *   Set the necessary watches to start monitoring /hotplug/ entries for
+ *   the caller domain.
+ *
  */
 
 /* Disks */
@@ -523,6 +531,9 @@ int libxl_device_pci_remove(libxl_ctx *c
 int libxl_device_pci_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev);
 libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid, int 
*num);
 
+/* Hotplug */
+int libxl_setup_hotplug_listener(libxl_ctx *ctx);
+
 /*
  * Parse a PCI BDF into a PCI device structure.
  */

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