diff mbox

[24/28] libxl: dm spawn records rc in state struct rather than passing as argument

Message ID 1450809903-3393-25-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Dec. 22, 2015, 6:44 p.m. UTC
This is going to be much more convenient in a moment, when one of the
call sites is going to want to run two in parallel.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v6: New patch.
---
 tools/libxl/libxl.c          |    4 ++--
 tools/libxl/libxl_create.c   |   14 +++++++-------
 tools/libxl/libxl_dm.c       |   22 +++++++++++++---------
 tools/libxl/libxl_internal.h |    5 +++--
 4 files changed, 25 insertions(+), 20 deletions(-)
diff mbox

Patch

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index dff4478..3bb6d3b 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4345,10 +4345,10 @@  static void device_complete(libxl__egc *egc, libxl__ao_device *aodev)
     libxl__nested_ao_free(aodev->ao);
 }
 
-static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss,
-                                int rc)
+static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss)
 {
     STATE_AO_GC(dmss->spawn.ao);
+    int rc = dmss->rc;
 
     LOG(DEBUG, "qdisk backend spawn for domain %u %s", dmss->guest_domid,
                rc ? "failed" : "succeed");
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index be9bb7b..e67e402 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -803,8 +803,7 @@  static void remus_checkpoint_stream_done(
 static void domcreate_dm_support_checked(libxl__egc *egc,
     libxl__dm_support_check_state *checking, int rc);
 static void domcreate_devmodel_started(libxl__egc *egc,
-                                       libxl__dm_spawn_state *dmss,
-                                       int rc);
+                                       libxl__dm_spawn_state *dmss);
 static void domcreate_bootloader_console_available(libxl__egc *egc,
                                                    libxl__bootloader_state *bl);
 static void domcreate_bootloader_done(libxl__egc *egc,
@@ -1387,8 +1386,8 @@  static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
 
         if (d_config->b_info.device_model_version ==
             LIBXL_DEVICE_MODEL_VERSION_NONE) {
-            domcreate_devmodel_started(egc, &dcs->dmss.dm, 0);
-            return;
+            dcs->dmss.dm.rc = 0;
+            domcreate_devmodel_started(egc, &dcs->dmss.dm);
         }
 
         libxl_device_vkb_init(&vkb);
@@ -1440,7 +1439,8 @@  static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
             return;
         } else {
             assert(!dcs->dmss.dm.guest_domid);
-            domcreate_devmodel_started(egc, &dcs->dmss.dm, 0);
+            dcs->dmss.dm.rc = 0;
+            domcreate_devmodel_started(egc, &dcs->dmss.dm);
             return;
         }
     }
@@ -1456,11 +1456,11 @@  static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
 }
 
 static void domcreate_devmodel_started(libxl__egc *egc,
-                                       libxl__dm_spawn_state *dmss,
-                                       int ret)
+                                       libxl__dm_spawn_state *dmss)
 {
     libxl__domain_create_state *dcs = CONTAINER_OF(dmss, *dcs, dmss.dm);
     STATE_AO_GC(dmss->spawn.ao);
+    int ret = dmss->rc;
     int domid = dcs->guest_domid;
 
     /* convenience aliases */
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 5e1a6cf..58760e7 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1369,8 +1369,7 @@  retry_transaction:
 }
 
 static void spawn_stubdom_pvqemu_cb(libxl__egc *egc,
-                                libxl__dm_spawn_state *stubdom_dmss,
-                                int rc);
+                                libxl__dm_spawn_state *stubdom_dmss);
 
 static void spawn_stub_launch_dm(libxl__egc *egc,
                                  libxl__multidev *aodevs, int ret);
@@ -1534,7 +1533,8 @@  retry_transaction:
 
 out:
     assert(ret);
-    spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret);
+    sdss->pvqemu.rc = ret;
+    spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu);
 }
 
 static void spawn_stub_launch_dm(libxl__egc *egc,
@@ -1632,16 +1632,17 @@  static void spawn_stub_launch_dm(libxl__egc *egc,
 
 out:
     assert(ret);
-    spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret);
+    sdss->pvqemu.rc = ret;
+    spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu);
 }
 
 static void spawn_stubdom_pvqemu_cb(libxl__egc *egc,
-                                libxl__dm_spawn_state *stubdom_dmss,
-                                int rc)
+                                libxl__dm_spawn_state *stubdom_dmss)
 {
     libxl__stub_dm_spawn_state *sdss =
         CONTAINER_OF(stubdom_dmss, *sdss, pvqemu);
     STATE_AO_GC(sdss->dm.spawn.ao);
+    int rc = stubdom_dmss->rc;
     uint32_t dm_domid = sdss->pvqemu.guest_domid;
     libxl_domain_config *d_config = stubdom_dmss->guest_config;
 
@@ -1712,7 +1713,8 @@  static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait,
         return;
  out:
     libxl__xswait_stop(gc, xswait);
-    sdss->callback(egc, &sdss->dm, rc);
+    sdss->dm.rc = rc;
+    sdss->callback(egc, &sdss->dm);
 }
 
 /* callbacks passed to libxl__spawn_spawn */
@@ -1929,7 +1931,8 @@  static void device_model_spawn_outcome(libxl__egc *egc,
     }
 
  out:
-    dmss->callback(egc, dmss, rc);
+    dmss->rc = rc;
+    dmss->callback(egc, dmss);
 }
 
 void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
@@ -2005,7 +2008,8 @@  error:
     assert(rc);
     if (logfile_w >= 0) close(logfile_w);
     if (null >= 0) close(null);
-    dmss->callback(egc, dmss, rc);
+    dmss->rc = rc;
+    dmss->callback(egc, dmss);
     return;
 }
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 350ec29..82f264a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3413,12 +3413,13 @@  _hidden void libxl__add_vtpms(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
 
 typedef struct libxl__dm_spawn_state libxl__dm_spawn_state;
 
-typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*,
-                                int rc /* if !0, error was logged */);
+typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*);
 
 struct libxl__dm_spawn_state {
     /* mixed - spawn.ao must be initialised by user; rest is private: */
     libxl__spawn_state spawn;
+    /* filled in by dm spawn just before making callback */
+    int rc; /* if !0, error was logged */
     /* filled in by user, must remain valid: */
     uint32_t guest_domid; /* domain being served */
     libxl_domain_config *guest_config;