[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/7] xen-bus: only set the xen device frontend state if it is miss
From: |
Anthony PERARD |
Subject: |
[PULL 7/7] xen-bus: only set the xen device frontend state if it is missing |
Date: |
Tue, 24 Sep 2019 12:30:26 +0100 |
From: Mark Syms <address@hidden>
Some toolstack implementations will set the frontend xenstore
keys to Initialising which will then trigger the in guest PV
drivers to begin initialising and some implementations will
then set their state to Closing. If this has occurred then
device realize must not overwrite the frontend keys as then
the handshake will stall.
Signed-off-by: Mark Syms <address@hidden>
Also avoid creating the frontend area if it already exists.
Signed-off-by: Paul Durrant <address@hidden>
Reviewed-by: Anthony PERARD <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Anthony PERARD <address@hidden>
---
hw/xen/xen-bus.c | 47 +++++++++++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index 55c157393d..c2ad22a42d 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -857,6 +857,13 @@ static void xen_device_frontend_changed(void *opaque)
}
}
+static bool xen_device_frontend_exists(XenDevice *xendev)
+{
+ enum xenbus_state state;
+
+ return (xen_device_frontend_scanf(xendev, "state", "%u", &state) == 1);
+}
+
static void xen_device_frontend_create(XenDevice *xendev, Error **errp)
{
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
@@ -865,19 +872,25 @@ static void xen_device_frontend_create(XenDevice *xendev,
Error **errp)
xendev->frontend_path = xen_device_get_frontend_path(xendev);
- perms[0].id = xendev->frontend_id;
- perms[0].perms = XS_PERM_NONE;
- perms[1].id = xenbus->backend_id;
- perms[1].perms = XS_PERM_READ | XS_PERM_WRITE;
+ /*
+ * The frontend area may have already been created by a legacy
+ * toolstack.
+ */
+ if (!xen_device_frontend_exists(xendev)) {
+ perms[0].id = xendev->frontend_id;
+ perms[0].perms = XS_PERM_NONE;
+ perms[1].id = xenbus->backend_id;
+ perms[1].perms = XS_PERM_READ | XS_PERM_WRITE;
- g_assert(xenbus->xsh);
+ g_assert(xenbus->xsh);
- xs_node_create(xenbus->xsh, XBT_NULL, xendev->frontend_path, perms,
- ARRAY_SIZE(perms), &local_err);
- if (local_err) {
- error_propagate_prepend(errp, local_err,
- "failed to create frontend: ");
- return;
+ xs_node_create(xenbus->xsh, XBT_NULL, xendev->frontend_path, perms,
+ ARRAY_SIZE(perms), &local_err);
+ if (local_err) {
+ error_propagate_prepend(errp, local_err,
+ "failed to create frontend: ");
+ return;
+ }
}
xendev->frontend_state_watch =
@@ -1290,12 +1303,14 @@ static void xen_device_realize(DeviceState *dev, Error
**errp)
xen_device_backend_set_online(xendev, true);
xen_device_backend_set_state(xendev, XenbusStateInitWait);
- xen_device_frontend_printf(xendev, "backend", "%s",
- xendev->backend_path);
- xen_device_frontend_printf(xendev, "backend-id", "%u",
- xenbus->backend_id);
+ if (!xen_device_frontend_exists(xendev)) {
+ xen_device_frontend_printf(xendev, "backend", "%s",
+ xendev->backend_path);
+ xen_device_frontend_printf(xendev, "backend-id", "%u",
+ xenbus->backend_id);
- xen_device_frontend_set_state(xendev, XenbusStateInitialising, true);
+ xen_device_frontend_set_state(xendev, XenbusStateInitialising, true);
+ }
xendev->exit.notify = xen_device_exit;
qemu_add_exit_notifier(&xendev->exit);
--
Anthony PERARD
- [PULL 0/7] xen queue 2019-09-24, Anthony PERARD, 2019/09/24
- [PULL 6/7] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed, Anthony PERARD, 2019/09/24
- [PULL 1/7] xen-bus: check whether the frontend is active during device reset..., Anthony PERARD, 2019/09/24
- [PULL 5/7] MAINTAINERS: update my email address, Anthony PERARD, 2019/09/24
- [PULL 2/7] xen / notify: introduce a new XenWatchList abstraction, Anthony PERARD, 2019/09/24
- [PULL 7/7] xen-bus: only set the xen device frontend state if it is missing,
Anthony PERARD <=
- [PULL 4/7] xen: perform XenDevice clean-up in XenBus watch handler, Anthony PERARD, 2019/09/24
- [PULL 3/7] xen: introduce separate XenWatchList for XenDevice objects, Anthony PERARD, 2019/09/24
- Re: [PULL 0/7] xen queue 2019-09-24, Peter Maydell, 2019/09/25