From nobody Wed Nov 12 07:06:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1568716393; cv=none; d=zoho.com; s=zohoarc; b=V2RNnAf7Fj+pz3wJkFv9vrxpx0BPEIF+zqLA7cX2F/dQecAcOW2TcuE5f/7sLOO5S/cRS4dbjII3H6zt/ZCdUynisG5LPc72hYOpXIyVG1PdOAsT2WJjhpPv6AbjHSNSbfOkzRTK67MjGb7jVCjS0hUC8mZ/WSwZ8z/FFqnYDmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568716393; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dkTU84KelgOlqyKEJ6i0pdR0cU06evKbJoL4xu4Phgw=; b=Q9pPd47o1m1WbKfdcQx84Hfqrztqab/yN5UjlnDpSgBHOvJcL5ViwhaCI2HZ5hv3mwXkeucx57eQRJfdp12j9Km0jYg3BwyzF9YNNvJfEi+JarbGKbwC+tJJ0lfCfmpe+jKwBZZV/zDmVarZQnIbrRU7gEtsyv/TtQKuL0vDwfM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568716393239840.7765968159213; Tue, 17 Sep 2019 03:33:13 -0700 (PDT) Received: from localhost ([::1]:43770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAAnG-0008Ew-Nb for importer@patchew.org; Tue, 17 Sep 2019 06:33:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43967) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAAcf-0007lD-4K for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAAca-00046H-Hb for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:31458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAAca-00045Q-9J for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:08 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8HAHDas178933 for ; Tue, 17 Sep 2019 06:22:06 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v0uutuqf6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Sep 2019 06:22:05 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Sep 2019 11:22:02 +0100 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Sep 2019 11:21:55 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8HALSI233489272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Sep 2019 10:21:28 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C55FAE053; Tue, 17 Sep 2019 10:21:54 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54584AE04D; Tue, 17 Sep 2019 10:21:53 +0000 (GMT) Received: from bahia.lan (unknown [9.145.22.84]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Sep 2019 10:21:53 +0000 (GMT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 17 Sep 2019 12:21:53 +0200 In-Reply-To: <156871562997.196432.17776290406203122029.stgit@bahia.lan> References: <156871562997.196432.17776290406203122029.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19091710-0020-0000-0000-0000036E12C2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091710-0021-0000-0000-000021C3B66F Message-Id: <156871571297.196432.545961868971946073.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-09-17_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=781 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909170106 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 13/17] nbd: Pass local error object pointer to error_append_hint() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , "Michael S. Tsirkin" , Jeff Cody , Mark Cave-Ayland , Michael Roth , Gerd Hoffmann , Subbaraya Sundeep , Juan Quintela , David Hildenbrand , Markus Armbruster , Halil Pasic , Christian Borntraeger , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , David Gibson , Eric Farman , "Dr. David Alan Gilbert" , Yuval Shaia , Alex Williamson , "Daniel P. =?utf-8?q?Berrang=C3=A9=22?= , qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-s390x@nongnu.org"@d06av26.portsmouth.uk.ibm.com, John Snow , Richard Henderson , Kevin Wolf , Cornelia Huck , Max Reitz , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Ensure that hints are added even if errp is &error_fatal or &error_abort. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- nbd/client.c | 24 +++++++++++++----------- nbd/server.c | 7 +++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index b9dc829175f9..c6e6e4046fd5 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -154,6 +154,7 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDOpt= ionReply *reply, bool strict, Error **errp) { g_autofree char *msg =3D NULL; + Error *local_err =3D NULL; =20 if (!(reply->type & (1 << 31))) { return 1; @@ -161,14 +162,14 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDO= ptionReply *reply, =20 if (reply->length) { if (reply->length > NBD_MAX_BUFFER_SIZE) { - error_setg(errp, "server error %" PRIu32 + error_setg(&local_err, "server error %" PRIu32 " (%s) message is too long", reply->type, nbd_rep_lookup(reply->type)); goto err; } msg =3D g_malloc(reply->length + 1); if (nbd_read(ioc, msg, reply->length, NULL, errp) < 0) { - error_prepend(errp, "Failed to read option error %" PRIu32 + error_prepend(&local_err, "Failed to read option error %" PRIu= 32 " (%s) message: ", reply->type, nbd_rep_lookup(reply->type)); goto err; @@ -187,50 +188,51 @@ static int nbd_handle_reply_err(QIOChannel *ioc, NBDO= ptionReply *reply, =20 switch (reply->type) { case NBD_REP_ERR_POLICY: - error_setg(errp, "Denied by server for option %" PRIu32 " (%s)", + error_setg(&local_err, "Denied by server for option %" PRIu32 " (%= s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 case NBD_REP_ERR_INVALID: - error_setg(errp, "Invalid parameters for option %" PRIu32 " (%s)", + error_setg(&local_err, "Invalid parameters for option %" PRIu32 " = (%s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 case NBD_REP_ERR_PLATFORM: - error_setg(errp, "Server lacks support for option %" PRIu32 " (%s)= ", + error_setg(&local_err, "Server lacks support for option %" PRIu32 = " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 case NBD_REP_ERR_TLS_REQD: - error_setg(errp, "TLS negotiation required before option %" PRIu32 + error_setg(&local_err, "TLS negotiation required before option %" = PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 case NBD_REP_ERR_UNKNOWN: - error_setg(errp, "Requested export not available"); + error_setg(&local_err, "Requested export not available"); break; =20 case NBD_REP_ERR_SHUTDOWN: - error_setg(errp, "Server shutting down before option %" PRIu32 " (= %s)", + error_setg(&local_err, "Server shutting down before option %" PRIu= 32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 case NBD_REP_ERR_BLOCK_SIZE_REQD: - error_setg(errp, "Server requires INFO_BLOCK_SIZE for option %" PR= Iu32 + error_setg(&local_err, "Server requires INFO_BLOCK_SIZE for option= %" PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; =20 default: - error_setg(errp, "Unknown error code when asking for option %" PRI= u32 + error_setg(&local_err, "Unknown error code when asking for option = %" PRIu32 " (%s)", reply->option, nbd_opt_lookup(reply->option)); break; } =20 if (msg) { - error_append_hint(errp, "server reported: %s\n", msg); + error_append_hint(&local_err, "server reported: %s\n", msg); } =20 err: + error_propagate(errp, local_err); nbd_send_opt_abort(ioc); return -1; } diff --git a/nbd/server.c b/nbd/server.c index 28c3c8be854c..6d9ca2563cce 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1616,6 +1616,8 @@ void nbd_export_close(NBDExport *exp) =20 void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error **e= rrp) { + Error *local_err =3D NULL; + if (mode =3D=3D NBD_SERVER_REMOVE_MODE_HARD || QTAILQ_EMPTY(&exp->clie= nts)) { nbd_export_close(exp); return; @@ -1623,8 +1625,9 @@ void nbd_export_remove(NBDExport *exp, NbdServerRemov= eMode mode, Error **errp) =20 assert(mode =3D=3D NBD_SERVER_REMOVE_MODE_SAFE); =20 - error_setg(errp, "export '%s' still in use", exp->name); - error_append_hint(errp, "Use mode=3D'hard' to force client disconnect\= n"); + error_setg(&local_err, "export '%s' still in use", exp->name); + error_append_hint(&local_err, "Use mode=3D'hard' to force client disco= nnect\n"); + error_propagate(errp, local_err); } =20 void nbd_export_get(NBDExport *exp)