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

[Xen-devel] [PATCH v2 03/13] libxl: provide a function to retrieve the xenstore domain id



Add libxl_xenstore_domid() to obtain the domain id of the xenstore
domain.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/libxl/libxl.c | 24 ++++++++++++++++++++++++
 tools/libxl/libxl.h | 11 +++++++++++
 2 files changed, 35 insertions(+)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 9207621..3bcff59 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -701,6 +701,30 @@ int libxl_domain_info(libxl_ctx *ctx, libxl_dominfo 
*info_r,
     return 0;
 }
 
+int libxl_xenstore_domid(libxl_ctx *ctx, uint32_t *domid)
+{
+    xc_dominfo_t info;
+    uint32_t last_domid;
+    int ret;
+    GC_INIT(ctx);
+
+    for (last_domid = 0;
+         (ret = xc_domain_getinfo(ctx->xch, last_domid, 1, &info)) == 1;
+         last_domid = info.domid + 1)
+    {
+        if (info.xs_domain)
+        {
+            *domid = info.domid;
+            ret = 0;
+            goto out;
+        }
+    }
+    ret = (ret == 0) ? ERROR_DOMAIN_NOTFOUND : ERROR_FAIL;
+out:
+    GC_FREE;
+    return ret;
+}
+
 /* Returns:
  *   0 - success
  *   ERROR_FAIL + errno == ENOENT - no entry found
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 05606a7..41e9d88 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -867,6 +867,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, 
libxl_mac *src);
  */
 #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1
 
+/*
+ * LIBXL_HAVE_XENSTORE_DOMID
+ *
+ * If this is defined, then libxl_xenstore_domid is available.
+ */
+#define LIBXL_HAVE_XENSTORE_DOMID
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
@@ -1306,6 +1313,10 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t 
domid, int cons_num,
  */
 int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, char 
**path);
 
+/* Save domid of a possible Xenstore domain. If no Xenstore domain exists,
+ * ERROR_DOMAIN_NOTFOUND is returned. */
+int libxl_xenstore_domid(libxl_ctx *ctx, uint32_t *domid);
+
 /* May be called with info_r == NULL to check for domain's existence.
  * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return
  * ERROR_INVAL for this scenario). */
-- 
2.6.2


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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