qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] xen queue 2019-08-27
@ 2019-08-27 13:32 Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 1/4] xen: Fix ring.h header Anthony PERARD
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Anthony PERARD @ 2019-08-27 13:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD, xen-devel, Peter Maydell

The following changes since commit dac03af5d5482ec7ee9c23db467bb7230b33c0d9:

  Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20190825' into staging (2019-08-27 10:00:51 +0100)

are available in the Git repository at:

  https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20190827

for you to fetch changes up to 705be570941b38cd1cbebc68f7f671ce7532ecb0:

  xen-bus: Avoid rewriting identical values to xenstore (2019-08-27 14:18:28 +0100)

----------------------------------------------------------------
Xen queue

* Fixes for xen-bus and exit cleanup.
* Build fix.

----------------------------------------------------------------
Anthony PERARD (3):
      xen: Fix ring.h header
      xen-bus: Fix backend state transition on device reset
      xen-bus: Avoid rewriting identical values to xenstore

Igor Druzhinin (1):
      xen: cleanup IOREQ server on exit

 hw/i386/xen/xen-hvm.c              |  2 ++
 hw/xen/xen-bus.c                   | 34 +++++++++++++++++++++++++++-------
 include/hw/xen/interface/io/ring.h | 13 +++++++------
 3 files changed, 36 insertions(+), 13 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/4] xen: Fix ring.h header
  2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
@ 2019-08-27 13:32 ` Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 2/4] xen: cleanup IOREQ server on exit Anthony PERARD
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony PERARD @ 2019-08-27 13:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD, xen-devel, Peter Maydell

The xen_[rw]?mb() macros defined in ring.h can't be used and the fact
that there are gated behind __XEN_INTERFACE_VERSION__ means that it
needs to be defined somewhere. QEMU doesn't implement interfaces with
the Xen hypervisor so defining __XEN_INTERFACE_VERSION__ is pointless.
This leads to:
    include/hw/xen/io/ring.h:47:5: error: "__XEN_INTERFACE_VERSION__"
        is not defined, evaluates to 0 [-Werror=undef]

Cleanup ring.h. The xen_*mb() macros are already defined in xenctrl.h
which is included in xen_common.h.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190704153605.4140-1-anthony.perard@citrix.com>
[aperard: Adding the comment proposed upstream]
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 include/hw/xen/interface/io/ring.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

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. */
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/4] xen: cleanup IOREQ server on exit
  2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 1/4] xen: Fix ring.h header Anthony PERARD
@ 2019-08-27 13:32 ` Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 3/4] xen-bus: Fix backend state transition on device reset Anthony PERARD
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony PERARD @ 2019-08-27 13:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD, xen-devel, Peter Maydell

From: Igor Druzhinin <igor.druzhinin@citrix.com>

Device model is supposed to destroy IOREQ server for itself.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Acked-by: Paul Durrant <paul.durrant@citrix.com>
Message-Id: <1564428563-1006-1-git-send-email-igor.druzhinin@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 hw/i386/xen/xen-hvm.c | 2 ++
 1 file changed, 2 insertions(+)

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);
 }
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 3/4] xen-bus: Fix backend state transition on device reset
  2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 1/4] xen: Fix ring.h header Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 2/4] xen: cleanup IOREQ server on exit Anthony PERARD
@ 2019-08-27 13:32 ` Anthony PERARD
  2019-08-27 13:32 ` [Qemu-devel] [PULL 4/4] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD
  2019-08-27 16:14 ` [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony PERARD @ 2019-08-27 13:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD, xen-devel, Peter Maydell

When a frontend wants to reset its state and the backend one, it
starts with setting "Closing", then waits for the backend (QEMU) to do
the same.

But when QEMU is setting "Closing" to its state, it triggers an event
(xenstore watch) that re-execute xen_device_backend_changed() and set
the backend state to "Closed". QEMU should wait for the frontend to
set "Closed" before doing the same.

Before setting "Closed" to the backend_state, we are also going to
check if there is a frontend. If that the case, when the backend state
is set to "Closing" the frontend should react and sets its state to
"Closing" then "Closed". The backend should wait for that to happen.

Fixes: b6af8926fb858c4f1426e5acb2cfc1f0580ec98a
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Message-Id: <20190823101534.465-2-anthony.perard@citrix.com>
---
 hw/xen/xen-bus.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index e40500242d..62c127b926 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);
     }
 
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 4/4] xen-bus: Avoid rewriting identical values to xenstore
  2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
                   ` (2 preceding siblings ...)
  2019-08-27 13:32 ` [Qemu-devel] [PULL 3/4] xen-bus: Fix backend state transition on device reset Anthony PERARD
@ 2019-08-27 13:32 ` Anthony PERARD
  2019-08-27 16:14 ` [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Anthony PERARD @ 2019-08-27 13:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony PERARD, xen-devel, Peter Maydell

When QEMU receives a xenstore watch event suggesting that the "state"
of the frontend changed, it records this in its own state but it also
re-write the value back into xenstore even so there were no change.
This triggers an unnecessary xenstore watch event which QEMU will
process again (and maybe the frontend as well). Also QEMU could
potentially write an already old value.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Message-Id: <20190823101534.465-3-anthony.perard@citrix.com>
---
 hw/xen/xen-bus.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index 62c127b926..a04478ad4f 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -698,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));
 
@@ -710,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)
@@ -726,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 &&
@@ -1169,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);
-- 
Anthony PERARD



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] xen queue 2019-08-27
  2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
                   ` (3 preceding siblings ...)
  2019-08-27 13:32 ` [Qemu-devel] [PULL 4/4] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD
@ 2019-08-27 16:14 ` Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2019-08-27 16:14 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: open list:X86, QEMU Developers

On Tue, 27 Aug 2019 at 14:33, Anthony PERARD <anthony.perard@citrix.com> wrote:
>
> The following changes since commit dac03af5d5482ec7ee9c23db467bb7230b33c0d9:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20190825' into staging (2019-08-27 10:00:51 +0100)
>
> are available in the Git repository at:
>
>   https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20190827
>
> for you to fetch changes up to 705be570941b38cd1cbebc68f7f671ce7532ecb0:
>
>   xen-bus: Avoid rewriting identical values to xenstore (2019-08-27 14:18:28 +0100)
>
> ----------------------------------------------------------------
> Xen queue
>
> * Fixes for xen-bus and exit cleanup.
> * Build fix.
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-27 16:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 13:32 [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Anthony PERARD
2019-08-27 13:32 ` [Qemu-devel] [PULL 1/4] xen: Fix ring.h header Anthony PERARD
2019-08-27 13:32 ` [Qemu-devel] [PULL 2/4] xen: cleanup IOREQ server on exit Anthony PERARD
2019-08-27 13:32 ` [Qemu-devel] [PULL 3/4] xen-bus: Fix backend state transition on device reset Anthony PERARD
2019-08-27 13:32 ` [Qemu-devel] [PULL 4/4] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD
2019-08-27 16:14 ` [Qemu-devel] [PULL 0/4] xen queue 2019-08-27 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).