aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_device.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-08-03 12:25:29 +0100
committerIan Campbell <ian.campbell@citrix.com>2012-08-03 12:25:29 +0100
commit4f6dda6a14abb5aa9337b28226518294c3300f58 (patch)
tree9c7d1a2f53b6fc49a6bc8b27b18cdd68e05ef2d2 /tools/libxl/libxl_device.c
parent4c73ff5d726429fc2de884957b3d67b291cee968 (diff)
downloadxen-4f6dda6a14abb5aa9337b28226518294c3300f58.tar.gz
xen-4f6dda6a14abb5aa9337b28226518294c3300f58.tar.bz2
xen-4f6dda6a14abb5aa9337b28226518294c3300f58.zip
libxl: fix cleanup of tap devices in libxl__device_destroy
We pass be_path to tapdisk_destroy but we've already deleted it so it fails to read tapdisk-params. However it appears that we need to destroy the tap device after tearing down xenstore, to avoid the leak reported by Greg Wettstein in <201207312141.q6VLfJje012656@wind.enjellic.com>. So read the tapdisk-params in the cleanup transaction, before the remove, and pass that down to destroy_tapdisk instead. tapdisk-params may of course be NULL if the device isn't a tap device. There is no need to tear down the tap device from libxl__initiate_device_remove since this ultimately calls libxl__device_destroy. Propagate and log errors from libxl__device_destroy_tapdisk. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.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.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 6d8e562e9e..8e8410e214 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -522,8 +522,10 @@ DEFINE_DEVICES_ADD(nic)
int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
{
- char *be_path = libxl__device_backend_path(gc, dev);
+ const char *be_path = libxl__device_backend_path(gc, dev);
const char *fe_path = libxl__device_frontend_path(gc, dev);
+ const char *tapdisk_path = GCSPRINTF("%s/%s", be_path, "tapdisk-params");
+ const char *tapdisk_params;
xs_transaction_t t = 0;
int rc;
@@ -531,6 +533,10 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
rc = libxl__xs_transaction_start(gc, &t);
if (rc) goto out;
+ /* May not exist if this is not a tap device */
+ rc = libxl__xs_read_checked(gc, t, tapdisk_path, &tapdisk_params);
+ if (rc) goto out;
+
libxl__xs_path_cleanup(gc, t, fe_path);
libxl__xs_path_cleanup(gc, t, be_path);
@@ -539,7 +545,8 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
if (rc < 0) goto out;
}
- libxl__device_destroy_tapdisk(gc, be_path);
+ if (tapdisk_params)
+ rc = libxl__device_destroy_tapdisk(gc, tapdisk_params);
out:
libxl__xs_transaction_abort(gc, &t);
@@ -790,8 +797,6 @@ void libxl__initiate_device_remove(libxl__egc *egc,
if (rc < 0) goto out;
}
- libxl__device_destroy_tapdisk(gc, be_path);
-
rc = libxl__ev_devstate_wait(gc, &aodev->backend_ds,
device_backend_callback,
state_path, XenbusStateClosed,