aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_create.c
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2012-08-03 09:54:09 +0100
committerIan Jackson <ian.jackson@eu.citrix.com>2012-08-03 09:54:09 +0100
commit258cd4e261de3b3f4470ba390b16c73101c802ce (patch)
tree390951657fdda2f1142cafa01d3662105c3f1eb6 /tools/libxl/libxl_create.c
parent7253e0fd1aeb3ae7d4714bcc1d86b846b3331995 (diff)
downloadxen-258cd4e261de3b3f4470ba390b16c73101c802ce.tar.gz
xen-258cd4e261de3b3f4470ba390b16c73101c802ce.tar.bz2
xen-258cd4e261de3b3f4470ba390b16c73101c802ce.zip
libxl: fix device counting race in libxl__devices_destroy
Don't have a fixed number of devices in the aodevs array, and instead size it depending on the devices present in xenstore. Somewhat formalise the multiple device addition/removal machinery to make this clearer and easier to do. As a side-effect we fix a few "lost thread of control" bug which would occur if there were no devices of a particular kind. (Various if statements which checked for there being no devices have become redundant, but are retained to avoid making the patch bigger.) Specifically: * Users of libxl__ao_devices are no longer expected to know in advance how many device operations they are going to do. Instead they can initiate them one at a time, between bracketing calls to "begin" and "prepared". * The array of aodevs used for this is dynamically sized; to support this it's an array of pointers rather than of structs. * Users of libxl__ao_devices are presented with a more opaque interface. They are are no longer expected to, themselves, - look into the array of aodevs (this is now private) - know that the individual addition/removal completions are handled by libxl__ao_devices_callback (this callback function is now a private function for the multidev machinery) - ever deal with populating the contents of an aodevs * The doc comments relating to some of the members of libxl__ao_device are clarified. (And the member `aodevs' is moved to put it with the other members with the same status.) * The multidev machinery allocates an aodev to represent the operation of preparing all of the other operations. See the comment in libxl__multidev_begin. A wrinkle is that the functions are called "multidev" but the structs are called "libxl__ao_devices" and "aodevs". I have given these functions this name to distinguish them from "libxl__ao_device" and "aodev" and so forth by more than just the use of the plural "s" suffix. In the next patch we will rename the structs. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/libxl/libxl_create.c')
-rw-r--r--tools/libxl/libxl_create.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index aafacd8c85..3265d69132 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -909,10 +909,10 @@ static void domcreate_rebuild_done(libxl__egc *egc,
store_libxl_entry(gc, domid, &d_config->b_info);
- dcs->aodevs.size = d_config->num_disks;
+ libxl__multidev_begin(ao, &dcs->aodevs);
dcs->aodevs.callback = domcreate_launch_dm;
- libxl__prepare_ao_devices(ao, &dcs->aodevs);
libxl__add_disks(egc, ao, domid, 0, d_config, &dcs->aodevs);
+ libxl__multidev_prepared(egc, &dcs->aodevs, 0);
return;
@@ -1039,10 +1039,10 @@ static void domcreate_devmodel_started(libxl__egc *egc,
/* Plug nic interfaces */
if (d_config->num_nics > 0) {
/* Attach nics */
- dcs->aodevs.size = d_config->num_nics;
+ libxl__multidev_begin(ao, &dcs->aodevs);
dcs->aodevs.callback = domcreate_attach_pci;
- libxl__prepare_ao_devices(ao, &dcs->aodevs);
libxl__add_nics(egc, ao, domid, 0, d_config, &dcs->aodevs);
+ libxl__multidev_prepared(egc, &dcs->aodevs, 0);
return;
}