libxl: attempt to cleanup tapdisk processes on disk backend destroy.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Ian Campbell committed 2011-09-28 16:42:11 +01:00
1 parent 6dac205d04
commit 2c76a4f11b
6 files changed
+51 -11

No files matched your search

+6 -6
View File
@@ -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, const char *path)
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;
}
+1 -1
View File
@@ -76,7 +76,7 @@ int tap_ctl_get_driver_id(const char *handle);
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);
+32 -4
View File
@@ -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 @@ char *libxl__blktap_devpath(libxl__gc *gc,
{
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 @@ char *libxl__blktap_devpath(libxl__gc *gc,
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);
}
+2
View File
@@ -376,6 +376,7 @@ int libxl__device_destroy(libxl__gc *gc, char *be_path, int force)
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;
}
@@ -398,6 +399,7 @@ retry_transaction:
} else {
xs_rm(ctx->xsh, XBT_NULL, be_path);
}
libxl__device_destroy_tapdisk(gc, be_path);
out:
return rc;
}
+6
View File
@@ -363,6 +363,12 @@ _hidden char *libxl__blktap_devpath(libxl__gc *gc,
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 {
+4
View File
@@ -27,3 +27,7 @@ char *libxl__blktap_devpath(libxl__gc *gc,
{
return NULL;
}
void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path)
{
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.