aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_dm.c
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@citrix.com>2012-07-26 16:47:31 +0100
committerRoger Pau Monne <roger.pau@citrix.com>2012-07-26 16:47:31 +0100
commit2d40cd6513387013f2d0409af1366f738ffa134d (patch)
tree48304b21f1066a3593328cb8e0584063099c8719 /tools/libxl/libxl_dm.c
parent962eb2acbb8af50f8cddc28ad4479fe9661ab65c (diff)
downloadxen-2d40cd6513387013f2d0409af1366f738ffa134d.tar.gz
xen-2d40cd6513387013f2d0409af1366f738ffa134d.tar.bz2
xen-2d40cd6513387013f2d0409af1366f738ffa134d.zip
libxl: convert libxl_device_nic_add to an async operation
This patch converts libxl_device_nic_add to an ao operation that waits for device backend to reach state XenbusStateInitWait and then marks the operation as completed. This is not really useful now, but will be used by latter patches that will launch hotplug scripts after we reached the desired xenbus state. Calls to libxl_device_nic_add have also been moved to occur after the device model has been launched, so when hotplug scripts are called from this functions the interfaces already exists. As usual, libxl_device_nic_add callers have been modified, and the internal function libxl__device_disk_add has been used if the call was inside an already running ao. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_dm.c')
-rw-r--r--tools/libxl/libxl_dm.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 8a731ae500..1b17ef516f 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -716,6 +716,10 @@ static void spawn_stubdom_pvqemu_cb(libxl__egc *egc,
static void spawn_stub_launch_dm(libxl__egc *egc,
libxl__ao_devices *aodevs, int ret);
+static void stubdom_pvqemu_cb(libxl__egc *egc,
+ libxl__ao_devices *aodevs,
+ int rc);
+
static void spaw_stubdom_pvqemu_destroy_cb(libxl__egc *egc,
libxl__destroy_domid_state *dis,
int rc);
@@ -887,9 +891,11 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
}
for (i = 0; i < dm_config->num_nics; i++) {
- ret = libxl_device_nic_add(ctx, dm_domid, &dm_config->nics[i]);
- if (ret)
- goto out;
+ /* We have to init the nic here, because we still haven't
+ * called libxl_device_nic_add at this point, but qemu needs
+ * the nic information to be complete.
+ */
+ libxl__device_nic_setdefault(gc, &dm_config->nics[i]);
}
ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]);
if (ret)
@@ -966,9 +972,35 @@ static void spawn_stubdom_pvqemu_cb(libxl__egc *egc,
CONTAINER_OF(stubdom_dmss, *sdss, pvqemu);
STATE_AO_GC(sdss->dm.spawn.ao);
uint32_t dm_domid = sdss->pvqemu.guest_domid;
+ libxl_domain_config *d_config = stubdom_dmss->guest_config;
if (rc) goto out;
+ if (d_config->num_nics > 0) {
+ sdss->aodevs.size = d_config->num_nics;
+ sdss->aodevs.callback = stubdom_pvqemu_cb;
+ libxl__prepare_ao_devices(ao, &sdss->aodevs);
+ libxl__add_nics(egc, ao, dm_domid, 0, d_config, &sdss->aodevs);
+ return;
+ }
+
+out:
+ stubdom_pvqemu_cb(egc, &sdss->aodevs, rc);
+}
+
+static void stubdom_pvqemu_cb(libxl__egc *egc,
+ libxl__ao_devices *aodevs,
+ int rc)
+{
+ libxl__stub_dm_spawn_state *sdss = CONTAINER_OF(aodevs, *sdss, aodevs);
+ STATE_AO_GC(sdss->dm.spawn.ao);
+ uint32_t dm_domid = sdss->pvqemu.guest_domid;
+
+ if (rc) {
+ LOGE(ERROR, "error connecting nics devices");
+ goto out;
+ }
+
rc = libxl_domain_unpause(CTX, dm_domid);
if (rc) goto out;