Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libxl blktap support #394

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tapback/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,15 @@ tapback_backend_create_device(backend_t *backend,
goto out;
}

/* After tapback has written it's capabilities to XenStore, switch to
* InitWait. */
err = xenbus_switch_state(device, XenbusStateInitWait);
if (unlikely(err)) {
WARN(device, "failed to switch to XenbusStateInitWait: %s\n",
strerror(-err));
goto out;
}

out:
if (err) {
WARN(NULL, "%s: error creating device: %s\n", name, strerror(-err));
Expand Down
38 changes: 9 additions & 29 deletions tapback/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,10 @@ frontend_changed(vbd_t * const device, const XenbusState state)

switch (state) {
case XenbusStateInitialising:
if (device->hotplug_status_connected)
err = xenbus_switch_state(device, XenbusStateInitWait);
if (device->state == XenbusStateClosed) {
DBG(device, "prepare for reconnect\n");
err = xenbus_switch_state(device, XenbusStateInitWait);
}
break;
case XenbusStateInitialised:
case XenbusStateConnected:
Expand Down Expand Up @@ -477,7 +479,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 @@ -508,41 +510,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