Skip to content

Commit

Permalink
tapback: Don't remove xenstore backend
Browse files Browse the repository at this point in the history
libxl doesn't clean up tapdisks because it doesn't call the hotplug
cleanup scripts:
libxl: debug: libxl_event.c:1043:devstate_callback: backend /local/domain/0/backend/vbd3/5/2048/state wanted state 6 but it was removed
libxl: debug: libxl_event.c:849:libxl__ev_xswatch_deregister: watch w=0xf82ba0 wpath=/local/domain/0/backend/vbd3/5/2048/state token=1/2: deregister slotnum=1
libxl: debug: libxl_device.c:1156:device_backend_callback: Domain 5:calling device_backend_cleanup
libxl: debug: libxl_event.c:863:libxl__ev_xswatch_deregister: watch w=0xf82ba0: deregister unregistered
libxl: error: libxl_device.c:1169:device_backend_callback: Domain 5:unable to remove device with path /local/domain/0/backend/vbd3/5/2048 - rc -6

The backend state cannot be found because tapback deleted the entire
backend subtree.

tapback shouldn't remove the backend nodes when the frontend is removed,
because the nodes contain the information on how to clean up.  Leave the
nodes and allowed them to be removed by the toolstack.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
  • Loading branch information
jandryuk committed Apr 28, 2023
1 parent e443937 commit 680512a
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions tapback/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ tapback_backend_handle_otherend_watch(backend_t *backend,
{
vbd_t *device = NULL;
int err = 0, state = 0;
char *s = NULL, *end = NULL, *_path = NULL;
char *s = NULL, *end = NULL;

ASSERT(backend);
ASSERT(path);
Expand Down Expand Up @@ -504,41 +504,19 @@ tapback_backend_handle_otherend_watch(backend_t *backend,
*/
s = tapback_xs_read(device->backend->xs, XBT_NULL, "%s",
device->frontend_state_path);
if (!s) {
err = errno;
/*
* If the front-end XenBus node is missing, the XenBus device has been
* removed: remove the XenBus back-end node.
*/
if (err == ENOENT) {
err = asprintf(&_path, "%s/%s/%d/%d", XENSTORE_BACKEND,
device->backend->name, device->domid, device->devid);
if (err == -1) {
err = errno;
WARN(device, "failed to asprintf: %s\n", strerror(err));
goto out;
}
err = 0;
if (!xs_rm(device->backend->xs, XBT_NULL, _path)) {
if (errno != ENOENT) {
err = errno;
WARN(device, "failed to remove %s: %s\n", path,
strerror(err));
}
}
}
} else {
if (s) {
state = strtol(s, &end, 0);
if (*end != 0 || end == s) {
WARN(device, "invalid XenBus state '%s'\n", s);
err = EINVAL;
} else
err = frontend_changed(device, state);
} else {
WARN(device, "frontend disappeared!");
err = ENOENT;
}

out:
free(s);
free(_path);
return err;
}

Expand Down

0 comments on commit 680512a

Please sign in to comment.