qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Anthony Perard <anthony.perard@citrix.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Anthony Perard <anthony.perard@citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	"qemu-stable@nongnu.org" <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] xen-bus: Fix backend state transition on device reset
Date: Tue, 27 Aug 2019 09:44:48 +0000	[thread overview]
Message-ID: <fae714e07fce4694b9555da6bc986663@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20190823101534.465-2-anthony.perard@citrix.com>

> -----Original Message-----
> From: Anthony PERARD <anthony.perard@citrix.com>
> Sent: 23 August 2019 11:16
> To: qemu-devel@nongnu.org
> Cc: Anthony Perard <anthony.perard@citrix.com>; qemu-stable@nongnu.org; Stefano Stabellini
> <sstabellini@kernel.org>; Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org
> Subject: [PATCH v2 1/2] xen-bus: Fix backend state transition on device reset
> 
> 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>

> ---
> Cc: qemu-stable@nongnu.org
> ---
> 
> Notes:
>     v2:
>     - use a helper
>     - Add InitWait and Initialised to the list of active state
> 
>  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



  reply	other threads:[~2019-08-27  9:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 10:15 [Qemu-devel] [PATCH v2 0/2] Fix for the xen-bus driver Anthony PERARD
2019-08-23 10:15 ` [Qemu-devel] [PATCH v2 1/2] xen-bus: Fix backend state transition on device reset Anthony PERARD
2019-08-27  9:44   ` Paul Durrant [this message]
2019-08-23 10:15 ` [Qemu-devel] [PATCH v2 2/2] xen-bus: Avoid rewriting identical values to xenstore Anthony PERARD
2019-08-27  9:46   ` Paul Durrant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fae714e07fce4694b9555da6bc986663@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).