diff options
author | Greg Wettstein <greg@enjellic.com> | 2012-12-13 14:35:58 +0000 |
---|---|---|
committer | Greg Wettstein <greg@enjellic.com> | 2012-12-13 14:35:58 +0000 |
commit | 303b534f0ed7f80627d59f8eb8b916b3174e1a12 (patch) | |
tree | f815c7786d3059486756b73ec068e015a055a03f | |
parent | 8cc9dbccf0720398a83bd5239f20c1695fac895f (diff) | |
download | xen-303b534f0ed7f80627d59f8eb8b916b3174e1a12.tar.gz xen-303b534f0ed7f80627d59f8eb8b916b3174e1a12.tar.bz2 xen-303b534f0ed7f80627d59f8eb8b916b3174e1a12.zip |
libxl: avoid blktap2 deadlock on cleanup
Establishes correct cleanup behavior for blktap devices. This patch
implements the release of the backend device before calling for
the destruction of the userspace component of the blktap device.
Without this patch the kernel xen-blkback driver deadlocks with
the blktap2 user control plane until the IPC channel is terminated by the
timeout on the select() call. This results in a noticeable delay
in the termination of the guest and causes the blktap minor
number which had been allocated to be orphaned.
Signed-off-by: Greg Wettstein <greg@enjellic.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r-- | tools/libxl/libxl_blktap2.c | 7 | ||||
-rw-r--r-- | tools/libxl/libxl_device.c | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/tools/libxl/libxl_blktap2.c b/tools/libxl/libxl_blktap2.c index 00d8dbbee4..b126f8d6fa 100644 --- a/tools/libxl/libxl_blktap2.c +++ b/tools/libxl/libxl_blktap2.c @@ -59,6 +59,7 @@ void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) char *path, *params, *type, *disk; int err; tap_list_t tap; + libxl_ctx *ctx = libxl__gc_owner(gc); path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); if (!path) return; @@ -75,5 +76,11 @@ void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) err = tap_ctl_find(type, disk, &tap); if (err < 0) return; + /* + * Remove the instance of the backend device to avoid a deadlock with the + * removal of the tap device. + */ + xs_rm(ctx->xsh, XBT_NULL, be_path); + tap_ctl_destroy(tap.id, tap.minor); } diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 7e8fcef20d..8a92efa3ba 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -251,7 +251,6 @@ int libxl__device_destroy(libxl_ctx *ctx, char *be_path, int force) goto out; if (atoi(state) != 4) { libxl__device_destroy_tapdisk(&gc, be_path); - xs_rm(ctx->xsh, XBT_NULL, be_path); goto out; } |