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

[PATCH 2/5] libxl: Add utility function to check guest status



This is used to check that a guest has not been destroyed and to obtain
information about it.  It will be used in subsequent patches.

Signed-off-by: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
---
 tools/libs/light/libxl_dom_suspend.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/tools/libs/light/libxl_dom_suspend.c 
b/tools/libs/light/libxl_dom_suspend.c
index 
fa50e8801f35d173a99ae5dd19eb941649e14019..d2a88ea34efb115a8f2b861daf5884d95f39e81d
 100644
--- a/tools/libs/light/libxl_dom_suspend.c
+++ b/tools/libs/light/libxl_dom_suspend.c
@@ -321,27 +321,36 @@ static void suspend_common_wait_guest_watch(libxl__egc 
*egc,
     suspend_common_wait_guest_check(egc, dsps);
 }
 
+static int check_guest_status(libxl__gc *gc, const uint32_t domid,
+                              xc_domaininfo_t *info, const char *what)
+{
+    int ret = xc_domain_getinfolist(CTX->xch, domid, 1, info);
+
+    if (ret < 0) {
+        LOGED(ERROR, domid, "unable to check for status of guest");
+        return ERROR_FAIL;
+    }
+
+    if (!(ret == 1 && info->domain == domid)) {
+        LOGED(ERROR, domid, "guest we were %s has been destroyed", what);
+        return ERROR_FAIL;
+    }
+
+    return 0;
+}
+
 static void suspend_common_wait_guest_check(libxl__egc *egc,
         libxl__domain_suspend_state *dsps)
 {
     STATE_AO_GC(dsps->ao);
     xc_domaininfo_t info;
-    int ret;
     int shutdown_reason;
 
     /* Convenience aliases */
     const uint32_t domid = dsps->domid;
 
-    ret = xc_domain_getinfolist(CTX->xch, domid, 1, &info);
-    if (ret < 0) {
-        LOGED(ERROR, domid, "unable to check for status of guest");
+    if (check_guest_status(gc, domid, &info, "suspending"))
         goto err;
-    }
-
-    if (!(ret == 1 && info.domain == domid)) {
-        LOGED(ERROR, domid, "guest we were suspending has been destroyed");
-        goto err;
-    }
 
     if (!(info.flags & XEN_DOMINF_shutdown))
         /* keep waiting */
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab



 


Rackspace

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