aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-08-27 15:52:36 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-08-27 15:52:36 +0100
commit23919ddfd56135cad3cb468a8f54d5a595f024f4 (patch)
treecd0383fd2ad62e8e46a39b17164989b83508e733
parentdac03af5d5482ec7ee9c23db467bb7230b33c0d9 (diff)
parent705be570941b38cd1cbebc68f7f671ce7532ecb0 (diff)
downloadqemu-arm-23919ddfd56135cad3cb468a8f54d5a595f024f4.tar.gz
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging
Xen queue * Fixes for xen-bus and exit cleanup. * Build fix. # gpg: Signature made Tue 27 Aug 2019 14:31:10 BST # gpg: using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF # gpg: issuer "anthony.perard@citrix.com" # gpg: Good signature from "Anthony PERARD <anthony.perard@gmail.com>" [marginal] # gpg: aka "Anthony PERARD <anthony.perard@citrix.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 5379 2F71 024C 600F 778A 7161 D8D5 7199 DF83 42C8 # Subkey fingerprint: F80C 0063 08E2 2CFD 8A92 E798 0CF5 572F D7FB 55AF * remotes/aperard/tags/pull-xen-20190827: xen-bus: Avoid rewriting identical values to xenstore xen-bus: Fix backend state transition on device reset xen: cleanup IOREQ server on exit xen: Fix ring.h header Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/i386/xen/xen-hvm.c2
-rw-r--r--hw/xen/xen-bus.c34
-rw-r--r--include/hw/xen/interface/io/ring.h13
3 files changed, 36 insertions, 13 deletions
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 5d3e4750e6..6b5e5bb7f5 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -1247,6 +1247,8 @@ static void xen_exit_notifier(Notifier *n, void *data)
{
XenIOState *state = container_of(n, XenIOState, exit);
+ xen_destroy_ioreq_server(xen_domid, state->ioservid);
+
xenevtchn_close(state->xce_handle);
xs_daemon_close(state->xenstore);
}
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index e40500242d..a04478ad4f 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -516,6 +516,23 @@ static void xen_device_backend_set_online(XenDevice *xendev, bool online)
xen_device_backend_printf(xendev, "online", "%u", online);
}
+/*
+ * Tell from the state whether the frontend is likely alive,
+ * i.e. it will react to a change of state of the backend.
+ */
+static bool xen_device_state_is_active(enum xenbus_state state)
+{
+ switch (state) {
+ case XenbusStateInitWait:
+ case XenbusStateInitialised:
+ case XenbusStateConnected:
+ case XenbusStateClosing:
+ return true;
+ default:
+ return false;
+ }
+}
+
static void xen_device_backend_changed(void *opaque)
{
XenDevice *xendev = opaque;
@@ -539,11 +556,11 @@ static void xen_device_backend_changed(void *opaque)
/*
* If the toolstack (or unplug request callback) has set the backend
- * state to Closing, but there is no active frontend (i.e. the
- * state is not Connected) then set the backend state to Closed.
+ * state to Closing, but there is no active frontend then set the
+ * backend state to Closed.
*/
if (xendev->backend_state == XenbusStateClosing &&
- xendev->frontend_state != XenbusStateConnected) {
+ !xen_device_state_is_active(state)) {
xen_device_backend_set_state(xendev, XenbusStateClosed);
}
@@ -681,7 +698,8 @@ int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
}
static void xen_device_frontend_set_state(XenDevice *xendev,
- enum xenbus_state state)
+ enum xenbus_state state,
+ bool publish)
{
const char *type = object_get_typename(OBJECT(xendev));
@@ -693,7 +711,9 @@ static void xen_device_frontend_set_state(XenDevice *xendev,
xs_strstate(state));
xendev->frontend_state = state;
- xen_device_frontend_printf(xendev, "state", "%u", state);
+ if (publish) {
+ xen_device_frontend_printf(xendev, "state", "%u", state);
+ }
}
static void xen_device_frontend_changed(void *opaque)
@@ -709,7 +729,7 @@ static void xen_device_frontend_changed(void *opaque)
state = XenbusStateUnknown;
}
- xen_device_frontend_set_state(xendev, state);
+ xen_device_frontend_set_state(xendev, state, false);
if (state == XenbusStateInitialising &&
xendev->backend_state == XenbusStateClosed &&
@@ -1152,7 +1172,7 @@ static void xen_device_realize(DeviceState *dev, Error **errp)
xen_device_frontend_printf(xendev, "backend-id", "%u",
xenbus->backend_id);
- xen_device_frontend_set_state(xendev, XenbusStateInitialising);
+ xen_device_frontend_set_state(xendev, XenbusStateInitialising, true);
xendev->exit.notify = xen_device_exit;
qemu_add_exit_notifier(&xendev->exit);
diff --git a/include/hw/xen/interface/io/ring.h b/include/hw/xen/interface/io/ring.h
index 1adacf09f9..5d048b335c 100644
--- a/include/hw/xen/interface/io/ring.h
+++ b/include/hw/xen/interface/io/ring.h
@@ -33,6 +33,13 @@
* - standard integers types (uint8_t, uint16_t, etc)
* They are provided by stdint.h of the standard headers.
*
+ * Before using the different macros, you need to provide the following
+ * macros:
+ * - xen_mb() a memory barrier
+ * - xen_rmb() a read memory barrier
+ * - xen_wmb() a write memory barrier
+ * Example of those can be found in xenctrl.h.
+ *
* In addition, if you intend to use the FLEX macros, you also need to
* provide the following, before invoking the FLEX macros:
* - size_t
@@ -42,12 +49,6 @@
* and grant_table.h from the Xen public headers.
*/
-#if __XEN_INTERFACE_VERSION__ < 0x00030208
-#define xen_mb() mb()
-#define xen_rmb() rmb()
-#define xen_wmb() wmb()
-#endif
-
typedef unsigned int RING_IDX;
/* Round a 32-bit unsigned constant down to the nearest power of two. */