Skip to contentSkip to conversation

NBD patches through 2020-10-08

GIT PULL Applied Eric Blake 2 participants 3 messages Oct 9, 2020 – Oct 11, 2020

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

The following changes since commit 4a7c0bd9dcb08798c6f82e55b5a3423f7ee669f1:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.2-20201009' into staging (2020-10-09 15:48:04 +0100)

are available in the Git repository at:

https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-10-08-v3

for you to fetch changes up to ebd57062a1957307a175a810441af87259d7dbe9:

nbd: Simplify meta-context parsing (2020-10-09 15:05:08 -0500)

v2: fix BSD build
v3: fix mingw build (only the affected patch resent)

----------------------------------------------------------------
nbd patches for 2020-10-08

- silence compilation warnings
- more fixes to prevent reconnect hangs
- improve 'qemu-nbd' termination behavior
- cleaner NBD protocol compliance on string handling

----------------------------------------------------------------
Christian Borntraeger (1):
nbd: silence maybe-uninitialized warnings

Eric Blake (3):
qemu-nbd: Honor SIGINT and SIGHUP nbd/server: Reject embedded NUL in NBD strings
nbd: Simplify meta-context parsing

Vladimir Sementsov-Ogievskiy (4):
block/nbd: fix drain dead-lock because of nbd reconnect-delay block/nbd: correctly use qio_channel_detach_aio_context when needed block/nbd: fix reconnect-delay
block/nbd: nbd_co_reconnect_loop(): don't connect if drained

 block/nbd.c  |  71 ++++++++++++++++---
 nbd/server.c | 221 ++++++++++++++++++++++++-----------------------------------
 qemu-nbd.c   |  15 ++--
 3 files changed, 157 insertions(+), 150 deletions(-)
Signature · 1 line
2.28.0
author
#1 lore raw

[PULL v3 6/8] qemu-nbd: Honor SIGINT and SIGHUP

Honoring just SIGTERM on Linux is too weak; we also want to handle other common signals, and do so even on BSD. Why? Because at least 'qemu-nbd -B bitmap' needs a chance to clean up the in-use bit on bitmaps when the server is shut down via a signal.

See also: http://bugzilla.redhat.com/1883608

Message-Id: <[email protected]>

[eblake: apply comment tweak suggested by Vladimir; fix ifdef around termsig_handler]

---
 qemu-nbd.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
qemu-nbd.c +8 -7
index bacb69b0898b..bc644a0670b6 100644
@@ -154,13 +154,13 @@ QEMU_COPYRIGHT "\n"
     , name);
 }
 
-#if HAVE_NBD_DEVICE
+#ifdef CONFIG_POSIX
 static void termsig_handler(int signum)
 {
     qatomic_cmpxchg(&state, RUNNING, TERMINATE);
     qemu_notify_event();
 }
-#endif /* HAVE_NBD_DEVICE */
+#endif /* CONFIG_POSIX */
 
 static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls,
                                 const char *hostname)
@@ -581,17 +581,18 @@ int main(int argc, char **argv)
     const char *pid_file_name = NULL;
     BlockExportOptions *export_opts;
 
-#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.
+#ifdef CONFIG_POSIX
+    /*
+     * Exit gracefully on various signals, which includes SIGTERM used
+     * by 'qemu-nbd -v -c'.
      */
     struct sigaction sa_sigterm;
     memset(&sa_sigterm, 0, sizeof(sa_sigterm));
     sa_sigterm.sa_handler = termsig_handler;
     sigaction(SIGTERM, &sa_sigterm, NULL);
-#endif /* HAVE_NBD_DEVICE */
+    sigaction(SIGINT, &sa_sigterm, NULL);
+    sigaction(SIGHUP, &sa_sigterm, NULL);
 
-#ifdef CONFIG_POSIX
     signal(SIGPIPE, SIG_IGN);
 #endif
 
Signature · 1 line
2.28.0
#2 lore raw
In reply to Eric Blake
Quoted 16 lines · Eric Blake

The following changes since commit 4a7c0bd9dcb08798c6f82e55b5a3423f7ee669f1:

Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.2-20201009' into staging (2020-10-09 15:48:04 +0100)

are available in the Git repository at:

https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-10-08-v3

for you to fetch changes up to ebd57062a1957307a175a810441af87259d7dbe9:

nbd: Simplify meta-context parsing (2020-10-09 15:05:08 -0500)

v2: fix BSD build
v3: fix mingw build (only the affected patch resent)

Quoted 8 lines

----------------------------------------------------------------
nbd patches for 2020-10-08

- silence compilation warnings
- more fixes to prevent reconnect hangs
- improve 'qemu-nbd' termination behavior
- cleaner NBD protocol compliance on string handling

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM