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

[Xen-devel] [PATCH RFC v2 5/8] Improved migration flow syntax in libxl



---
 tools/libxl/libxl_create.c       |  5 +++--
 tools/libxl/libxl_dm.c           | 10 +++++-----
 tools/libxl/libxl_internal.h     |  4 ++--
 tools/libxl/libxl_save_callout.c | 41 +++++++++++++++++++++-------------------
 tools/libxl/libxl_save_helper.c  | 15 ++++++++++-----
 tools/libxl/libxl_types.idl      |  6 ++++++
 6 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f10f2ce..6df2754 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1121,6 +1121,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
     dcs->sdss.dm.spawn.ao = ao;
     dcs->sdss.dm.guest_config = dcs->guest_config;
     dcs->sdss.dm.build_state = &dcs->build_state;
+    dcs->sdss.dm.mirror_qemu_disks = dcs->mirror_qemu_disks;
     if(!dcs->mirror_qemu_disks) {
         dcs->sdss.dm.callback = domcreate_devmodel_started;
         dcs->sdss.callback = domcreate_devmodel_started;
@@ -1518,7 +1519,7 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__multidev *multidev,
         if (libxl_defbool_val(d_config->b_info.device_model_stubdomain))
             libxl__spawn_stub_dm(egc, &dcs->sdss);
         else
-            libxl__spawn_local_dm(egc, &dcs->sdss.dm, dcs->mirror_qemu_disks);
+            libxl__spawn_local_dm(egc, &dcs->sdss.dm);
 
         /*
          * Handle the domain's (and the related stubdomain's) access to
@@ -1550,7 +1551,7 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__multidev *multidev,
             goto error_out;
         if (ret) {
             dcs->sdss.dm.guest_domid = domid;
-            libxl__spawn_local_dm(egc, &dcs->sdss.dm, 0);
+            libxl__spawn_local_dm(egc, &dcs->sdss.dm);
             return;
         } else {
             assert(!dcs->sdss.dm.guest_domid);
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index ff6721d..001e14e 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1396,7 +1396,7 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
         }
     }
 
-    if (state->saved_state && !mirror_qemu_disks) {
+    if (state->saved_state) {
         /* This file descriptor is meant to be used by QEMU */
         *dm_state_fd = open(state->saved_state, O_RDONLY);
         flexarray_append(dm_args, "-incoming");
@@ -2062,7 +2062,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
         /* If dom0 qemu not needed, do not launch it */
         spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, 0);
     } else {
-        libxl__spawn_local_dm(egc, &sdss->pvqemu, 0);
+        libxl__spawn_local_dm(egc, &sdss->pvqemu);
     }
 
     return;
@@ -2167,8 +2167,7 @@ static void device_model_spawn_outcome(libxl__egc *egc,
                                        libxl__dm_spawn_state *dmss,
                                        int rc);
 
-void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss,
-                           int mirror_qemu_disks)
+void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
 {
     /* convenience aliases */
     const int domid = dmss->guest_domid;
@@ -2208,7 +2207,8 @@ void libxl__spawn_local_dm(libxl__egc *egc, 
libxl__dm_spawn_state *dmss,
     }
     rc = libxl__build_device_model_args(gc, dm, domid, guest_config,
                                           &args, &envs, state,
-                                          &dm_state_fd, mirror_qemu_disks);
+                                          &dm_state_fd,
+                                          dmss->mirror_qemu_disks);
     if (rc)
         goto out;
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 16a476f..30862c6 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3780,7 +3780,7 @@ _hidden void libxl__domain_save(libxl__egc *egc,
 _hidden void libxl__xc_domain_save(libxl__egc *egc,
                                    libxl__domain_save_state *dss,
                                    libxl__save_helper_state *shs,
-                                   int mirror_qemu_disks);
+                                   int migration_phase);
 /* If rc==0 then retval is the return value from xc_domain_save
  * and errnoval is the errno value it provided.
  * If rc!=0, retval and errnoval are undefined. */
@@ -3813,7 +3813,7 @@ _hidden int libxl__restore_emulator_xenstore_data
 _hidden void libxl__xc_domain_restore(libxl__egc *egc,
                                       libxl__domain_create_state *dcs,
                                       libxl__save_helper_state *shs,
-                                      int hvm, int pae, int mirror_qemu_disks);
+                                      int hvm, int pae, int migration_phase);
 /* If rc==0 then retval is the return value from xc_domain_save
  * and errnoval is the errno value it provided.
  * If rc!=0, retval and errnoval are undefined. */
diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c
index 290d91d..48f96d8 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -43,7 +43,7 @@ static void helper_done(libxl__egc *egc, 
libxl__save_helper_state *shs);
 
 void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs,
                               libxl__save_helper_state *shs,
-                              int hvm, int pae, int mirror_qemu_disks)
+                              int hvm, int pae, int migration_phase)
 {
     STATE_AO_GC(dcs->ao);
 
@@ -62,8 +62,7 @@ void libxl__xc_domain_restore(libxl__egc *egc, 
libxl__domain_create_state *dcs,
         state->store_domid, state->console_port,
         state->console_domid,
         hvm, pae,
-        cbflags, dcs->restore_params.checkpointed_stream,
-        mirror_qemu_disks,
+        cbflags, dcs->restore_params.checkpointed_stream
     };
 
     shs->ao = ao;
@@ -73,21 +72,25 @@ void libxl__xc_domain_restore(libxl__egc *egc, 
libxl__domain_create_state *dcs,
         LIBXL_CHECKPOINTED_STREAM_COLO) {
         shs->completion_callback = libxl__colo_restore_teardown;
     } else {
-        if(!mirror_qemu_disks){
+        if ( migration_phase != LIBXL_MIGRATION_PHASE_MIRROR_DISK ) {
             shs->completion_callback = libxl__xc_domain_restore_done;
+            if( local_disks == LIBXL_MIGRATION_PHASE_VIRTUAL_RAM )
+                shs->need_results = 0;
+            else
+                shs->need_results = 1;
         } else {
-            shs->completion_callback = libxl__xc_hvm_params_restore_done;
+            shs->completion_callback = libxl__xc_mirror_disks_restore_done;
+            shs->need_results = 1;
         }
     }
     shs->caller_state = dcs;
-    shs->need_results = 1;
 
     run_helper(egc, shs, "--restore-domain", restore_fd, send_back_fd, 0, 0,
                argnums, ARRAY_SIZE(argnums));
 }
 
 void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss,
-                           libxl__save_helper_state *shs, int 
mirror_qemu_disks)
+                           libxl__save_helper_state *shs, int migration_phase)
 {
     STATE_AO_GC(dss->ao);
 
@@ -96,17 +99,17 @@ void libxl__xc_domain_save(libxl__egc *egc, 
libxl__domain_save_state *dss,
 
     const unsigned long argnums[] = {
         dss->domid, 0, 0, dss->xcflags, dss->hvm,
-        cbflags, dss->checkpointed_stream, mirror_qemu_disks,
+        cbflags, dss->checkpointed_stream, migration_phase,
     };
 
     shs->ao = ao;
     shs->domid = dss->domid;
     shs->recv_callback = libxl__srm_callout_received_save;
-    if(!mirror_qemu_disks){
+     if ( migration_phase != LIBXL_MIGRATION_PHASE_MIRROR_DISK )
         shs->completion_callback = libxl__xc_domain_save_done;
-    }else{
-        shs->completion_callback = libxl__xc_hvm_params_save_done;
-    }
+    else
+        shs->completion_callback = libxl__xc_mirror_disks_save_done;
+
     shs->caller_state = dss;
     shs->need_results = 0;
 
@@ -346,13 +349,13 @@ static void helper_exited(libxl__egc *egc, 
libxl__ev_child *ch,
         if (!shs->rc)
             shs->rc = ERROR_FAIL;
     }
-//    balvisio: TODO: FIX
-//    if (shs->need_results) {
-//        if (!shs->rc) {
-//            LOGD(ERROR,shs->domid,"%s exited without providing 
results",what);
-//            shs->rc = ERROR_FAIL;
-//        }
-//    }
+
+    if (shs->need_results) {
+        if (!shs->rc) {
+            LOGD(ERROR,shs->domid,"%s exited without providing results",what);
+            shs->rc = ERROR_FAIL;
+        }
+    }
 
     if (!shs->completed) {
         if (!shs->rc) {
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
index cfc9279..9a57b28 100644
--- a/tools/libxl/libxl_save_helper.c
+++ b/tools/libxl/libxl_save_helper.c
@@ -257,7 +257,7 @@ int main(int argc, char **argv)
         int hvm =                           atoi(NEXTARG);
         unsigned cbflags =                  strtoul(NEXTARG,0,10);
         xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
-        int mirror_qemu_disks =                   atoi(NEXTARG);
+        int migration_phase =               atoi(NEXTARG);
         assert(!*++argv);
 
         helper_setcallbacks_save(&helper_save_callbacks, cbflags);
@@ -267,7 +267,7 @@ int main(int argc, char **argv)
 
         r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, flags,
                            &helper_save_callbacks, hvm, stream_type,
-                           recv_fd, mirror_qemu_disks);
+                           recv_fd, migration_phase);
         complete(r);
 
     } else if (!strcmp(mode,"--restore-domain")) {
@@ -283,7 +283,7 @@ int main(int argc, char **argv)
         unsigned int pae =                  strtoul(NEXTARG,0,10);
         unsigned cbflags =                  strtoul(NEXTARG,0,10);
         xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
-        int mirror_qemu_disks =             atoi(NEXTARG);
+        int migration_phase =               atoi(NEXTARG);
         assert(!*++argv);
 
         helper_setcallbacks_restore(&helper_restore_callbacks, cbflags);
@@ -298,8 +298,13 @@ int main(int argc, char **argv)
                               store_domid, console_evtchn, &console_mfn,
                               console_domid, hvm, pae,
                               stream_type,
-                              &helper_restore_callbacks, send_back_fd);
-        helper_stub_restore_results(store_mfn,console_mfn,0);
+                              &helper_restore_callbacks, send_back_fd,
+                              migration_phase);
+
+        if (migration_phase == LIBXL_MIGRATION_PHASE_NON_LOCAL_DISK ||
+            migration_phase == LIBXL_MIGRATION_PHASE_MIRROR_DISK) {
+            helper_stub_restore_results(store_mfn,console_mfn,0);
+        }
         complete(r);
 
     } else {
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 173d70a..de5f536 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -240,6 +240,12 @@ libxl_checkpointed_stream = 
Enumeration("checkpointed_stream", [
     (2, "COLO"),
     ])
 
+libxl_stream_phase = Enumeration("migration_phase", [
+    (0, "NON_LOCAL_DISK"),
+    (1, "VIRTUAL_RAM"),
+    (2, "MIRROR_DISK"),
+    ])
+
 #
 # Complex libxl types
 #
-- 
2.3.2 (Apple Git-55)


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

 


Rackspace

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