--------------------------------------------------------------------------- Backport of the following patch from development: # User Ian Campbell <[hidden email]> # Date 1309968705 -3600 # Node ID e4781aedf817c5ab36f6f3077e44c43c566a2812 # Parent 700d0f03d50aa6619d313c1ff6aea7fd429d28a7 libxl: attempt to cleanup tapdisk processes on disk backend destroy. This patch properly terminates the tapdisk2 process(es) started to service a virtual block device. Signed-off-by: Greg Wettstein <greg@enjellic.com> diff -r 700d0f03d50a tools/blktap2/control/tap-ctl-list.c --- a/tools/blktap2/control/tap-ctl-list.c Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/blktap2/control/tap-ctl-list.c Tue Nov 06 19:52:48 2012 -0600 @@ -506,17 +506,15 @@ out: } int -tap_ctl_find_minor(const char *type, const char *path) +tap_ctl_find(const char *type, const char *path, tap_list_t *tap) { tap_list_t **list, **_entry; - int minor, err; + int ret = -ENOENT, err; err = tap_ctl_list(&list); if (err) return err; - minor = -1; - for (_entry = list; *_entry != NULL; ++_entry) { tap_list_t *entry = *_entry; @@ -526,11 +524,13 @@ tap_ctl_find_minor(const char *type, con if (path && (!entry->path || strcmp(entry->path, path))) continue; - minor = entry->minor; + *tap = *entry; + tap->type = tap->path = NULL; + ret = 0; break; } tap_ctl_free_list(list); - return minor >= 0 ? minor : -ENOENT; + return ret; } diff -r 700d0f03d50a tools/blktap2/control/tap-ctl.h --- a/tools/blktap2/control/tap-ctl.h Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/blktap2/control/tap-ctl.h Tue Nov 06 19:52:48 2012 -0600 @@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *ha int tap_ctl_list(tap_list_t ***list); void tap_ctl_free_list(tap_list_t **list); -int tap_ctl_find_minor(const char *type, const char *path); +int tap_ctl_find(const char *type, const char *path, tap_list_t *tap); int tap_ctl_allocate(int *minor, char **devname); int tap_ctl_free(const int minor); diff -r 700d0f03d50a tools/libxl/libxl_blktap2.c --- a/tools/libxl/libxl_blktap2.c Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/libxl/libxl_blktap2.c Tue Nov 06 19:52:48 2012 -0600 @@ -18,6 +18,8 @@ #include "tap-ctl.h" +#include <string.h> + int libxl__blktap_enabled(libxl__gc *gc) { const char *msg; @@ -30,12 +32,13 @@ const char *libxl__blktap_devpath(libxl_ { const char *type; char *params, *devname = NULL; - int minor, err; + tap_list_t tap; + int err; type = libxl__device_disk_string_of_format(format); - minor = tap_ctl_find_minor(type, disk); - if (minor >= 0) { - devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor); + err = tap_ctl_find(type, disk, &tap); + if (err == 0) { + devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor); if (devname) return devname; } @@ -49,3 +52,28 @@ const char *libxl__blktap_devpath(libxl_ return NULL; } + + +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) +{ + char *path, *params, *type, *disk; + int err; + tap_list_t tap; + + path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); + if (!path) return; + + params = libxl__xs_read(gc, XBT_NULL, path); + if (!params) return; + + type = params; + disk = strchr(params, '':''); + if (!disk) return; + + *disk++ = ''\0''; + + err = tap_ctl_find(type, disk, &tap); + if (err < 0) return; + + tap_ctl_destroy(tap.id, tap.minor); +} diff -r 700d0f03d50a tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/libxl/libxl_device.c Tue Nov 06 19:52:48 2012 -0600 @@ -250,6 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx if (!state) goto out; if (atoi(state) != 4) { + libxl__device_destroy_tapdisk(&gc, be_path); xs_rm(ctx->xsh, XBT_NULL, be_path); goto out; } @@ -368,6 +369,7 @@ int libxl__devices_destroy(libxl_ctx *ct } } } + libxl__device_destroy_tapdisk(&gc, be_path); out: libxl__free_all(&gc); return 0; diff -r 700d0f03d50a tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/libxl/libxl_internal.h Tue Nov 06 19:52:48 2012 -0600 @@ -314,6 +314,12 @@ _hidden const char *libxl__blktap_devpat const char *disk, libxl_disk_format format); +/* libxl__device_destroy_tapdisk: + * Destroys any tapdisk process associated with the backend represented + * by be_path. + */ +_hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); + _hidden char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid); struct libxl__xen_console_reader { diff -r 700d0f03d50a tools/libxl/libxl_noblktap2.c --- a/tools/libxl/libxl_noblktap2.c Mon Oct 29 09:04:48 2012 +0100 +++ b/tools/libxl/libxl_noblktap2.c Tue Nov 06 19:52:48 2012 -0600 @@ -27,3 +27,7 @@ const char *libxl__blktap_devpath(libxl_ { return NULL; } + +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) +{ +} --------------------------------------------------------------------------- As always, Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. 4206 N. 19th Ave. Specializing in information infra-structure Fargo, ND 58102 development. PH: 701-281-1686 FAX: 701-281-3949 EMAIL: greg@enjellic.com ------------------------------------------------------------------------------ "Man, despite his artistic pretensions, his sophistication and many accomplishments, owes the fact of his existence to a six-inch layer of topsoil and the fact that it rains." -- Anonymous writer on perspective. GAUSSIAN quote.
On Wed, 2012-11-07 at 02:06 +0000, Dr. Greg Wettstein wrote:> --------------------------------------------------------------------------- > Backport of the following patch from development: > > # User Ian Campbell <[hidden email]> > # Date 1309968705 -3600 > # Node ID e4781aedf817c5ab36f6f3077e44c43c566a2812 > # Parent 700d0f03d50aa6619d313c1ff6aea7fd429d28a7 > libxl: attempt to cleanup tapdisk processes on disk backend destroy. > > This patch properly terminates the tapdisk2 process(es) started > to service a virtual block device. > > Signed-off-by: Greg Wettstein <greg@enjellic.com>Signed-off-by: Ian Campbell <ian.campbell@citrix.com>> > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl-list.c > --- a/tools/blktap2/control/tap-ctl-list.c Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/blktap2/control/tap-ctl-list.c Tue Nov 06 19:52:48 2012 -0600 > @@ -506,17 +506,15 @@ out: > } > > int > -tap_ctl_find_minor(const char *type, const char *path) > +tap_ctl_find(const char *type, const char *path, tap_list_t *tap) > { > tap_list_t **list, **_entry; > - int minor, err; > + int ret = -ENOENT, err; > > err = tap_ctl_list(&list); > if (err) > return err; > > - minor = -1; > - > for (_entry = list; *_entry != NULL; ++_entry) { > tap_list_t *entry = *_entry; > > @@ -526,11 +524,13 @@ tap_ctl_find_minor(const char *type, con > if (path && (!entry->path || strcmp(entry->path, path))) > continue; > > - minor = entry->minor; > + *tap = *entry; > + tap->type = tap->path = NULL; > + ret = 0; > break; > } > > tap_ctl_free_list(list); > > - return minor >= 0 ? minor : -ENOENT; > + return ret; > } > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl.h > --- a/tools/blktap2/control/tap-ctl.h Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/blktap2/control/tap-ctl.h Tue Nov 06 19:52:48 2012 -0600 > @@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *ha > > int tap_ctl_list(tap_list_t ***list); > void tap_ctl_free_list(tap_list_t **list); > -int tap_ctl_find_minor(const char *type, const char *path); > +int tap_ctl_find(const char *type, const char *path, tap_list_t *tap); > > int tap_ctl_allocate(int *minor, char **devname); > int tap_ctl_free(const int minor); > diff -r 700d0f03d50a tools/libxl/libxl_blktap2.c > --- a/tools/libxl/libxl_blktap2.c Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/libxl/libxl_blktap2.c Tue Nov 06 19:52:48 2012 -0600 > @@ -18,6 +18,8 @@ > > #include "tap-ctl.h" > > +#include <string.h> > + > int libxl__blktap_enabled(libxl__gc *gc) > { > const char *msg; > @@ -30,12 +32,13 @@ const char *libxl__blktap_devpath(libxl_ > { > const char *type; > char *params, *devname = NULL; > - int minor, err; > + tap_list_t tap; > + int err; > > type = libxl__device_disk_string_of_format(format); > - minor = tap_ctl_find_minor(type, disk); > - if (minor >= 0) { > - devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor); > + err = tap_ctl_find(type, disk, &tap); > + if (err == 0) { > + devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor); > if (devname) > return devname; > } > @@ -49,3 +52,28 @@ const char *libxl__blktap_devpath(libxl_ > > return NULL; > } > + > + > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > +{ > + char *path, *params, *type, *disk; > + int err; > + tap_list_t tap; > + > + path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); > + if (!path) return; > + > + params = libxl__xs_read(gc, XBT_NULL, path); > + if (!params) return; > + > + type = params; > + disk = strchr(params, '':''); > + if (!disk) return; > + > + *disk++ = ''\0''; > + > + err = tap_ctl_find(type, disk, &tap); > + if (err < 0) return; > + > + tap_ctl_destroy(tap.id, tap.minor); > +} > diff -r 700d0f03d50a tools/libxl/libxl_device.c > --- a/tools/libxl/libxl_device.c Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/libxl/libxl_device.c Tue Nov 06 19:52:48 2012 -0600 > @@ -250,6 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx > if (!state) > goto out; > if (atoi(state) != 4) { > + libxl__device_destroy_tapdisk(&gc, be_path); > xs_rm(ctx->xsh, XBT_NULL, be_path); > goto out; > } > @@ -368,6 +369,7 @@ int libxl__devices_destroy(libxl_ctx *ct > } > } > } > + libxl__device_destroy_tapdisk(&gc, be_path); > out: > libxl__free_all(&gc); > return 0; > diff -r 700d0f03d50a tools/libxl/libxl_internal.h > --- a/tools/libxl/libxl_internal.h Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/libxl/libxl_internal.h Tue Nov 06 19:52:48 2012 -0600 > @@ -314,6 +314,12 @@ _hidden const char *libxl__blktap_devpat > const char *disk, > libxl_disk_format format); > > +/* libxl__device_destroy_tapdisk: > + * Destroys any tapdisk process associated with the backend represented > + * by be_path. > + */ > +_hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); > + > _hidden char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid); > > struct libxl__xen_console_reader { > diff -r 700d0f03d50a tools/libxl/libxl_noblktap2.c > --- a/tools/libxl/libxl_noblktap2.c Mon Oct 29 09:04:48 2012 +0100 > +++ b/tools/libxl/libxl_noblktap2.c Tue Nov 06 19:52:48 2012 -0600 > @@ -27,3 +27,7 @@ const char *libxl__blktap_devpath(libxl_ > { > return NULL; > } > + > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > +{ > +} > --------------------------------------------------------------------------- > > As always, > Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. > 4206 N. 19th Ave. Specializing in information infra-structure > Fargo, ND 58102 development. > PH: 701-281-1686 > FAX: 701-281-3949 EMAIL: greg@enjellic.com > ------------------------------------------------------------------------------ > "Man, despite his artistic pretensions, his sophistication and many > accomplishments, owes the fact of his existence to a six-inch layer of > topsoil and the fact that it rains." > -- Anonymous writer on perspective. > GAUSSIAN quote. > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Hello, IanJ: Just a reminder to commit these two patches to xen-4.1-testing.. It''d be good to have them for Xen 4.1.4. Thanks, -- Pasi On Wed, Nov 07, 2012 at 08:22:28AM +0100, Ian Campbell wrote:> On Wed, 2012-11-07 at 02:06 +0000, Dr. Greg Wettstein wrote: > > --------------------------------------------------------------------------- > > Backport of the following patch from development: > > > > # User Ian Campbell <[hidden email]> > > # Date 1309968705 -3600 > > # Node ID e4781aedf817c5ab36f6f3077e44c43c566a2812 > > # Parent 700d0f03d50aa6619d313c1ff6aea7fd429d28a7 > > libxl: attempt to cleanup tapdisk processes on disk backend destroy. > > > > This patch properly terminates the tapdisk2 process(es) started > > to service a virtual block device. > > > > Signed-off-by: Greg Wettstein <greg@enjellic.com> > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > > > > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl-list.c > > --- a/tools/blktap2/control/tap-ctl-list.c Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/blktap2/control/tap-ctl-list.c Tue Nov 06 19:52:48 2012 -0600 > > @@ -506,17 +506,15 @@ out: > > } > > > > int > > -tap_ctl_find_minor(const char *type, const char *path) > > +tap_ctl_find(const char *type, const char *path, tap_list_t *tap) > > { > > tap_list_t **list, **_entry; > > - int minor, err; > > + int ret = -ENOENT, err; > > > > err = tap_ctl_list(&list); > > if (err) > > return err; > > > > - minor = -1; > > - > > for (_entry = list; *_entry != NULL; ++_entry) { > > tap_list_t *entry = *_entry; > > > > @@ -526,11 +524,13 @@ tap_ctl_find_minor(const char *type, con > > if (path && (!entry->path || strcmp(entry->path, path))) > > continue; > > > > - minor = entry->minor; > > + *tap = *entry; > > + tap->type = tap->path = NULL; > > + ret = 0; > > break; > > } > > > > tap_ctl_free_list(list); > > > > - return minor >= 0 ? minor : -ENOENT; > > + return ret; > > } > > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl.h > > --- a/tools/blktap2/control/tap-ctl.h Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/blktap2/control/tap-ctl.h Tue Nov 06 19:52:48 2012 -0600 > > @@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *ha > > > > int tap_ctl_list(tap_list_t ***list); > > void tap_ctl_free_list(tap_list_t **list); > > -int tap_ctl_find_minor(const char *type, const char *path); > > +int tap_ctl_find(const char *type, const char *path, tap_list_t *tap); > > > > int tap_ctl_allocate(int *minor, char **devname); > > int tap_ctl_free(const int minor); > > diff -r 700d0f03d50a tools/libxl/libxl_blktap2.c > > --- a/tools/libxl/libxl_blktap2.c Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/libxl/libxl_blktap2.c Tue Nov 06 19:52:48 2012 -0600 > > @@ -18,6 +18,8 @@ > > > > #include "tap-ctl.h" > > > > +#include <string.h> > > + > > int libxl__blktap_enabled(libxl__gc *gc) > > { > > const char *msg; > > @@ -30,12 +32,13 @@ const char *libxl__blktap_devpath(libxl_ > > { > > const char *type; > > char *params, *devname = NULL; > > - int minor, err; > > + tap_list_t tap; > > + int err; > > > > type = libxl__device_disk_string_of_format(format); > > - minor = tap_ctl_find_minor(type, disk); > > - if (minor >= 0) { > > - devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor); > > + err = tap_ctl_find(type, disk, &tap); > > + if (err == 0) { > > + devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor); > > if (devname) > > return devname; > > } > > @@ -49,3 +52,28 @@ const char *libxl__blktap_devpath(libxl_ > > > > return NULL; > > } > > + > > + > > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > > +{ > > + char *path, *params, *type, *disk; > > + int err; > > + tap_list_t tap; > > + > > + path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); > > + if (!path) return; > > + > > + params = libxl__xs_read(gc, XBT_NULL, path); > > + if (!params) return; > > + > > + type = params; > > + disk = strchr(params, '':''); > > + if (!disk) return; > > + > > + *disk++ = ''\0''; > > + > > + err = tap_ctl_find(type, disk, &tap); > > + if (err < 0) return; > > + > > + tap_ctl_destroy(tap.id, tap.minor); > > +} > > diff -r 700d0f03d50a tools/libxl/libxl_device.c > > --- a/tools/libxl/libxl_device.c Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/libxl/libxl_device.c Tue Nov 06 19:52:48 2012 -0600 > > @@ -250,6 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx > > if (!state) > > goto out; > > if (atoi(state) != 4) { > > + libxl__device_destroy_tapdisk(&gc, be_path); > > xs_rm(ctx->xsh, XBT_NULL, be_path); > > goto out; > > } > > @@ -368,6 +369,7 @@ int libxl__devices_destroy(libxl_ctx *ct > > } > > } > > } > > + libxl__device_destroy_tapdisk(&gc, be_path); > > out: > > libxl__free_all(&gc); > > return 0; > > diff -r 700d0f03d50a tools/libxl/libxl_internal.h > > --- a/tools/libxl/libxl_internal.h Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/libxl/libxl_internal.h Tue Nov 06 19:52:48 2012 -0600 > > @@ -314,6 +314,12 @@ _hidden const char *libxl__blktap_devpat > > const char *disk, > > libxl_disk_format format); > > > > +/* libxl__device_destroy_tapdisk: > > + * Destroys any tapdisk process associated with the backend represented > > + * by be_path. > > + */ > > +_hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); > > + > > _hidden char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid); > > > > struct libxl__xen_console_reader { > > diff -r 700d0f03d50a tools/libxl/libxl_noblktap2.c > > --- a/tools/libxl/libxl_noblktap2.c Mon Oct 29 09:04:48 2012 +0100 > > +++ b/tools/libxl/libxl_noblktap2.c Tue Nov 06 19:52:48 2012 -0600 > > @@ -27,3 +27,7 @@ const char *libxl__blktap_devpath(libxl_ > > { > > return NULL; > > } > > + > > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > > +{ > > +} > > --------------------------------------------------------------------------- > > > > As always, > > Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. > > 4206 N. 19th Ave. Specializing in information infra-structure > > Fargo, ND 58102 development. > > PH: 701-281-1686 > > FAX: 701-281-3949 EMAIL: greg@enjellic.com > > ------------------------------------------------------------------------------ > > "Man, despite his artistic pretensions, his sophistication and many > > accomplishments, owes the fact of his existence to a six-inch layer of > > topsoil and the fact that it rains." > > -- Anonymous writer on perspective. > > GAUSSIAN quote. > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xen.org > > http://lists.xen.org/xen-devel > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
On Sat, Dec 01, 2012 at 04:03:36PM +0200, Pasi Kärkkäinen wrote:> Hello, > > IanJ: Just a reminder to commit these two patches to xen-4.1-testing.. > > It''d be good to have them for Xen 4.1.4. >ping? -- Pasi> > On Wed, Nov 07, 2012 at 08:22:28AM +0100, Ian Campbell wrote: > > On Wed, 2012-11-07 at 02:06 +0000, Dr. Greg Wettstein wrote: > > > --------------------------------------------------------------------------- > > > Backport of the following patch from development: > > > > > > # User Ian Campbell <[hidden email]> > > > # Date 1309968705 -3600 > > > # Node ID e4781aedf817c5ab36f6f3077e44c43c566a2812 > > > # Parent 700d0f03d50aa6619d313c1ff6aea7fd429d28a7 > > > libxl: attempt to cleanup tapdisk processes on disk backend destroy. > > > > > > This patch properly terminates the tapdisk2 process(es) started > > > to service a virtual block device. > > > > > > Signed-off-by: Greg Wettstein <greg@enjellic.com> > > > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > > > > > > > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl-list.c > > > --- a/tools/blktap2/control/tap-ctl-list.c Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/blktap2/control/tap-ctl-list.c Tue Nov 06 19:52:48 2012 -0600 > > > @@ -506,17 +506,15 @@ out: > > > } > > > > > > int > > > -tap_ctl_find_minor(const char *type, const char *path) > > > +tap_ctl_find(const char *type, const char *path, tap_list_t *tap) > > > { > > > tap_list_t **list, **_entry; > > > - int minor, err; > > > + int ret = -ENOENT, err; > > > > > > err = tap_ctl_list(&list); > > > if (err) > > > return err; > > > > > > - minor = -1; > > > - > > > for (_entry = list; *_entry != NULL; ++_entry) { > > > tap_list_t *entry = *_entry; > > > > > > @@ -526,11 +524,13 @@ tap_ctl_find_minor(const char *type, con > > > if (path && (!entry->path || strcmp(entry->path, path))) > > > continue; > > > > > > - minor = entry->minor; > > > + *tap = *entry; > > > + tap->type = tap->path = NULL; > > > + ret = 0; > > > break; > > > } > > > > > > tap_ctl_free_list(list); > > > > > > - return minor >= 0 ? minor : -ENOENT; > > > + return ret; > > > } > > > diff -r 700d0f03d50a tools/blktap2/control/tap-ctl.h > > > --- a/tools/blktap2/control/tap-ctl.h Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/blktap2/control/tap-ctl.h Tue Nov 06 19:52:48 2012 -0600 > > > @@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *ha > > > > > > int tap_ctl_list(tap_list_t ***list); > > > void tap_ctl_free_list(tap_list_t **list); > > > -int tap_ctl_find_minor(const char *type, const char *path); > > > +int tap_ctl_find(const char *type, const char *path, tap_list_t *tap); > > > > > > int tap_ctl_allocate(int *minor, char **devname); > > > int tap_ctl_free(const int minor); > > > diff -r 700d0f03d50a tools/libxl/libxl_blktap2.c > > > --- a/tools/libxl/libxl_blktap2.c Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/libxl/libxl_blktap2.c Tue Nov 06 19:52:48 2012 -0600 > > > @@ -18,6 +18,8 @@ > > > > > > #include "tap-ctl.h" > > > > > > +#include <string.h> > > > + > > > int libxl__blktap_enabled(libxl__gc *gc) > > > { > > > const char *msg; > > > @@ -30,12 +32,13 @@ const char *libxl__blktap_devpath(libxl_ > > > { > > > const char *type; > > > char *params, *devname = NULL; > > > - int minor, err; > > > + tap_list_t tap; > > > + int err; > > > > > > type = libxl__device_disk_string_of_format(format); > > > - minor = tap_ctl_find_minor(type, disk); > > > - if (minor >= 0) { > > > - devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor); > > > + err = tap_ctl_find(type, disk, &tap); > > > + if (err == 0) { > > > + devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor); > > > if (devname) > > > return devname; > > > } > > > @@ -49,3 +52,28 @@ const char *libxl__blktap_devpath(libxl_ > > > > > > return NULL; > > > } > > > + > > > + > > > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > > > +{ > > > + char *path, *params, *type, *disk; > > > + int err; > > > + tap_list_t tap; > > > + > > > + path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); > > > + if (!path) return; > > > + > > > + params = libxl__xs_read(gc, XBT_NULL, path); > > > + if (!params) return; > > > + > > > + type = params; > > > + disk = strchr(params, '':''); > > > + if (!disk) return; > > > + > > > + *disk++ = ''\0''; > > > + > > > + err = tap_ctl_find(type, disk, &tap); > > > + if (err < 0) return; > > > + > > > + tap_ctl_destroy(tap.id, tap.minor); > > > +} > > > diff -r 700d0f03d50a tools/libxl/libxl_device.c > > > --- a/tools/libxl/libxl_device.c Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/libxl/libxl_device.c Tue Nov 06 19:52:48 2012 -0600 > > > @@ -250,6 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx > > > if (!state) > > > goto out; > > > if (atoi(state) != 4) { > > > + libxl__device_destroy_tapdisk(&gc, be_path); > > > xs_rm(ctx->xsh, XBT_NULL, be_path); > > > goto out; > > > } > > > @@ -368,6 +369,7 @@ int libxl__devices_destroy(libxl_ctx *ct > > > } > > > } > > > } > > > + libxl__device_destroy_tapdisk(&gc, be_path); > > > out: > > > libxl__free_all(&gc); > > > return 0; > > > diff -r 700d0f03d50a tools/libxl/libxl_internal.h > > > --- a/tools/libxl/libxl_internal.h Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/libxl/libxl_internal.h Tue Nov 06 19:52:48 2012 -0600 > > > @@ -314,6 +314,12 @@ _hidden const char *libxl__blktap_devpat > > > const char *disk, > > > libxl_disk_format format); > > > > > > +/* libxl__device_destroy_tapdisk: > > > + * Destroys any tapdisk process associated with the backend represented > > > + * by be_path. > > > + */ > > > +_hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); > > > + > > > _hidden char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid); > > > > > > struct libxl__xen_console_reader { > > > diff -r 700d0f03d50a tools/libxl/libxl_noblktap2.c > > > --- a/tools/libxl/libxl_noblktap2.c Mon Oct 29 09:04:48 2012 +0100 > > > +++ b/tools/libxl/libxl_noblktap2.c Tue Nov 06 19:52:48 2012 -0600 > > > @@ -27,3 +27,7 @@ const char *libxl__blktap_devpath(libxl_ > > > { > > > return NULL; > > > } > > > + > > > +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) > > > +{ > > > +} > > > --------------------------------------------------------------------------- > > > > > > As always, > > > Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. > > > 4206 N. 19th Ave. Specializing in information infra-structure > > > Fargo, ND 58102 development. > > > PH: 701-281-1686 > > > FAX: 701-281-3949 EMAIL: greg@enjellic.com > > > ------------------------------------------------------------------------------ > > > "Man, despite his artistic pretensions, his sophistication and many > > > accomplishments, owes the fact of his existence to a six-inch layer of > > > topsoil and the fact that it rains." > > > -- Anonymous writer on perspective. > > > GAUSSIAN quote. > > > > > > _______________________________________________ > > > Xen-devel mailing list > > > Xen-devel@lists.xen.org > > > http://lists.xen.org/xen-devel > > > > > > > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xen.org > > http://lists.xen.org/xen-devel > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
Dr. Greg Wettstein writes ("[PATCH 1/2] 4.1.2 blktap2 cleanup fixes."):> --------------------------------------------------------------------------- > Backport of the following patch from development: > > # User Ian Campbell <[hidden email]> > # Date 1309968705 -3600 > # Node ID e4781aedf817c5ab36f6f3077e44c43c566a2812 > # Parent 700d0f03d50aa6619d313c1ff6aea7fd429d28a7 > libxl: attempt to cleanup tapdisk processes on disk backend destroy. > > This patch properly terminates the tapdisk2 process(es) started > to service a virtual block device. > > Signed-off-by: Greg Wettstein <greg@enjellic.com>Thanks, I have applied this to 4.1. Ian. # HG changeset patch # User Ian Jackson <Ian.Jackson@eu.citrix.com> # Date 1355334075 0 # Node ID 255a0b6a81041e51fe38ef0e919a6541ffe0d119 # Parent a866cc5b8235ae05b178b9a904a59569b005f177 From: Ian Campbell <ian.campbell@citrix.com> libxl: attempt to cleanup tapdisk processes on disk backend destroy. This patch properly terminates the tapdisk2 process(es) started to service a virtual block device. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> xen-unstable changeset: 23883:7998217630e2 xen-unstable date: Wed Sep 28 16:42:11 2011 +0100 Signed-off-by: Greg Wettstein <greg@enjellic.com> Backport-requested-by: Greg Wettstein <greg@enjellic.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com> diff -r a866cc5b8235 -r 255a0b6a8104 tools/blktap2/control/tap-ctl-list.c --- a/tools/blktap2/control/tap-ctl-list.c Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/blktap2/control/tap-ctl-list.c Wed Dec 12 17:41:15 2012 +0000 @@ -506,17 +506,15 @@ out: } int -tap_ctl_find_minor(const char *type, const char *path) +tap_ctl_find(const char *type, const char *path, tap_list_t *tap) { tap_list_t **list, **_entry; - int minor, err; + int ret = -ENOENT, err; err = tap_ctl_list(&list); if (err) return err; - minor = -1; - for (_entry = list; *_entry != NULL; ++_entry) { tap_list_t *entry = *_entry; @@ -526,11 +524,13 @@ tap_ctl_find_minor(const char *type, con if (path && (!entry->path || strcmp(entry->path, path))) continue; - minor = entry->minor; + *tap = *entry; + tap->type = tap->path = NULL; + ret = 0; break; } tap_ctl_free_list(list); - return minor >= 0 ? minor : -ENOENT; + return ret; } diff -r a866cc5b8235 -r 255a0b6a8104 tools/blktap2/control/tap-ctl.h --- a/tools/blktap2/control/tap-ctl.h Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/blktap2/control/tap-ctl.h Wed Dec 12 17:41:15 2012 +0000 @@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *ha int tap_ctl_list(tap_list_t ***list); void tap_ctl_free_list(tap_list_t **list); -int tap_ctl_find_minor(const char *type, const char *path); +int tap_ctl_find(const char *type, const char *path, tap_list_t *tap); int tap_ctl_allocate(int *minor, char **devname); int tap_ctl_free(const int minor); diff -r a866cc5b8235 -r 255a0b6a8104 tools/libxl/libxl_blktap2.c --- a/tools/libxl/libxl_blktap2.c Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/libxl/libxl_blktap2.c Wed Dec 12 17:41:15 2012 +0000 @@ -18,6 +18,8 @@ #include "tap-ctl.h" +#include <string.h> + int libxl__blktap_enabled(libxl__gc *gc) { const char *msg; @@ -30,12 +32,13 @@ const char *libxl__blktap_devpath(libxl_ { const char *type; char *params, *devname = NULL; - int minor, err; + tap_list_t tap; + int err; type = libxl__device_disk_string_of_format(format); - minor = tap_ctl_find_minor(type, disk); - if (minor >= 0) { - devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", minor); + err = tap_ctl_find(type, disk, &tap); + if (err == 0) { + devname = libxl__sprintf(gc, "/dev/xen/blktap-2/tapdev%d", tap.minor); if (devname) return devname; } @@ -49,3 +52,28 @@ const char *libxl__blktap_devpath(libxl_ return NULL; } + + +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) +{ + char *path, *params, *type, *disk; + int err; + tap_list_t tap; + + path = libxl__sprintf(gc, "%s/tapdisk-params", be_path); + if (!path) return; + + params = libxl__xs_read(gc, XBT_NULL, path); + if (!params) return; + + type = params; + disk = strchr(params, '':''); + if (!disk) return; + + *disk++ = ''\0''; + + err = tap_ctl_find(type, disk, &tap); + if (err < 0) return; + + tap_ctl_destroy(tap.id, tap.minor); +} diff -r a866cc5b8235 -r 255a0b6a8104 tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/libxl/libxl_device.c Wed Dec 12 17:41:15 2012 +0000 @@ -250,6 +250,7 @@ int libxl__device_destroy(libxl_ctx *ctx if (!state) goto out; if (atoi(state) != 4) { + libxl__device_destroy_tapdisk(&gc, be_path); xs_rm(ctx->xsh, XBT_NULL, be_path); goto out; } @@ -368,6 +369,7 @@ int libxl__devices_destroy(libxl_ctx *ct } } } + libxl__device_destroy_tapdisk(&gc, be_path); out: libxl__free_all(&gc); return 0; diff -r a866cc5b8235 -r 255a0b6a8104 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/libxl/libxl_internal.h Wed Dec 12 17:41:15 2012 +0000 @@ -314,6 +314,12 @@ _hidden const char *libxl__blktap_devpat const char *disk, libxl_disk_format format); +/* libxl__device_destroy_tapdisk: + * Destroys any tapdisk process associated with the backend represented + * by be_path. + */ +_hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); + _hidden char *libxl__uuid2string(libxl__gc *gc, const libxl_uuid uuid); struct libxl__xen_console_reader { diff -r a866cc5b8235 -r 255a0b6a8104 tools/libxl/libxl_noblktap2.c --- a/tools/libxl/libxl_noblktap2.c Wed Dec 12 09:40:16 2012 +0000 +++ b/tools/libxl/libxl_noblktap2.c Wed Dec 12 17:41:15 2012 +0000 @@ -27,3 +27,7 @@ const char *libxl__blktap_devpath(libxl_ { return NULL; } + +void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path) +{ +}
Possibly Parallel Threads
- [PATCH] libxl: attempt to cleanup tapdisk processes on disk backend destroy
- [PATCH 2/2] 4.1.2 blktap2 cleanup fixes.
- [PATCH] xl: Make blktap support optional
- libxl device_disk_add orphans blktap devices on transaction error
- Can't block-attach a file on a read only volume?