qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for 2.6 1/1] nbd: fix assert() on qemu-nbd stop


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH for 2.6 1/1] nbd: fix assert() on qemu-nbd stop
Date: Thu, 14 Apr 2016 15:23:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1


On 14/04/2016 12:20, Denis V. Lunev wrote:
> From: Pavel Butsykin <address@hidden>
> 
> From time to time qemu-nbd is crashing on the following assert:
>     assert(state == TERMINATING);
>     nbd_export_closed
>     nbd_export_put
>     main
> and the state at the moment of the crash is evaluated to TERMINATE.
> 
> During shutdown process of the client the nbd_client_thread thread sends
> SIGTERM signal and the main thread calls the nbd_client_closed callback.
> If the SIGTERM callback will be executed after change the state to
> TERMINATING, then the state will once again be TERMINATE.
> 
> To solve the issue, we must change the state to TERMINATE only if the state
> is RUNNING. In the other case we are shutting down already.
> 
> Signed-off-by: Pavel Butsykin <address@hidden>
> Signed-off-by: Denis V. Lunev <address@hidden>
> CC: Paolo Bonzini <address@hidden>
> ---
>  qemu-nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index ca4a724..956013f 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -213,7 +213,7 @@ static int find_partition(BlockBackend *blk, int 
> partition,
>  
>  static void termsig_handler(int signum)
>  {
> -    state = TERMINATE;
> +    atomic_cmpxchg(&state, RUNNING, TERMINATE);

Just a simple "if" is enough (the rest of the file is not using any of
atomic{mb_,}{read,set}.

I'm not able to send further pull requests for 2.6, can the block
maintainers help?

Paolo

>      qemu_notify_event();
>  }
>  
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]