libxenlight: get state for one domain
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 4 Dec 2009 07:11:44 +0000 (07:11 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 4 Dec 2009 07:11:44 +0000 (07:11 +0000)
Simple function to get the dominfo state of a single domain.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
tools/libxl/libxl.c
tools/libxl/libxl.h

index 7a01dc5df17e225ff1233bd2fee834b370efb603..39373385fc93d14f2b57871ec5626583cff4ff53 100644 (file)
@@ -362,6 +362,31 @@ static int libxl_save_device_model(struct libxl_ctx *ctx, uint32_t domid, int fd
     return 0;
 }
 
+xc_dominfo_t *libxl_domain_info(struct libxl_ctx *ctx, uint32_t domid)
+{
+    xc_dominfo_t *info;
+    int rc;
+
+    info = (xc_dominfo_t *) calloc(1, sizeof(xc_dominfo_t));
+    if (!info) {
+        return NULL;
+    }
+    rc = xc_domain_getinfo(ctx->xch, domid, 1, info);
+    if (rc != 1) {
+        free(info);
+        XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "Failed to get info for domain %u", 
+                        domid);
+        return NULL;
+    }
+    if (info->domid != domid) {
+        free(info);
+        XL_LOG(ctx, XL_LOG_ERROR, "Failed to get info for domain %u"
+                        ", seems to not exist anymore", domid);
+        return NULL;
+    }
+
+    return info;
+}
 int libxl_domain_suspend(struct libxl_ctx *ctx, libxl_domain_suspend_info *info,
                          uint32_t domid, int fd)
 {
index a07918520ff075980ea91f31220a1ec717d6f677..2ac3669afab48830b1b577bacb28c1d8c6e3e60c 100644 (file)
@@ -276,6 +276,7 @@ int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num);
 
 struct libxl_dominfo * libxl_domain_list(struct libxl_ctx *ctx, int *nb_domain);
 xc_dominfo_t * libxl_domain_infolist(struct libxl_ctx *ctx, int *nb_domain);
+xc_dominfo_t * libxl_domain_info(struct libxl_ctx *ctx, uint32_t domid);
 
 typedef struct libxl_device_model_starting libxl_device_model_starting;
 int libxl_create_device_model(struct libxl_ctx *ctx,