aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_device.c
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:09 +0100
committerIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:09 +0100
commit089f08b94cc7567b5716bfc3bfddbe5ff801a211 (patch)
treeb1c3e21f8c021dbfd5008d08069e624be2eb16c2 /tools/libxl/libxl_device.c
parent5ce5fe6d3798fc51b68fbf5cbea1c2c5c5d1124f (diff)
downloadxen-089f08b94cc7567b5716bfc3bfddbe5ff801a211.tar.gz
xen-089f08b94cc7567b5716bfc3bfddbe5ff801a211.tar.bz2
xen-089f08b94cc7567b5716bfc3bfddbe5ff801a211.zip
libxl: fix hang due to libxl__initiate_device_remove
libxl__initiate_device_remove might discover that the operation was complete, immediately (typically, if the device is already removed). Previously, in this situation, it would return 0 to the caller but never call libxl__ao_complete. Fix this. This necessitates passing the egc in from the functions which are the ao initiators. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Roger Pau Monne <roger.pau@entel.upc.edu> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_device.c')
-rw-r--r--tools/libxl/libxl_device.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index c2880e080d..c7e057dcb7 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -376,7 +376,8 @@ static void device_remove_callback(libxl__egc *egc, libxl__ev_devstate *ds,
device_remove_cleanup(gc, aorm);
}
-int libxl__initiate_device_remove(libxl__ao *ao, libxl__device *dev)
+int libxl__initiate_device_remove(libxl__egc *egc, libxl__ao *ao,
+ libxl__device *dev)
{
AO_GC;
libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -388,11 +389,11 @@ int libxl__initiate_device_remove(libxl__ao *ao, libxl__device *dev)
libxl__ao_device_remove *aorm = 0;
if (!state)
- goto out;
+ goto out_ok;
if (atoi(state) != 4) {
libxl__device_destroy_tapdisk(gc, be_path);
xs_rm(ctx->xsh, XBT_NULL, be_path);
- goto out;
+ goto out_ok;
}
retry_transaction:
@@ -404,7 +405,7 @@ retry_transaction:
goto retry_transaction;
else {
rc = ERROR_FAIL;
- goto out;
+ goto out_fail;
}
}
@@ -417,13 +418,18 @@ retry_transaction:
rc = libxl__ev_devstate_wait(gc, &aorm->ds, device_remove_callback,
state_path, XenbusStateClosed,
LIBXL_DESTROY_TIMEOUT * 1000);
- if (rc) goto out;
+ if (rc) goto out_fail;
return 0;
- out:
+ out_fail:
+ assert(rc);
device_remove_cleanup(gc, aorm);
return rc;
+
+ out_ok:
+ libxl__ao_complete(egc, ao, 0);
+ return 0;
}
int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)