rc = libxl__device_from_disk(gc, domid, disk, &device);
if (rc != 0) goto out;
- rc = libxl__initiate_device_remove(ao, &device);
+ rc = libxl__initiate_device_remove(egc, ao, &device);
if (rc) goto out;
return AO_INPROGRESS;
rc = libxl__device_from_nic(gc, domid, nic, &device);
if (rc != 0) goto out;
- rc = libxl__initiate_device_remove(ao, &device);
+ rc = libxl__initiate_device_remove(egc, ao, &device);
if (rc) goto out;
return AO_INPROGRESS;
rc = libxl__device_from_vkb(gc, domid, vkb, &device);
if (rc != 0) goto out;
- rc = libxl__initiate_device_remove(ao, &device);
+ rc = libxl__initiate_device_remove(egc, ao, &device);
if (rc) goto out;
return AO_INPROGRESS;
rc = libxl__device_from_vfb(gc, domid, vfb, &device);
if (rc != 0) goto out;
- rc = libxl__initiate_device_remove(ao, &device);
+ rc = libxl__initiate_device_remove(egc, ao, &device);
if (rc) goto out;
return AO_INPROGRESS;
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);
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:
goto retry_transaction;
else {
rc = ERROR_FAIL;
- goto out;
+ goto out_fail;
}
}
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)
* this is done, the ao will be completed. An error
* return from libxl__initiate_device_remove means that the ao
* will _not_ be completed and the caller must do so. */
-_hidden int libxl__initiate_device_remove(libxl__ao*, libxl__device *dev);
+_hidden int libxl__initiate_device_remove(libxl__egc*, libxl__ao*,
+ libxl__device *dev);
/*
* libxl__ev_devstate - waits a given time for a device to