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

[Xen-changelog] [xen-unstable] libxl: make domain resume API asynchronous


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Fri, 24 Aug 2012 03:11:10 +0000
  • Delivery-date: Fri, 24 Aug 2012 03:11:28 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1345744809 -3600
# Node ID 53e35329b07f90d07eb3e96d3ed24db46ece2d28
# Parent  c29ffdfae39b9e19ee8cd1e7b4ee22f1409ded28
libxl: make domain resume API asynchronous

Although the current implementation has no asynchromous parts I can
envisage it needing to do bits of create/destroy like functionality
which may need async support in the future.

To do this make the meat into an internal libxl__domain_resume
function in order to satisfy the no-internal-callers rule for the
async function.

Since I needed to touch the logging to s/ctx/CTX/ anyway switch to the
LOG* helper macros.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r c29ffdfae39b -r 53e35329b07f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Aug 23 15:06:11 2012 +0100
+++ b/tools/libxl/libxl.c       Thu Aug 23 19:00:09 2012 +0100
@@ -396,15 +396,12 @@ int libxl_domain_rename(libxl_ctx *ctx, 
     return rc;
 }
 
-int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel)
+int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel)
 {
-    GC_INIT(ctx);
     int rc = 0;
 
-    if (xc_domain_resume(ctx->xch, domid, suspend_cancel)) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
-                        "xc_domain_resume failed for domain %u",
-                        domid);
+    if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) {
+        LOGE(ERROR, "xc_domain_resume failed for domain %u", domid);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -418,24 +415,29 @@ int libxl_domain_resume(libxl_ctx *ctx, 
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
         rc = libxl__domain_resume_device_model(gc, domid);
         if (rc) {
-            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                       "failed to resume device model for domain %u:%d",
-                       domid, rc);
+            LOG(ERROR, "failed to resume device model for domain %u:%d",
+                domid, rc);
             goto out;
         }
     }
 
-    if (!xs_resume_domain(ctx->xsh, domid)) {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
-                        "xs_resume_domain failed for domain %u",
-                        domid);
+    if (!xs_resume_domain(CTX->xsh, domid)) {
+        LOGE(ERROR, "xs_resume_domain failed for domain %u", domid);
         rc = ERROR_FAIL;
     }
 out:
-    GC_FREE;
     return rc;
 }
 
+int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel,
+                        const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    int rc = libxl__domain_resume(gc, domid, suspend_cancel);
+    libxl__ao_complete(egc, ao, rc);
+    return AO_INPROGRESS;
+}
+
 /*
  * Preserves a domain but rewrites xenstore etc to make it unique so
  * that the domain can be restarted.
diff -r c29ffdfae39b -r 53e35329b07f tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Aug 23 15:06:11 2012 +0100
+++ b/tools/libxl/libxl.h       Thu Aug 23 19:00:09 2012 +0100
@@ -529,7 +529,9 @@ int libxl_domain_suspend(libxl_ctx *ctx,
  *   If this parameter is true, use co-operative resume. The guest
  *   must support this.
  */
-int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel);
+int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel,
+                        const libxl_asyncop_how *ao_how)
+                        LIBXL_EXTERNAL_CALLERS_ONLY;
 
 int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
                              uint32_t domid, int send_fd, int recv_fd,
diff -r c29ffdfae39b -r 53e35329b07f tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Thu Aug 23 15:06:11 2012 +0100
+++ b/tools/libxl/libxl_dom.c   Thu Aug 23 19:00:09 2012 +0100
@@ -1121,7 +1121,7 @@ static int libxl__remus_domain_resume_ca
     STATE_AO_GC(dss->ao);
 
     /* Resumes the domain and the device model */
-    if (libxl_domain_resume(CTX, dss->domid, /* Fast Suspend */1))
+    if (libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1))
         return 0;
 
     /* REMUS TODO: Deal with disk. Start a new network output buffer */
diff -r c29ffdfae39b -r 53e35329b07f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Aug 23 15:06:11 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Thu Aug 23 19:00:09 2012 +0100
@@ -899,6 +899,9 @@ _hidden int libxl__domain_resume_device_
 
 _hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid);
 
+_hidden int libxl__domain_resume(libxl__gc *gc, uint32_t domid,
+                                 int suspend_cancel);
+
 /* returns 0 or 1, or a libxl error code */
 _hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);
 
diff -r c29ffdfae39b -r 53e35329b07f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Aug 23 15:06:11 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Aug 23 19:00:09 2012 +0100
@@ -2854,7 +2854,7 @@ static int save_domain(const char *p, co
     close(fd);
 
     if (checkpoint)
-        libxl_domain_resume(ctx, domid, 1);
+        libxl_domain_resume(ctx, domid, 1, 0);
     else
         libxl_domain_destroy(ctx, domid, 0);
 
@@ -3105,7 +3105,7 @@ static void migrate_domain(const char *d
         if (common_domname) {
             libxl_domain_rename(ctx, domid, away_domname, common_domname);
         }
-        rc = libxl_domain_resume(ctx, domid, 0);
+        rc = libxl_domain_resume(ctx, domid, 0, 0);
         if (!rc) fprintf(stderr, "migration sender: Resumed OK.\n");
 
         fprintf(stderr, "Migration failed due to problems at target.\n");
@@ -3127,7 +3127,7 @@ static void migrate_domain(const char *d
     close(send_fd);
     migration_child_report(recv_fd);
     fprintf(stderr, "Migration failed, resuming at sender.\n");
-    libxl_domain_resume(ctx, domid, 0);
+    libxl_domain_resume(ctx, domid, 0, 0);
     exit(-ERROR_FAIL);
 
  failed_badly:
@@ -6646,7 +6646,7 @@ int main_remus(int argc, char **argv)
         fprintf(stderr, "Failed to suspend domain at primary.\n");
     else {
         fprintf(stderr, "Remus: Backup failed? resuming domain at primary.\n");
-        libxl_domain_resume(ctx, domid, 1);
+        libxl_domain_resume(ctx, domid, 1, 0);
     }
 
     close(send_fd);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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