From patchwork Thu Jun 15 10:52:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 776224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wpLCh6Dd8z9s65 for ; Thu, 15 Jun 2017 21:01:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u0Kgb577"; dkim-atps=neutral Received: from localhost ([::1]:53160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLSWc-0006qS-Ia for incoming@patchwork.ozlabs.org; Thu, 15 Jun 2017 07:01:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLSP7-0008Gh-Ru for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLSP7-0007ab-4C for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:33 -0400 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:34368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLSP6-0007aN-Tm for qemu-devel@nongnu.org; Thu, 15 Jun 2017 06:53:33 -0400 Received: by mail-wr0-x242.google.com with SMTP id y25so546681wrd.1 for ; Thu, 15 Jun 2017 03:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QdF/zGOAzbyimkHue4lhRyt7GkPyYBGDArvoQeU+Lq4=; b=u0Kgb577ZBlalqyC5Ha+4KekL40bhUAewnj979OM/40zelne3xaHFPU9MgMvFuOeFE LTZdMJPEjuPn7dPbhjrHX3+8sjOF13NQGQ8Rh1k93fUbJJSYA/tHr0v+R2pkptH3VD3j vx+YS4+80CCk24syU+k5ZbOFhCE0dbLYR4e2BOAAYvXVq01UyUNXEFkTNU9/qUienATu s3DDHg+AlSc9LBVxwIAhNKyLeAPk9ciDL96il9oXmt/HHJ1hQJ8CZm9/9UoSjK/CACdL 0NlHijIp3CossC/6f4dUQ59KuDPuytjFWJmpQVA/FKiOUetGgX1+8Jar3pI7hav9yZBM Uyww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QdF/zGOAzbyimkHue4lhRyt7GkPyYBGDArvoQeU+Lq4=; b=iUTawlr5s7TaSHATS7n4i4ww/swiV0+zUg/RigO+xSzoWnxN0hDLW/sJuH47hc4QTE q6Dp1uVogiewFTlTl3HLidbMN0c+wiApeMyIQrRgYXl4dFXElzz1kw1EErpIrb0k+4Ot 5205Z9HTJQ8BoOWOlSyIdGJWQdmkkdSM2msz+jTvq+i1LT00BK7jFls6uPffjyg+bgDH 06hW0WWJwvlxSR1B1S13Dhrr1Y1a5/eZfXTE75WYERmBLh/31E0b0m2bCtHoRkt43n+3 bfVm9zOTglG3x8QKA7E7l9mTEdfMjKYg6+JDZ1VuvgnpiQUOExjr3VKujOPD5qNEJyBU pR4A== X-Gm-Message-State: AKS2vOzmUQdJlWxV37RILSHW6jZarYShD7hJaG9fGZKVryrt9lYWZ77I xJWN4CBHV0O8x68AT1k= X-Received: by 10.28.54.154 with SMTP id y26mr3145795wmh.53.1497524011653; Thu, 15 Jun 2017 03:53:31 -0700 (PDT) Received: from 640k.lan (94-39-191-51.adsl-ull.clienti.tiscali.it. [94.39.191.51]) by smtp.gmail.com with ESMTPSA id f21sm3258597wra.5.2017.06.15.03.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2017 03:53:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 15 Jun 2017 12:52:39 +0200 Message-Id: <1497523981-38449-20-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1497523981-38449-1-git-send-email-pbonzini@redhat.com> References: <1497523981-38449-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PULL 19/41] qemu-nbd: Ignore SIGPIPE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz qemu proper has done so for 13 years (8a7ddc38a60648257dc0645ab4a05b33d6040063), qemu-img and qemu-io have done so for four years (526eda14a68d5b3596be715505289b541288ef2a). Ignoring this signal is especially important in qemu-nbd because otherwise a client can easily take down the qemu-nbd server by dropping the connection when the server wants to send something, for example: $ qemu-nbd -x foo -f raw -t null-co:// & [1] 12726 $ qemu-io -c quit nbd://localhost/bar can't open device nbd://localhost/bar: No export with name 'bar' available [1] + 12726 broken pipe qemu-nbd -x foo -f raw -t null-co:// In this case, the client sends an NBD_OPT_ABORT and closes the connection (because it is not required to wait for a reply), but the server replies with an NBD_REP_ACK (because it is required to reply). Signed-off-by: Max Reitz Message-Id: <20170611123714.31292-1-mreitz@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-nbd.c b/qemu-nbd.c index 9464a04..4dd3fd4 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -581,6 +581,10 @@ int main(int argc, char **argv) sa_sigterm.sa_handler = termsig_handler; sigaction(SIGTERM, &sa_sigterm, NULL); +#ifdef CONFIG_POSIX + signal(SIGPIPE, SIG_IGN); +#endif + module_call_init(MODULE_INIT_TRACE); qcrypto_init(&error_fatal);