Xen queue

* Fixes for xen-bus and exit cleanup.
 * Build fix.
 -----BEGIN PGP SIGNATURE-----
 
 iQFOBAABCgA4FiEE+AwAYwjiLP2KkueYDPVXL9f7Va8FAl1lMJ4aHGFudGhvbnku
 cGVyYXJkQGNpdHJpeC5jb20ACgkQDPVXL9f7Va/DyQf/UVkAt9qtJ88ch9agTLX9
 g3s57fevMM0AuiRv8yC96aJTv32Eexxd7CU9CmmKTi43HfX1+XO9+F3rjz0FBuKF
 YbMRL6KfmSKzxXpyBo3Mj0lrUZopjycopPoHntf6wI7CF/ab0wvy0Za8X+oS4F/s
 hOk0o9b0grJXu5y3WNVJYklsASaZ220DvCCVtwWYWkEDSVm5Qezo7t+BUIKcCviZ
 l9W9BTnCrNi0XzwDi0SRHiQ+rgeor1ViIRiureEHdgn4fcxsl0fGXrjFOgZQVWp7
 E2LXGeAWp2NW3GSIO5vRylrGC7pAkLAKxCNPC7fC+DH8echU+DuGMcu6MZ0g3qVY
 oQ==
 =gOSb
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Peter Maydell 2019-08-27 15:52:36 +01:00
commit 23919ddfd5
3 changed files with 36 additions and 13 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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. */