qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
@ 2019-09-18 11:57 Paul Durrant
  2019-09-20 21:10 ` [Qemu-block] " John Snow
  2019-09-23 11:34 ` Anthony PERARD
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Durrant @ 2019-09-18 11:57 UTC (permalink / raw)
  To: xen-devel, qemu-devel, qemu-block
  Cc: Kevin Wolf, Stefano Stabellini, Max Reitz, Paul Durrant,
	Anthony Perard, Mark Syms

When a frontend gracefully disconnects from an offline backend, it will
set its own state to XenbusStateClosed. The code in xen-block.c correctly
deals with this and sets the backend into XenbusStateClosed. Unfortunately
it is possible for toolstack to actually delete the frontend area
before the state key has been read, leading to an apparent frontend state
of XenbusStateUnknown. This prevents the backend state from transitioning
to XenbusStateClosed and hence leaves it limbo.

This patch simply treats a frontend state of XenbusStateUnknown the same
as XenbusStateClosed, which will unblock the backend in these circumstances.

Reported-by: Mark Syms <mark.syms@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
---
 hw/block/xen-block.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index f77343db60..879fc310a4 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -313,6 +313,7 @@ static void xen_block_frontend_changed(XenDevice *xendev,
         break;
 
     case XenbusStateClosed:
+    case XenbusStateUnknown:
         xen_block_disconnect(xendev, &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
-- 
2.20.1.2.gb21ebb671



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

* Re: [Qemu-block] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
  2019-09-18 11:57 [Qemu-devel] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed Paul Durrant
@ 2019-09-20 21:10 ` John Snow
  2019-09-23  9:38   ` Paul Durrant
  2019-09-23 11:34 ` Anthony PERARD
  1 sibling, 1 reply; 5+ messages in thread
From: John Snow @ 2019-09-20 21:10 UTC (permalink / raw)
  To: Paul Durrant, xen-devel, qemu-devel, qemu-block
  Cc: Kevin Wolf, Anthony Perard, Stefano Stabellini, Mark Syms, Max Reitz



On 9/18/19 7:57 AM, Paul Durrant wrote:
> When a frontend gracefully disconnects from an offline backend, it will
> set its own state to XenbusStateClosed. The code in xen-block.c correctly
> deals with this and sets the backend into XenbusStateClosed. Unfortunately
> it is possible for toolstack to actually delete the frontend area
> before the state key has been read, leading to an apparent frontend state
> of XenbusStateUnknown. This prevents the backend state from transitioning
> to XenbusStateClosed and hence leaves it limbo.
> 

Does the 0 come from a read into de-allocated memory?

--js

> This patch simply treats a frontend state of XenbusStateUnknown the same
> as XenbusStateClosed, which will unblock the backend in these circumstances.
> 
> Reported-by: Mark Syms <mark.syms@citrix.com>
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> ---
>  hw/block/xen-block.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
> index f77343db60..879fc310a4 100644
> --- a/hw/block/xen-block.c
> +++ b/hw/block/xen-block.c
> @@ -313,6 +313,7 @@ static void xen_block_frontend_changed(XenDevice *xendev,
>          break;
>  
>      case XenbusStateClosed:
> +    case XenbusStateUnknown:
>          xen_block_disconnect(xendev, &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
> 


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

* RE: [Qemu-block] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
  2019-09-20 21:10 ` [Qemu-block] " John Snow
@ 2019-09-23  9:38   ` Paul Durrant
  2019-09-23 17:08     ` John Snow
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Durrant @ 2019-09-23  9:38 UTC (permalink / raw)
  To: 'John Snow', xen-devel, qemu-devel, qemu-block
  Cc: Kevin Wolf, Anthony Perard, Stefano Stabellini, Mark Syms, Max Reitz

> -----Original Message-----
> From: John Snow <jsnow@redhat.com>
> Sent: 20 September 2019 22:11
> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org; qemu-devel@nongnu.org;
> qemu-block@nongnu.org
> Cc: Kevin Wolf <kwolf@redhat.com>; Stefano Stabellini <sstabellini@kernel.org>; Max Reitz
> <mreitz@redhat.com>; Anthony Perard <anthony.perard@citrix.com>; Mark Syms <Mark.Syms@citrix.com>
> Subject: Re: [Qemu-block] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
> 
> 
> 
> On 9/18/19 7:57 AM, Paul Durrant wrote:
> > When a frontend gracefully disconnects from an offline backend, it will
> > set its own state to XenbusStateClosed. The code in xen-block.c correctly
> > deals with this and sets the backend into XenbusStateClosed. Unfortunately
> > it is possible for toolstack to actually delete the frontend area
> > before the state key has been read, leading to an apparent frontend state
> > of XenbusStateUnknown. This prevents the backend state from transitioning
> > to XenbusStateClosed and hence leaves it limbo.
> >
> 
> Does the 0 come from a read into de-allocated memory?

No, it comes from the fact that the xenstore state key is not present. Conventionally a missing state key means the state is reported as XenbusStateUnknown.

  Paul

> 
> --js
> 
> > This patch simply treats a frontend state of XenbusStateUnknown the same
> > as XenbusStateClosed, which will unblock the backend in these circumstances.
> >
> > Reported-by: Mark Syms <mark.syms@citrix.com>
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > ---
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Cc: Max Reitz <mreitz@redhat.com>
> > ---
> >  hw/block/xen-block.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
> > index f77343db60..879fc310a4 100644
> > --- a/hw/block/xen-block.c
> > +++ b/hw/block/xen-block.c
> > @@ -313,6 +313,7 @@ static void xen_block_frontend_changed(XenDevice *xendev,
> >          break;
> >
> >      case XenbusStateClosed:
> > +    case XenbusStateUnknown:
> >          xen_block_disconnect(xendev, &local_err);
> >          if (local_err) {
> >              error_propagate(errp, local_err);
> >

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

* Re: [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
  2019-09-18 11:57 [Qemu-devel] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed Paul Durrant
  2019-09-20 21:10 ` [Qemu-block] " John Snow
@ 2019-09-23 11:34 ` Anthony PERARD
  1 sibling, 0 replies; 5+ messages in thread
From: Anthony PERARD @ 2019-09-23 11:34 UTC (permalink / raw)
  To: Paul Durrant
  Cc: Kevin Wolf, Stefano Stabellini, qemu-block, qemu-devel,
	Max Reitz, xen-devel, Mark Syms

On Wed, Sep 18, 2019 at 12:57:02PM +0100, Paul Durrant wrote:
> When a frontend gracefully disconnects from an offline backend, it will
> set its own state to XenbusStateClosed. The code in xen-block.c correctly
> deals with this and sets the backend into XenbusStateClosed. Unfortunately
> it is possible for toolstack to actually delete the frontend area
> before the state key has been read, leading to an apparent frontend state
> of XenbusStateUnknown. This prevents the backend state from transitioning
> to XenbusStateClosed and hence leaves it limbo.
> 
> This patch simply treats a frontend state of XenbusStateUnknown the same
> as XenbusStateClosed, which will unblock the backend in these circumstances.
> 
> Reported-by: Mark Syms <mark.syms@citrix.com>
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


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

* Re: [Qemu-block] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
  2019-09-23  9:38   ` Paul Durrant
@ 2019-09-23 17:08     ` John Snow
  0 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2019-09-23 17:08 UTC (permalink / raw)
  To: Paul Durrant, xen-devel, qemu-devel, qemu-block
  Cc: Kevin Wolf, Anthony Perard, Stefano Stabellini, Mark Syms, Max Reitz



On 9/23/19 5:38 AM, Paul Durrant wrote:
>> -----Original Message-----
>> From: John Snow <jsnow@redhat.com>
>> Sent: 20 September 2019 22:11
>> To: Paul Durrant <Paul.Durrant@citrix.com>; xen-devel@lists.xenproject.org; qemu-devel@nongnu.org;
>> qemu-block@nongnu.org
>> Cc: Kevin Wolf <kwolf@redhat.com>; Stefano Stabellini <sstabellini@kernel.org>; Max Reitz
>> <mreitz@redhat.com>; Anthony Perard <anthony.perard@citrix.com>; Mark Syms <Mark.Syms@citrix.com>
>> Subject: Re: [Qemu-block] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
>>
>>
>>
>> On 9/18/19 7:57 AM, Paul Durrant wrote:
>>> When a frontend gracefully disconnects from an offline backend, it will
>>> set its own state to XenbusStateClosed. The code in xen-block.c correctly
>>> deals with this and sets the backend into XenbusStateClosed. Unfortunately
>>> it is possible for toolstack to actually delete the frontend area
>>> before the state key has been read, leading to an apparent frontend state
>>> of XenbusStateUnknown. This prevents the backend state from transitioning
>>> to XenbusStateClosed and hence leaves it limbo.
>>>
>>
>> Does the 0 come from a read into de-allocated memory?
> 
> No, it comes from the fact that the xenstore state key is not present. Conventionally a missing state key means the state is reported as XenbusStateUnknown.
> 
>   Paul
> 

Good enough for me, just had to confirm.

Reviewed-by: John Snow <jsnow@redhat.com>


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

end of thread, other threads:[~2019-09-23 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 11:57 [Qemu-devel] [PATCH] xen-block: treat XenbusStateUnknown the same as XenbusStateClosed Paul Durrant
2019-09-20 21:10 ` [Qemu-block] " John Snow
2019-09-23  9:38   ` Paul Durrant
2019-09-23 17:08     ` John Snow
2019-09-23 11:34 ` Anthony PERARD

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).