diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-08-03 12:25:29 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-08-03 12:25:29 +0100 |
commit | 4f6dda6a14abb5aa9337b28226518294c3300f58 (patch) | |
tree | 9c7d1a2f53b6fc49a6bc8b27b18cdd68e05ef2d2 /tools/libxl/libxl_blktap2.c | |
parent | 4c73ff5d726429fc2de884957b3d67b291cee968 (diff) | |
download | xen-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_blktap2.c')
-rw-r--r-- | tools/libxl/libxl_blktap2.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/tools/libxl/libxl_blktap2.c b/tools/libxl/libxl_blktap2.c index 2c40182057..2053403a5b 100644 --- a/tools/libxl/libxl_blktap2.c +++ b/tools/libxl/libxl_blktap2.c @@ -51,28 +51,37 @@ char *libxl__blktap_devpath(libxl__gc *gc, } -void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) +int libxl__device_destroy_tapdisk(libxl__gc *gc, const char *params) { - char *path, *params, *type, *disk; + char *type, *disk; int err; tap_list_t tap; - path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); - if (!path) return; + type = libxl__strdup(gc, params); - params = libxl__xs_read(gc, XBT_NULL, path); - if (!params) return; - - type = params; - disk = strchr(params, ':'); - if (!disk) return; + disk = strchr(type, ':'); + if (!disk) { + LOG(ERROR, "Unable to parse params %s", params); + return ERROR_INVAL; + } *disk++ = '\0'; err = tap_ctl_find(type, disk, &tap); - if (err < 0) return; + if (err < 0) { + /* returns -errno */ + LOGEV(ERROR, -err, "Unable to find type %s disk %s", type, disk); + return ERROR_FAIL; + } + + err = tap_ctl_destroy(tap.id, tap.minor); + if (err < 0) { + LOGEV(ERROR, -err, "Failed to destroy tap device id %d minor %d", + tap.id, tap.minor); + return ERROR_FAIL; + } - tap_ctl_destroy(tap.id, tap.minor); + return 0; } /* |