qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH v2 3/4] block: move block exports to libblockdev


From: Stefan Hajnoczi
Subject: Re: [PATCH v2 3/4] block: move block exports to libblockdev
Date: Wed, 30 Sep 2020 09:51:08 +0100

On Tue, Sep 29, 2020 at 12:36:10PM -0500, Eric Blake wrote:
> On 9/29/20 7:55 AM, Stefan Hajnoczi wrote:
> > Block exports are used by softmmu, qemu-storage-daemon, and qemu-nbd.
> > They are not used by other programs and are not otherwise needed in
> > libblock.
> > 
> > Undo the recent move of blockdev-nbd.c from blockdev_ss into block_ss.
> > Since bdrv_close_all() (libblock) calls blk_exp_close_all()
> > (libblockdev) a stub function is required..
> > 
> > Make qemu-ndb.c use signal handling utility functions instead of
> > duplicating the code. This helps because os-posix.c is in libblockdev
> > and it depends on a qemu_system_killed() symbol that qemu-nbd.c lacks.
> > Once we use the signal handling utility functions we also end up
> > providing the necessary symbol.
> 
> Hmm. I just stumbled on a long-standing bug in qemu-nbd - it installs a
> SIGTERM handler, but not a SIGINT or SIGHUP handler.  This matters in
> the following sequence:
> 
> qemu-nbd -f qcow2 -B bitmap image   # Ctrl-C
> qemu-nbd -f qcow2 -B bitmap image
> 
> because the first instance dies with SIGINT but there is no handler
> installed, qemu-nbd does not release the bitmap from being marked
> in-use, and the second instance then fails with:
> 
> qemu-nbd: Bitmap 'b0' is inconsistent and cannot be used
> 
> And to my surprise, while I was trying to find the root cause to fixing
> the bug I just found, I noticed that your patch happens to fix that...
> 
> > +++ b/qemu-nbd.c
> 
> > @@ -581,20 +586,12 @@ int main(int argc, char **argv)
> >      const char *pid_file_name = NULL;
> >      BlockExportOptions *export_opts;
> >  
> > +    os_setup_early_signal_handling();
> > +
> >  #if HAVE_NBD_DEVICE
> > -    /* The client thread uses SIGTERM to interrupt the server.  A signal
> > -     * handler ensures that "qemu-nbd -v -c" exits with a nice status code.
> > -     */
> > -    struct sigaction sa_sigterm;
> > -    memset(&sa_sigterm, 0, sizeof(sa_sigterm));
> > -    sa_sigterm.sa_handler = termsig_handler;
> > -    sigaction(SIGTERM, &sa_sigterm, NULL);
> > +    os_setup_signal_handling();
> 
> ...by installing a SIGINT handler.
> 
> Is HAVE_NBD_DEVICE really the best gate for this code, or is it really
> whether we are compiling for mingw?  At any rate, you may want to add a
> link to https://bugzilla.redhat.com/show_bug.cgi?id=1883608 in the
> commit message, and/or separate the bug fix out into a separate commit.

Thanks for letting me know about the bug report. The link can be
added to the commit description when merging (or if I resend).

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

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