qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Coiby Xu <Coiby.Xu@gmail.com>, Max Reitz <mreitz@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 3/4] block: move block exports to libblockdev
Date: Tue, 29 Sep 2020 12:36:10 -0500	[thread overview]
Message-ID: <846a3c67-33eb-f694-d9ed-9c4318e10eab@redhat.com> (raw)
In-Reply-To: <20200929125516.186715-4-stefanha@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 2448 bytes --]

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.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2020-09-29 17:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 12:55 [PATCH v2 0/4] block/export: add BlockExportOptions->iothread member Stefan Hajnoczi
2020-09-29 12:55 ` [PATCH v2 1/4] util/vhost-user-server: use static library in meson.build Stefan Hajnoczi
2020-09-29 12:55 ` [PATCH v2 2/4] qemu-storage-daemon: avoid compiling blockdev_ss twice Stefan Hajnoczi
2020-09-29 12:55 ` [PATCH v2 3/4] block: move block exports to libblockdev Stefan Hajnoczi
2020-09-29 13:02   ` Paolo Bonzini
2020-09-29 13:03   ` Eric Blake
2020-09-29 17:36   ` Eric Blake [this message]
2020-09-30  8:51     ` Stefan Hajnoczi
2020-09-29 12:55 ` [PATCH v2 4/4] block/export: add iothread and fixed-iothread options Stefan Hajnoczi
2020-09-29 13:07   ` Eric Blake
2020-09-29 15:44     ` Stefan Hajnoczi
2020-10-09 10:17 ` [PATCH v2 0/4] block/export: add BlockExportOptions->iothread member Stefan Hajnoczi

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=846a3c67-33eb-f694-d9ed-9c4318e10eab@redhat.com \
    --to=eblake@redhat.com \
    --cc=Coiby.Xu@gmail.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /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).