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