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

[Xen-changelog] [xen master] libxl/remus: introduce libxl__remus_setup



commit c2302612338e9ed5a337649f53291dc5c9fcbd74
Author:     Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
AuthorDate: Fri Jul 10 14:57:52 2015 +0800
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Jul 21 14:10:00 2015 +0100

    libxl/remus: introduce libxl__remus_setup
    
    Refactoring Remus setup by introducing libxl__remus_setup API.
    All Remus setup work are done in this function.
    
    There is a subtle behavioural change here, which is that if anything
    which is now done in _setup fails then the result is a call to
    dss->callback( ..,..,ERROR_FAIL) rather than _start returning
    AO_CREATE_FAIL(ERROR_FAIL). But this is correct and intended.
    
    Also remove the libxl__ prefix for static functions.
    
    Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
    CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
    CC: Wei Liu <wei.liu2@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/libxl/libxl.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index d8343a9..312e261 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -802,10 +802,12 @@ out:
     return ptr;
 }
 
-static void libxl__remus_setup_done(libxl__egc *egc,
-                                    libxl__remus_devices_state *rds, int rc);
-static void libxl__remus_setup_failed(libxl__egc *egc,
-                                      libxl__remus_devices_state *rds, int rc);
+static void libxl__remus_setup(libxl__egc *egc,
+                               libxl__domain_suspend_state *dss);
+static void remus_setup_done(libxl__egc *egc,
+                             libxl__remus_devices_state *rds, int rc);
+static void remus_setup_failed(libxl__egc *egc,
+                               libxl__remus_devices_state *rds, int rc);
 static void remus_failover_cb(libxl__egc *egc,
                               libxl__domain_suspend_state *dss, int rc);
 
@@ -854,13 +856,26 @@ int libxl_domain_remus_start(libxl_ctx *ctx, 
libxl_domain_remus_info *info,
 
     assert(info);
 
+    /* Point of no return */
+    libxl__remus_setup(egc, dss);
+    return AO_INPROGRESS;
+
+ out:
+    return AO_CREATE_FAIL(rc);
+}
+
+static void libxl__remus_setup(libxl__egc *egc,
+                               libxl__domain_suspend_state *dss)
+{
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
+    const libxl_domain_remus_info *const info = dss->remus;
+
+    STATE_AO_GC(dss->ao);
 
     if (libxl_defbool_val(info->netbuf)) {
         if (!libxl__netbuffer_enabled(gc)) {
             LOG(ERROR, "Remus: No support for network buffering");
-            rc = ERROR_FAIL;
             goto out;
         }
         rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VIF);
@@ -870,19 +885,18 @@ int libxl_domain_remus_start(libxl_ctx *ctx, 
libxl_domain_remus_info *info,
         rds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VBD);
 
     rds->ao = ao;
-    rds->domid = domid;
-    rds->callback = libxl__remus_setup_done;
+    rds->domid = dss->domid;
+    rds->callback = remus_setup_done;
 
-    /* Point of no return */
     libxl__remus_devices_setup(egc, rds);
-    return AO_INPROGRESS;
+    return;
 
- out:
-    return AO_CREATE_FAIL(rc);
+out:
+    dss->callback(egc, dss, ERROR_FAIL);
 }
 
-static void libxl__remus_setup_done(libxl__egc *egc,
-                                    libxl__remus_devices_state *rds, int rc)
+static void remus_setup_done(libxl__egc *egc,
+                             libxl__remus_devices_state *rds, int rc)
 {
     libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
@@ -894,12 +908,12 @@ static void libxl__remus_setup_done(libxl__egc *egc,
 
     LOG(ERROR, "Remus: failed to setup device for guest with domid %u, rc %d",
         dss->domid, rc);
-    rds->callback = libxl__remus_setup_failed;
+    rds->callback = remus_setup_failed;
     libxl__remus_devices_teardown(egc, rds);
 }
 
-static void libxl__remus_setup_failed(libxl__egc *egc,
-                                      libxl__remus_devices_state *rds, int rc)
+static void remus_setup_failed(libxl__egc *egc,
+                               libxl__remus_devices_state *rds, int rc)
 {
     libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
     STATE_AO_GC(dss->ao);
--
generated by git-patchbot for /home/xen/git/xen.git#master

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