peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0104-qemu-nbd-Ignore-SIGPIPE.patch

335584
From: Max Reitz <mreitz@redhat.com>
335584
Date: Sun, 11 Jun 2017 14:37:14 +0200
335584
Subject: [PATCH] qemu-nbd: Ignore SIGPIPE
335584
335584
qemu proper has done so for 13 years
335584
(8a7ddc38a60648257dc0645ab4a05b33d6040063), qemu-img and qemu-io have
335584
done so for four years (526eda14a68d5b3596be715505289b541288ef2a).
335584
Ignoring this signal is especially important in qemu-nbd because
335584
otherwise a client can easily take down the qemu-nbd server by dropping
335584
the connection when the server wants to send something, for example:
335584
335584
$ qemu-nbd -x foo -f raw -t null-co:// &
335584
[1] 12726
335584
$ qemu-io -c quit nbd://localhost/bar
335584
can't open device nbd://localhost/bar: No export with name 'bar' available
335584
[1]  + 12726 broken pipe  qemu-nbd -x foo -f raw -t null-co://
335584
335584
In this case, the client sends an NBD_OPT_ABORT and closes the
335584
connection (because it is not required to wait for a reply), but the
335584
server replies with an NBD_REP_ACK (because it is required to reply).
335584
335584
Signed-off-by: Max Reitz <mreitz@redhat.com>
335584
Message-Id: <20170611123714.31292-1-mreitz@redhat.com>
335584
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
335584
(cherry picked from commit 041e32b8d9d076980b4e35317c0339e57ab888f1)
335584
---
335584
 qemu-nbd.c | 4 ++++
335584
 1 file changed, 4 insertions(+)
335584
335584
diff --git a/qemu-nbd.c b/qemu-nbd.c
335584
index 483dd77a77..5deb37e03e 100644
335584
--- a/qemu-nbd.c
335584
+++ b/qemu-nbd.c
335584
@@ -581,6 +581,10 @@ int main(int argc, char **argv)
335584
     sa_sigterm.sa_handler = termsig_handler;
335584
     sigaction(SIGTERM, &sa_sigterm, NULL);
335584
 
335584
+#ifdef CONFIG_POSIX
335584
+    signal(SIGPIPE, SIG_IGN);
335584
+#endif
335584
+
335584
     module_call_init(MODULE_INIT_TRACE);
335584
     qcrypto_init(&error_fatal);
335584