From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765133689433.86926967891384; Wed, 17 Oct 2018 01:32:13 -0700 (PDT) Received: from localhost ([::1]:34523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChFU-0003fY-CT for importer@patchew.org; Wed, 17 Oct 2018 04:32:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-000855-Ip for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAY-0000za-61 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAX-0000wr-Qt for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0FF525C20; Wed, 17 Oct 2018 08:27:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8689C18763; Wed, 17 Oct 2018 08:27:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 196481132F35; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:25 +0200 Message-Id: <20181017082702.5581-2-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Oct 2018 08:27:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 01/38] error: Fix use of error_prepend() with &error_fatal, &error_abort 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: Fei Li Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From include/qapi/error.h: * Pass an existing error to the caller with the message modified: * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); Fei Li pointed out that doing error_propagate() first doesn't work well when @errp is &error_fatal or &error_abort: the error_prepend() is never reached. Since I doubt fixing the documentation will stop people from getting it wrong, introduce error_propagate_prepend(), in the hope that it lures people away from using its constituents in the wrong order. Update the instructions in error.h accordingly. Convert existing error_prepend() next to error_propagate to error_propagate_prepend(). If any of these get reached with &error_fatal or &error_abort, the error messages improve. I didn't check whether that's the case anywhere. Cc: Fei Li Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Blake --- block.c | 6 +++--- block/qcow2.c | 4 ++-- block/qed.c | 4 ++-- hw/9pfs/9p-local.c | 4 ++-- hw/intc/xics.c | 15 +++++++++------ hw/ppc/pnv_core.c | 4 ++-- hw/ppc/spapr_pci.c | 7 +++---- hw/timer/aspeed_timer.c | 3 +-- hw/usb/bus.c | 5 +++-- hw/vfio/pci.c | 3 +-- include/qapi/error.h | 14 ++++++++++++++ migration/migration.c | 12 ++++++------ util/error.c | 13 +++++++++++++ 13 files changed, 61 insertions(+), 33 deletions(-) diff --git a/block.c b/block.c index 7710b399a3..5d51419d21 100644 --- a/block.c +++ b/block.c @@ -4697,9 +4697,9 @@ bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOp= Type op, Error **errp) assert((int) op >=3D 0 && op < BLOCK_OP_TYPE_MAX); if (!QLIST_EMPTY(&bs->op_blockers[op])) { blocker =3D QLIST_FIRST(&bs->op_blockers[op]); - error_propagate(errp, error_copy(blocker->reason)); - error_prepend(errp, "Node '%s' is busy: ", - bdrv_get_device_or_node_name(bs)); + error_propagate_prepend(errp, error_copy(blocker->reason), + "Node '%s' is busy: ", + bdrv_get_device_or_node_name(bs)); return true; } return false; diff --git a/block/qcow2.c b/block/qcow2.c index 7277feda13..4f8d2fa7bd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2208,8 +2208,8 @@ static void coroutine_fn qcow2_co_invalidate_cache(Bl= ockDriverState *bs, qemu_co_mutex_unlock(&s->lock); qobject_unref(options); if (local_err) { - error_propagate(errp, local_err); - error_prepend(errp, "Could not reopen qcow2 layer: "); + error_propagate_prepend(errp, local_err, + "Could not reopen qcow2 layer: "); bs->drv =3D NULL; return; } else if (ret < 0) { diff --git a/block/qed.c b/block/qed.c index 689ea9d4d5..9377c0b7ad 100644 --- a/block/qed.c +++ b/block/qed.c @@ -1606,8 +1606,8 @@ static void coroutine_fn bdrv_qed_co_invalidate_cache= (BlockDriverState *bs, ret =3D bdrv_qed_do_open(bs, NULL, bs->open_flags, &local_err); qemu_co_mutex_unlock(&s->table_lock); if (local_err) { - error_propagate(errp, local_err); - error_prepend(errp, "Could not reopen qed layer: "); + error_propagate_prepend(errp, local_err, + "Could not reopen qed layer: "); return; } else if (ret < 0) { error_setg_errno(errp, -ret, "Could not reopen qed layer"); diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index c30f4f26bd..08e673a79c 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1509,8 +1509,8 @@ static int local_parse_opts(QemuOpts *opts, FsDriverE= ntry *fse, Error **errp) =20 fsdev_throttle_parse_opts(opts, &fse->fst, &local_err); if (local_err) { - error_propagate(errp, local_err); - error_prepend(errp, "invalid throttle configuration: "); + error_propagate_prepend(errp, local_err, + "invalid throttle configuration: "); return -1; } =20 diff --git a/hw/intc/xics.c b/hw/intc/xics.c index c90c893228..406efee064 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -320,8 +320,9 @@ static void icp_realize(DeviceState *dev, Error **errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err); if (!obj) { - error_propagate(errp, err); - error_prepend(errp, "required link '" ICP_PROP_XICS "' not found: = "); + error_propagate_prepend(errp, err, + "required link '" ICP_PROP_XICS + "' not found: "); return; } =20 @@ -329,8 +330,9 @@ static void icp_realize(DeviceState *dev, Error **errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err); if (!obj) { - error_propagate(errp, err); - error_prepend(errp, "required link '" ICP_PROP_CPU "' not found: "= ); + error_propagate_prepend(errp, err, + "required link '" ICP_PROP_CPU + "' not found: "); return; } =20 @@ -624,8 +626,9 @@ static void ics_base_realize(DeviceState *dev, Error **= errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err); if (!obj) { - error_propagate(errp, err); - error_prepend(errp, "required link '" ICS_PROP_XICS "' not found: = "); + error_propagate_prepend(errp, err, + "required link '" ICS_PROP_XICS + "' not found: "); return; } ics->xics =3D XICS_FABRIC(obj); diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 9750464bf4..ad1bcc7990 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -148,8 +148,8 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) =20 chip =3D object_property_get_link(OBJECT(dev), "chip", &local_err); if (!chip) { - error_propagate(errp, local_err); - error_prepend(errp, "required link 'chip' not found: "); + error_propagate_prepend(errp, local_err, + "required link 'chip' not found: "); return; } =20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index c2271e6ed4..58afa46204 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1724,16 +1724,15 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) if (smc->legacy_irq_allocation) { irq =3D spapr_irq_findone(spapr, &local_err); if (local_err) { - error_propagate(errp, local_err); - error_prepend(errp, "can't allocate LSIs: "); + error_propagate_prepend(errp, local_err, + "can't allocate LSIs: "); return; } } =20 spapr_irq_claim(spapr, irq, true, &local_err); if (local_err) { - error_propagate(errp, local_err); - error_prepend(errp, "can't allocate LSIs: "); + error_propagate_prepend(errp, local_err, "can't allocate LSIs:= "); return; } =20 diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c index 54b400b94a..5c786e5128 100644 --- a/hw/timer/aspeed_timer.c +++ b/hw/timer/aspeed_timer.c @@ -454,8 +454,7 @@ static void aspeed_timer_realize(DeviceState *dev, Erro= r **errp) =20 obj =3D object_property_get_link(OBJECT(dev), "scu", &err); if (!obj) { - error_propagate(errp, err); - error_prepend(errp, "required link 'scu' not found: "); + error_propagate_prepend(errp, err, "required link 'scu' not found:= "); return; } s->scu =3D ASPEED_SCU(obj); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 11f7720d71..bf796d67e6 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -340,8 +340,9 @@ static USBDevice *usb_try_create_simple(USBBus *bus, co= nst char *name, } object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err) { - error_propagate(errp, err); - error_prepend(errp, "Failed to initialize USB device '%s': ", name= ); + error_propagate_prepend(errp, err, + "Failed to initialize USB device '%s': ", + name); return NULL; } return dev; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8b73582d51..4404c28360 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1283,8 +1283,7 @@ static int vfio_msi_setup(VFIOPCIDevice *vdev, int po= s, Error **errp) if (ret =3D=3D -ENOTSUP) { return 0; } - error_prepend(&err, "msi_init failed: "); - error_propagate(errp, err); + error_propagate_prepend(errp, err, "msi_init failed: "); return ret; } vdev->msi_cap_size =3D 0xa + (msi_maskbit ? 0xa : 0) + (msi_64bit ? 0x= 4 : 0); diff --git a/include/qapi/error.h b/include/qapi/error.h index bcb86a79f5..51b63dd4b5 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -52,8 +52,12 @@ * where Error **errp is a parameter, by convention the last one. * * Pass an existing error to the caller with the message modified: + * error_propagate_prepend(errp, err); + * + * Avoid * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); + * because this fails to prepend when @errp is &error_fatal. * * Create a new error and pass it to the caller: * error_setg(errp, "situation normal, all fouled up"); @@ -215,6 +219,16 @@ void error_setg_win32_internal(Error **errp, */ void error_propagate(Error **dst_errp, Error *local_err); =20 + +/* + * Propagate error object (if any) with some text prepended. + * Behaves like + * error_prepend(&local_err, fmt, ...); + * error_propagate(dst_errp, local_err); + */ +void error_propagate_prepend(Error **dst_errp, Error *local_err, + const char *fmt, ...); + /* * Prepend some text to @errp's human-readable error message. * The text is made by formatting @fmt, @ap like vprintf(). diff --git a/migration/migration.c b/migration/migration.c index d6ae879dc8..f0f299a773 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1546,9 +1546,9 @@ static GSList *migration_blockers; int migrate_add_blocker(Error *reason, Error **errp) { if (migrate_get_current()->only_migratable) { - error_propagate(errp, error_copy(reason)); - error_prepend(errp, "disallowing migration blocker " - "(--only_migratable) for: "); + error_propagate_prepend(errp, error_copy(reason), + "disallowing migration blocker " + "(--only_migratable) for: "); return -EACCES; } =20 @@ -1557,9 +1557,9 @@ int migrate_add_blocker(Error *reason, Error **errp) return 0; } =20 - error_propagate(errp, error_copy(reason)); - error_prepend(errp, "disallowing migration blocker (migration in " - "progress) for: "); + error_propagate_prepend(errp, error_copy(reason), + "disallowing migration blocker " + "(migration in progress) for: "); return -EBUSY; } =20 diff --git a/util/error.c b/util/error.c index 3efdd69162..b5ccbd8eac 100644 --- a/util/error.c +++ b/util/error.c @@ -292,3 +292,16 @@ void error_propagate(Error **dst_errp, Error *local_er= r) error_free(local_err); } } + +void error_propagate_prepend(Error **dst_errp, Error *err, + const char *fmt, ...) +{ + va_list ap; + + if (dst_errp && !*dst_errp) { + va_start(ap, fmt); + error_vprepend(&err, fmt, ap); + va_end(ap); + } /* else error is being ignored, don't bother with prepending */ + error_propagate(dst_errp, err); +} --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765549142926.2342759585356; Wed, 17 Oct 2018 01:39:09 -0700 (PDT) Received: from localhost ([::1]:34555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChM4-0001Gq-GQ for importer@patchew.org; Wed, 17 Oct 2018 04:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-00085M-Qc for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAY-0000zl-8S for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAX-0000xW-TA for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 562EF30024EC; Wed, 17 Oct 2018 08:27:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0AED5DD95; Wed, 17 Oct 2018 08:27:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1CCD01132D75; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:26 +0200 Message-Id: <20181017082702.5581-3-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 17 Oct 2018 08:27:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 02/38] Use error_fatal to simplify obvious fatal errors (again) 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: Paolo Bonzini , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a slight improvement of the Coccinelle semantic patch from commit 007b06578ab, and use it to clean up. It leaves dead Error * variables behind, cleaned up manually. Cc: David Gibson Cc: Alexander Graf Cc: Eric Blake Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Acked-by: David Gibson --- hw/intc/xics_kvm.c | 7 +------ qemu-nbd.c | 6 +----- scripts/coccinelle/use-error_fatal.cocci | 20 ++++++++++++++++++++ vl.c | 7 +------ 4 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 scripts/coccinelle/use-error_fatal.cocci diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 30c3769a20..e8fa9a53ae 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -198,17 +198,12 @@ static void ics_get_kvm_state(ICSState *ics) { uint64_t state; int i; - Error *local_err =3D NULL; =20 for (i =3D 0; i < ics->nr_irqs; i++) { ICSIRQState *irq =3D &ics->irqs[i]; =20 kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, - i + ics->offset, &state, false, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + i + ics->offset, &state, false, &error_fatal); =20 irq->server =3D state & KVM_XICS_DESTINATION_MASK; irq->saved_priority =3D (state >> KVM_XICS_PRIORITY_SHIFT) diff --git a/qemu-nbd.c b/qemu-nbd.c index e76fe3082a..7874bc973c 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -1002,11 +1002,7 @@ int main(int argc, char **argv) } =20 exp =3D nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_c= losed, - writethrough, NULL, &local_err); - if (!exp) { - error_report_err(local_err); - exit(EXIT_FAILURE); - } + writethrough, NULL, &error_fatal); nbd_export_set_name(exp, export_name); nbd_export_set_description(exp, export_description); =20 diff --git a/scripts/coccinelle/use-error_fatal.cocci b/scripts/coccinelle/= use-error_fatal.cocci new file mode 100644 index 0000000000..10fff0aec4 --- /dev/null +++ b/scripts/coccinelle/use-error_fatal.cocci @@ -0,0 +1,20 @@ +@@ +type T; +identifier FUN, RET; +expression list ARGS; +expression ERR, EC, FAIL; +@@ +( +- T RET =3D FUN(ARGS, &ERR); ++ T RET =3D FUN(ARGS, &error_fatal); +| +- RET =3D FUN(ARGS, &ERR); ++ RET =3D FUN(ARGS, &error_fatal); +| +- FUN(ARGS, &ERR); ++ FUN(ARGS, &error_fatal); +) +- if (FAIL) { +- error_report_err(ERR); +- exit(EC); +- } diff --git a/vl.c b/vl.c index 4e25c78bff..ff50199e64 100644 --- a/vl.c +++ b/vl.c @@ -2002,15 +2002,10 @@ static void select_vgahw(const char *p) =20 static void parse_display_qapi(const char *optarg) { - Error *err =3D NULL; DisplayOptions *opts; Visitor *v; =20 - v =3D qobject_input_visitor_new_str(optarg, "type", &err); - if (!v) { - error_report_err(err); - exit(1); - } + v =3D qobject_input_visitor_new_str(optarg, "type", &error_fatal); =20 visit_type_DisplayOptions(v, NULL, &opts, &error_fatal); QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539764982823243.82825200662296; Wed, 17 Oct 2018 01:29:42 -0700 (PDT) Received: from localhost ([::1]:34507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChD3-0001mT-F0 for importer@patchew.org; Wed, 17 Oct 2018 04:29:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-00085D-L6 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAY-0000zr-94 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAX-0000xY-Te for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8677F30034A1; Wed, 17 Oct 2018 08:27:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 895B95DD79; Wed, 17 Oct 2018 08:27:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 206981132D7F; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:27 +0200 Message-Id: <20181017082702.5581-4-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Oct 2018 08:27:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 03/38] block: Use warn_report() & friends to report warnings 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: Kevin Wolf , Hitoshi Mitake , Peter Lieven , Ronnie Sahlberg , Liu Yuan , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. Convert a few that are actually warnings to warn_report(). While there, split warnings consisting of multiple sentences to conform to conventions spelled out in warn_report()'s contract, and improve a rather useless warning in sheepdog.c. Cc: Kevin Wolf Cc: Ronnie Sahlberg Cc: Paolo Bonzini Cc: Peter Lieven Cc: Hitoshi Mitake Cc: Liu Yuan Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf --- block/bochs.c | 8 ++++---- block/cloop.c | 8 ++++---- block/dmg.c | 8 ++++---- block/iscsi.c | 2 +- block/rbd.c | 12 ++++++------ block/sheepdog.c | 2 +- block/vvfat.c | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/block/bochs.c b/block/bochs.c index 50c630047b..36c1b45bd2 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -112,10 +112,10 @@ static int bochs_open(BlockDriverState *bs, QDict *op= tions, int flags, } =20 if (!bdrv_is_read_only(bs)) { - error_report("Opening bochs images without an explicit read-only= =3Don " - "option is deprecated. Future versions will refuse to= " - "open the image instead of automatically marking the " - "image read-only."); + warn_report("Opening bochs images without an explicit read-only=3D= on " + "option is deprecated"); + error_printf("Future versions may refuse to open the image " + "instead of automatically marking it read-only.\n"); ret =3D bdrv_set_read_only(bs, true, errp); /* no write support ye= t */ if (ret < 0) { return ret; diff --git a/block/cloop.c b/block/cloop.c index 2be68987bd..a558e67cb0 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -74,10 +74,10 @@ static int cloop_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 if (!bdrv_is_read_only(bs)) { - error_report("Opening cloop images without an explicit read-only= =3Don " - "option is deprecated. Future versions will refuse to= " - "open the image instead of automatically marking the " - "image read-only."); + warn_report("Opening cloop images without an explicit read-only=3D= on " + "option is deprecated"); + error_printf("Future versions may refuse to open the image " + "instead of automatically marking it read-only.\n"); ret =3D bdrv_set_read_only(bs, true, errp); if (ret < 0) { return ret; diff --git a/block/dmg.c b/block/dmg.c index c9b3c519c4..9fb814460d 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -420,10 +420,10 @@ static int dmg_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 if (!bdrv_is_read_only(bs)) { - error_report("Opening dmg images without an explicit read-only=3Do= n " - "option is deprecated. Future versions will refuse to= " - "open the image instead of automatically marking the " - "image read-only."); + warn_report("Opening dmg images without an explicit read-only=3Don= " + "option is deprecated"); + error_printf("Future versions may refuse to open the image " + "instead of automatically marking it read-only.\n"); ret =3D bdrv_set_read_only(bs, true, errp); if (ret < 0) { return ret; diff --git a/block/iscsi.c b/block/iscsi.c index bb69faf34a..73998c2860 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1844,7 +1844,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *op= tions, int flags, iscsi_set_timeout(iscsi, timeout); #else if (timeout) { - error_report("iSCSI: ignoring timeout value for libiscsi <1.15.0"); + warn_report("iSCSI: ignoring timeout value for libiscsi <1.15.0"); } #endif =20 diff --git a/block/rbd.c b/block/rbd.c index 014c68d629..6e26bac170 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -750,8 +750,8 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, /* Take care whenever deciding to actually deprecate; once this ab= ility * is removed, we will not be able to open any images with legacy-= styled * backing image strings. */ - error_report("RBD options encoded in the filename as keyvalue pair= s " - "is deprecated"); + warn_report("RBD options encoded in the filename as keyvalue pairs= " + "is deprecated"); } =20 /* Remove the processed options from the QDict (the visitor processes @@ -781,10 +781,10 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict = *options, int flags, * leave as-is */ if (s->snap !=3D NULL) { if (!bdrv_is_read_only(bs)) { - error_report("Opening rbd snapshots without an explicit " - "read-only=3Don option is deprecated. Future vers= ions " - "will refuse to open the image instead of " - "automatically marking the image read-only."); + warn_report("Opening rbd snapshots without an explicit " + "read-only=3Don option is deprecated"); + error_printf("Future versions may refuse to open the image " + "instead of automatically marking it read-only.\n= "); r =3D bdrv_set_read_only(bs, true, &local_err); if (r < 0) { error_propagate(errp, local_err); diff --git a/block/sheepdog.c b/block/sheepdog.c index b229a664d9..0125df9d49 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -572,7 +572,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error = **errp) if (s->addr->type =3D=3D SOCKET_ADDRESS_TYPE_INET && fd >=3D 0) { int ret =3D socket_set_nodelay(fd); if (ret < 0) { - error_report("%s", strerror(errno)); + warn_report("can't set TCP_NODELAY: %s", strerror(errno)); } } =20 diff --git a/block/vvfat.c b/block/vvfat.c index fc41841a5c..8f3f9e9a93 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1263,10 +1263,10 @@ static int vvfat_open(BlockDriverState *bs, QDict *= options, int flags, goto fail; } } else if (!bdrv_is_read_only(bs)) { - error_report("Opening non-rw vvfat images without an explicit " - "read-only=3Don option is deprecated. Future versions= " - "will refuse to open the image instead of " - "automatically marking the image read-only."); + warn_report("Opening non-rw vvfat images without an explicit " + "read-only=3Don option is deprecated"); + error_printf("Future versions may refuse to open the image " + "instead of automatically marking it read-only.\n"); /* read only is the default for safety */ ret =3D bdrv_set_read_only(bs, true, &local_err); if (ret < 0) { --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766621898228.6025466341024; Wed, 17 Oct 2018 01:57:01 -0700 (PDT) Received: from localhost ([::1]:34653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChdG-0007nv-3U for importer@patchew.org; Wed, 17 Oct 2018 04:56:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB5-0000L6-2K for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB3-000218-64 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52726) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB2-0001hi-Ll for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3E0430E4EB3; Wed, 17 Oct 2018 08:27:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD27D19E17; Wed, 17 Oct 2018 08:27:03 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 241541132D83; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:28 +0200 Message-Id: <20181017082702.5581-5-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 17 Oct 2018 08:27:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 04/38] cpus hw target: Use warn_report() & friends to report warnings 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: Wei Huang , Fam Zheng , Mark Cave-Ayland , Alex Williamson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. Convert a few that are actually warnings to warn_report(). While there, split a warning consisting of multiple sentences to conform to conventions spelled out in warn_report()'s contract. Cc: Alex Benn=C3=A9e Cc: Mark Cave-Ayland Cc: Alex Williamson Cc: Fam Zheng Cc: Wei Huang Cc: David Gibson Signed-off-by: Markus Armbruster Acked-by: David Gibson Reviewed-by: Alex Benn=C3=A9e --- cpus.c | 8 ++++---- hw/display/cg3.c | 2 +- hw/display/tcx.c | 2 +- hw/misc/ivshmem.c | 4 ++-- hw/net/virtio-net.c | 8 ++++---- hw/virtio/virtio-pci.c | 4 ++-- target/i386/cpu.c | 17 +++++++++-------- target/ppc/translate_init.inc.c | 4 ++-- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/cpus.c b/cpus.c index 361678e459..7804071872 100644 --- a/cpus.c +++ b/cpus.c @@ -211,12 +211,12 @@ void qemu_tcg_configure(QemuOpts *opts, Error **errp) error_setg(errp, "No MTTCG when icount is enabled"); } else { #ifndef TARGET_SUPPORTS_MTTCG - error_report("Guest not yet converted to MTTCG - " - "you may get unexpected results"); + warn_report("Guest not yet converted to MTTCG - " + "you may get unexpected results"); #endif if (!check_tcg_memory_orders_compatible()) { - error_report("Guest expects a stronger memory ordering= " - "than the host provides"); + warn_report("Guest expects a stronger memory ordering " + "than the host provides"); error_printf("This may cause strange/hard to debug err= ors\n"); } mttcg_enabled =3D true; diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 1c199ab369..e50d97e48c 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -307,7 +307,7 @@ static void cg3_realizefn(DeviceState *dev, Error **err= p) ret =3D load_image_mr(fcode_filename, &s->rom); g_free(fcode_filename); if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { - error_report("cg3: could not load prom '%s'", CG3_ROM_FILE); + warn_report("cg3: could not load prom '%s'", CG3_ROM_FILE); } } =20 diff --git a/hw/display/tcx.c b/hw/display/tcx.c index b2786ee8d0..66f2459226 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -823,7 +823,7 @@ static void tcx_realizefn(DeviceState *dev, Error **err= p) ret =3D load_image_mr(fcode_filename, &s->rom); g_free(fcode_filename); if (ret < 0 || ret > FCODE_MAX_ROM_SIZE) { - error_report("tcx: could not load prom '%s'", TCX_ROM_FILE); + warn_report("tcx: could not load prom '%s'", TCX_ROM_FILE); } } =20 diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 8cb17b9dd4..f88910e55c 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -1288,8 +1288,8 @@ static void ivshmem_realize(PCIDevice *dev, Error **e= rrp) IVShmemState *s =3D IVSHMEM_COMMON(dev); =20 if (!qtest_enabled()) { - error_report("ivshmem is deprecated, please use ivshmem-plain" - " or ivshmem-doorbell instead"); + warn_report("ivshmem is deprecated, please use ivshmem-plain" + " or ivshmem-doorbell instead"); } =20 if (qemu_chr_fe_backend_connected(&s->server_chr) + !!s->shmobj !=3D 1= ) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 4bdd5b8532..385b1a03e9 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2020,10 +2020,10 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) =20 if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer") && strcmp(n->net_conf.tx, "bh")) { - error_report("virtio-net: " - "Unknown option tx=3D%s, valid options: \"timer\" \"b= h\"", - n->net_conf.tx); - error_report("Defaulting to \"bh\""); + warn_report("virtio-net: " + "Unknown option tx=3D%s, valid options: \"timer\" \"bh= \"", + n->net_conf.tx); + error_printf("Defaulting to \"bh\""); } =20 n->net_conf.tx_queue_size =3D MIN(virtio_net_max_tx_queue_size(n), diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3a01fe90f0..a954799267 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1683,8 +1683,8 @@ static void virtio_pci_device_plugged(DeviceState *d,= Error **errp) if (err) { /* Notice when a system that supports MSIx can't initialize it= */ if (err !=3D -ENOTSUP) { - error_report("unable to init msix vectors to %" PRIu32, - proxy->nvectors); + warn_report("unable to init msix vectors to %" PRIu32, + proxy->nvectors); } proxy->nvectors =3D 0; } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c88876dfe3..9d4217afba 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5123,14 +5123,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Err= or **errp) * NOTE: the following code has to follow qemu_init_vcpu(). Otherwise * cs->nr_threads hasn't be populated yet and the checking is incorrec= t. */ - if (IS_AMD_CPU(env) && - !(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) && - cs->nr_threads > 1 && !ht_warned) { - error_report("This family of AMD CPU doesn't support " - "hyperthreading(%d). Please configure -smp " - "options properly or try enabling topoext feature= .", - cs->nr_threads); - ht_warned =3D true; + if (IS_AMD_CPU(env) && + !(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) && + cs->nr_threads > 1 && !ht_warned) { + warn_report("This family of AMD CPU doesn't support " + "hyperthreading(%d)", + cs->nr_threads); + error_printf("Please configure -smp options properly" + " or try enabling topoext feature.\n"); + ht_warned =3D true; } =20 x86_cpu_apic_realize(cpu, &local_err); diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 263e63cb03..ee9432eb15 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -8381,8 +8381,8 @@ static void getset_compat_deprecated(Object *obj, Vis= itor *v, const char *name, QNull *null =3D NULL; =20 if (!qtest_enabled()) { - error_report("CPU 'compat' property is deprecated and has no effec= t; " - "use max-cpu-compat machine property instead"); + warn_report("CPU 'compat' property is deprecated and has no effect= ; " + "use max-cpu-compat machine property instead"); } visit_type_null(v, name, &null, NULL); qobject_unref(null); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766449956850.6180349548654; Wed, 17 Oct 2018 01:54:09 -0700 (PDT) Received: from localhost ([::1]:34633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChai-0005TB-Cq for importer@patchew.org; Wed, 17 Oct 2018 04:54:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Kt-TB for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB2-0001zI-MY for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB2-00018G-6u for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1194C120EE for ; Wed, 17 Oct 2018 08:27:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 227FC19E25; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 279841132D9B; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:29 +0200 Message-Id: <20181017082702.5581-6-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 17 Oct 2018 08:27:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 05/38] vfio: Use warn_report() & friends to report warnings 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: Alex Williamson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vfio code reports warnings like error_report(WARN_PREFIX "Could not frobnicate", DEV-NAME); where WARN_PREFIX is defined so the message comes out as vfio warning: DEV-NAME: Could not frobnicate This usage predates the introduction of warn_report() & friends in commit 97f40301f1d. It's time to convert to that interface. Since these functions already prefix the message with "warning: ", replace WARN_PREFIX by VFIO_MSG_PREFIX, so the messages come out like warning: vfio DEV-NAME: Could not frobnicate The next commit will replace ERR_PREFIX. Cc: Alex Williamson Signed-off-by: Markus Armbruster Acked-by: Alex Williamson Reviewed-by: Eric Blake --- hw/vfio/pci.c | 14 +++++++------- hw/vfio/platform.c | 4 ++-- include/hw/vfio/vfio-common.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4404c28360..0c3d245932 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -252,7 +252,7 @@ static void vfio_intx_update(PCIDevice *pdev) =20 vfio_intx_enable_kvm(vdev, &err); if (err) { - error_reportf_err(err, WARN_PREFIX, vdev->vbasedev.name); + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 /* Re-enable the interrupt in cased we missed an EOI */ @@ -317,7 +317,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error = **errp) =20 vfio_intx_enable_kvm(vdev, &err); if (err) { - error_reportf_err(err, WARN_PREFIX, vdev->vbasedev.name); + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 vdev->interrupt =3D VFIO_INT_INTx; @@ -1557,7 +1557,7 @@ static int vfio_msix_setup(VFIOPCIDevice *vdev, int p= os, Error **errp) &err); if (ret < 0) { if (ret =3D=3D -ENOTSUP) { - error_report_err(err); + warn_report_err(err); return 0; } =20 @@ -2590,9 +2590,9 @@ static void vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) } else if (irq_info.count =3D=3D 1) { vdev->pci_aer =3D true; } else { - error_report(WARN_PREFIX - "Could not enable error recovery for the device", - vbasedev->name); + warn_report(VFIO_MSG_PREFIX + "Could not enable error recovery for the device", + vbasedev->name); } } =20 @@ -2717,7 +2717,7 @@ static void vfio_req_notifier_handler(void *opaque) =20 qdev_unplug(&vdev->pdev.qdev, &err); if (err) { - error_reportf_err(err, WARN_PREFIX, vdev->vbasedev.name); + warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } } =20 diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index 64c1af653d..baf236ae79 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -679,8 +679,8 @@ static void vfio_platform_realize(DeviceState *dev, Err= or **errp) =20 for (i =3D 0; i < vbasedev->num_regions; i++) { if (vfio_region_mmap(vdev->regions[i])) { - error_report("%s mmap unsupported. Performance may be slow", - memory_region_name(vdev->regions[i]->mem)); + warn_report("%s mmap unsupported, performance may be slow", + memory_region_name(vdev->regions[i]->mem)); } sysbus_init_mmio(sbdev, vdev->regions[i]->mem); } diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index e46a28910a..1d7630345b 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -32,7 +32,7 @@ #endif =20 #define ERR_PREFIX "vfio error: %s: " -#define WARN_PREFIX "vfio warning: %s: " +#define VFIO_MSG_PREFIX "vfio %s: " =20 enum { VFIO_DEVICE_TYPE_PCI =3D 0, --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765469132249.49035478214728; Wed, 17 Oct 2018 01:37:49 -0700 (PDT) Received: from localhost ([::1]:34552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChKp-0008KD-He for importer@patchew.org; Wed, 17 Oct 2018 04:37:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAh-0008B2-QF for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-000160-2P for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAb-00011y-BA for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1098ACECB for ; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2214E17557; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2B2E01132D3B; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:30 +0200 Message-Id: <20181017082702.5581-7-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Oct 2018 08:27:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 06/38] vfio: Clean up error reporting after previous commit 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: Alex Williamson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The previous commit changed vfio's warning messages from vfio warning: DEV-NAME: Could not frobnicate to warning: vfio DEV-NAME: Could not frobnicate To match this change, change error messages from vfio error: DEV-NAME: On fire to vfio DEV-NAME: On fire Note the loss of "error". If we think marking error messages that way is a good idea, we should mark *all* error messages, i.e. make error_report() print it. Cc: Alex Williamson Signed-off-by: Markus Armbruster Acked-by: Alex Williamson --- hw/vfio/pci-quirks.c | 4 ++-- hw/vfio/pci.c | 8 ++++---- hw/vfio/platform.c | 2 +- include/hw/vfio/vfio-common.h | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 481fd08df7..eae31c74d6 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1670,7 +1670,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *= vdev, int nr) * but also no point in us enabling VGA if disabled in hardware. */ if (!(gmch & 0x2) && !vdev->vga && vfio_populate_vga(vdev, &err)) { - error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name); + error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); error_report("IGD device %s failed to enable VGA access, " "legacy mode disabled", vdev->vbasedev.name); goto out; @@ -1696,7 +1696,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *= vdev, int nr) ret =3D vfio_pci_igd_opregion_init(vdev, opregion, &err); if (ret) { error_append_hint(&err, "IGD legacy mode disabled\n"); - error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name); + error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); goto out; } =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0c3d245932..5c7bd96984 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -745,7 +745,7 @@ static void vfio_msi_disable_common(VFIOPCIDevice *vdev) =20 vfio_intx_enable(vdev, &err); if (err) { - error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name); + error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } } =20 @@ -2196,7 +2196,7 @@ static void vfio_pci_post_reset(VFIOPCIDevice *vdev) =20 vfio_intx_enable(vdev, &err); if (err) { - error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name); + error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 for (nr =3D 0; nr < PCI_NUM_REGIONS - 1; ++nr) { @@ -2830,7 +2830,7 @@ static void vfio_realize(PCIDevice *pdev, Error **err= p) =20 if (stat(vdev->vbasedev.sysfsdev, &st) < 0) { error_setg_errno(errp, errno, "no such host device"); - error_prepend(errp, ERR_PREFIX, vdev->vbasedev.sysfsdev); + error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.sysfsdev); return; } =20 @@ -3085,7 +3085,7 @@ out_teardown: vfio_teardown_msi(vdev); vfio_bars_exit(vdev); error: - error_prepend(errp, ERR_PREFIX, vdev->vbasedev.name); + error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 static void vfio_instance_finalize(Object *obj) diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c index baf236ae79..398db38f14 100644 --- a/hw/vfio/platform.c +++ b/hw/vfio/platform.c @@ -690,7 +690,7 @@ out: } =20 if (vdev->vbasedev.name) { - error_prepend(errp, ERR_PREFIX, vdev->vbasedev.name); + error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } else { error_prepend(errp, "vfio error: "); } diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 1d7630345b..1b434d02f6 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -31,7 +31,6 @@ #include #endif =20 -#define ERR_PREFIX "vfio error: %s: " #define VFIO_MSG_PREFIX "vfio %s: " =20 enum { --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765891728876.6162711924251; Wed, 17 Oct 2018 01:44:51 -0700 (PDT) Received: from localhost ([::1]:34584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChRi-0006M9-Jg for importer@patchew.org; Wed, 17 Oct 2018 04:44:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAx-00006H-DW for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAr-0001eP-R9 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54393) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAh-00017B-L8 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D7F846202 for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24C375DDFE; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2EB221132D3E; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:31 +0200 Message-Id: <20181017082702.5581-8-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 07/38] char: Use error_printf() to print help and such 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: Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. Convert a few that are actually help and such to error_printf(). Improves output of -chardev help from qemu-system-x86_64: -chardev help: Available chardev backend types: serial ... to Available chardev backend types: serial ... Cc: Paolo Bonzini Cc: "Marc-Andr=C3=A9 Lureau" Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-pty.c | 2 +- chardev/char.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index e8d9a53476..f681d637c1 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -259,7 +259,7 @@ static void char_pty_open(Chardev *chr, qemu_set_nonblock(master_fd); =20 chr->filename =3D g_strdup_printf("pty:%s", pty_name); - error_report("char device redirected to %s (label %s)", + error_printf("char device redirected to %s (label %s)\n", pty_name, chr->label); =20 s =3D PTY_CHARDEV(chr); diff --git a/chardev/char.c b/chardev/char.c index e115166995..7f07a1bfbd 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -634,7 +634,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, Error *= *errp) =20 chardev_name_foreach(help_string_append, str); =20 - error_report("Available chardev backend types: %s", str->str); + error_printf("Available chardev backend types: %s\n", str->str); g_string_free(str, true); return NULL; } --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765168282533.0450889432166; Wed, 17 Oct 2018 01:32:48 -0700 (PDT) Received: from localhost ([::1]:34524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChG2-00048S-Kh for importer@patchew.org; Wed, 17 Oct 2018 04:32:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-000859-KO for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAY-000102-Eu for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35520) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAY-0000y4-6J for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60F0E3082DCF; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 266E45F7C6; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 326181132D3F; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:32 +0200 Message-Id: <20181017082702.5581-9-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 17 Oct 2018 08:27:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 08/38] 9pfs: Fix CLI parsing crash on error 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: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. 9p-handle.c's handle_parse_opts() does that, and then fails without setting an error. Wrong. Its caller crashes when it tries to report the error: $ qemu-system-x86_64 -nodefaults -fsdev id=3Dfoo,fsdriver=3Dhandle qemu-system-x86_64: -fsdev id=3Dfoo,fsdriver=3Dhandle: warning: handle = backend is deprecated qemu-system-x86_64: -fsdev id=3Dfoo,fsdriver=3Dhandle: fsdev: No path s= pecified Segmentation fault (core dumped) Screwed up when commit 91cda4e8f37 (v2.12.0) converted the function to Error. Fix by calling error_setg() instead of error_report(). Fixes: 91cda4e8f372602795e3a2f4bd2e3adaf9f82255 Cc: Greg Kurz Signed-off-by: Markus Armbruster Acked-by: Greg Kurz Reviewed-by: Eric Blake --- hw/9pfs/9p-handle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c index f3641dbe4a..3465b1ef30 100644 --- a/hw/9pfs/9p-handle.c +++ b/hw/9pfs/9p-handle.c @@ -19,6 +19,7 @@ #include #include #include +#include "qapi/error.h" #include "qemu/xattr.h" #include "qemu/cutils.h" #include "qemu/error-report.h" @@ -655,12 +656,13 @@ static int handle_parse_opts(QemuOpts *opts, FsDriver= Entry *fse, Error **errp) warn_report("handle backend is deprecated"); =20 if (sec_model) { - error_report("Invalid argument security_model specified with handl= e fsdriver"); + error_setg(errp, + "Invalid argument security_model specified with handle = fsdriver"); return -1; } =20 if (!path) { - error_report("fsdev: No path specified"); + error_setg(errp, "fsdev: No path specified"); return -1; } fse->path =3D g_strdup(path); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766037260663.1968500611955; Wed, 17 Oct 2018 01:47:17 -0700 (PDT) Received: from localhost ([::1]:34600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChU4-0008HN-2D for importer@patchew.org; Wed, 17 Oct 2018 04:47:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB1-0000GY-FR for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAx-0001qB-Mw for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35670) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAx-0001Oo-AV for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B97E93082E60 for ; Wed, 17 Oct 2018 08:27:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 879825C226; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 35DF51132C7B; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:33 +0200 Message-Id: <20181017082702.5581-10-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 17 Oct 2018 08:27:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 09/38] pc: Fix machine property nvdimm-persistence error handling 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: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. pc.c's pc_machine_set_nvdimm_persistence() does that, and then exit()s. Wrong. Attempting to set machine property nvdimm-persistence to a bad value instantly kills the VM: $ qemu-system-x86_64 -nodefaults -S -display none -qmp stdio {"QMP": {"version": {"qemu": {"micro": 50, "minor": 0, "major": 3}, "pa= ckage": "v3.0.0-837-gc5e4e49258"}, "capabilities": []}} {"execute": "qmp_capabilities"} {"return": {}} {"execute": "qom-set", "arguments": {"path": "/machine", "property": "n= vdimm-persistence", "value": "instadeath"}} -machine nvdimm-persistence=3Dinstadeath: unsupported option $ echo $? 1 Broken when commit 11c39b5cd96 (v3.0.0) replaced error_propagate(); return by error_report(); exit() instead of error_setg(); return. Fix that. Fixes: 11c39b5cd966ddc067a1ca0c5392ec9b666c45b7 Cc: "Michael S. Tsirkin" Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index cd5029c149..eab8572f2a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2209,8 +2209,9 @@ static void pc_machine_set_nvdimm_persistence(Object = *obj, const char *value, else if (strcmp(value, "mem-ctrl") =3D=3D 0) nvdimm_state->persistence =3D 2; else { - error_report("-machine nvdimm-persistence=3D%s: unsupported option= ", value); - exit(EXIT_FAILURE); + error_setg(errp, "-machine nvdimm-persistence=3D%s: unsupported op= tion", + value); + return; } =20 g_free(nvdimm_state->persistence_string); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766439581700.1294035232228; Wed, 17 Oct 2018 01:53:59 -0700 (PDT) Received: from localhost ([::1]:34632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChaY-0005J9-El for importer@patchew.org; Wed, 17 Oct 2018 04:53:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Kw-Uw for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB2-0001y9-16 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB1-0001Oq-Np for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BB21680E7B for ; Wed, 17 Oct 2018 08:27:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A4C25C228; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 398BB11329D4; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:34 +0200 Message-Id: <20181017082702.5581-11-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Oct 2018 08:27:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 10/38] ioapic: Fix error handling in realize() 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: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. ioapic_realize() does that, and then exit()s. Currently mostly harmless, as the device cannot be hot-plugged. Fixes: 20fd4b7b6d9282fe0cb83601f1821f31bd257458 Cc: Peter Xu Signed-off-by: Markus Armbruster Reviewed-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/intc/ioapic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index b6896ac4ce..4e529729b4 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -21,7 +21,7 @@ */ =20 #include "qemu/osdep.h" -#include "qemu/error-report.h" +#include "qapi/error.h" #include "monitor/monitor.h" #include "hw/hw.h" #include "hw/i386/pc.h" @@ -393,9 +393,9 @@ static void ioapic_realize(DeviceState *dev, Error **er= rp) IOAPICCommonState *s =3D IOAPIC_COMMON(dev); =20 if (s->version !=3D 0x11 && s->version !=3D 0x20) { - error_report("IOAPIC only supports version 0x11 or 0x20 " - "(default: 0x%x).", IOAPIC_VER_DEF); - exit(1); + error_setg(errp, "IOAPIC only supports version 0x11 or 0x20 " + "(default: 0x%x).", IOAPIC_VER_DEF); + return; } =20 memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s, --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765717440984.4068329246642; Wed, 17 Oct 2018 01:41:57 -0700 (PDT) Received: from localhost ([::1]:34572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChOu-0003f7-A2 for importer@patchew.org; Wed, 17 Oct 2018 04:41:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-00085B-KZ for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAZ-00010l-9H for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAY-0000zv-Tg for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2035A307D866 for ; Wed, 17 Oct 2018 08:27:06 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA78D43FFE; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3D0F81132988; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:35 +0200 Message-Id: <20181017082702.5581-12-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 17 Oct 2018 08:27:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 11/38] smbios: Clean up error handling in smbios_add() 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. smbios_entry_add() does that, and then exit()s. It also passes &error_fatal to qemu_opts_validate(). Both wrong, but currently harmless, as its only caller passes &error_fatal. Messed up in commit 1007a37e208. Clean it up. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Acked-by: Paolo Bonzini --- hw/smbios/smbios.c | 90 +++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a27e54b2fa..920939454e 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -950,6 +950,7 @@ static void save_opt_list(size_t *ndest, const char ***= dest, =20 void smbios_entry_add(QemuOpts *opts, Error **errp) { + Error *err =3D NULL; const char *val; =20 assert(!smbios_immutable); @@ -960,12 +961,16 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) int size; struct smbios_table *table; /* legacy mode only */ =20 - qemu_opts_validate(opts, qemu_smbios_file_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_file_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } =20 size =3D get_image_size(val); if (size =3D=3D -1 || size < sizeof(struct smbios_structure_header= )) { - error_report("Cannot read SMBIOS file %s", val); - exit(1); + error_setg(errp, "Cannot read SMBIOS file %s", val); + return; } =20 /* @@ -978,14 +983,15 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) smbios_tables_len); =20 if (load_image(val, (uint8_t *)header) !=3D size) { - error_report("Failed to load SMBIOS file %s", val); - exit(1); + error_setg(errp, "Failed to load SMBIOS file %s", val); + return; } =20 if (test_bit(header->type, have_fields_bitmap)) { - error_report("can't load type %d struct, fields already specif= ied!", - header->type); - exit(1); + error_setg(errp, + "can't load type %d struct, fields already specifie= d!", + header->type); + return; } set_bit(header->type, have_binfile_bitmap); =20 @@ -1030,19 +1036,23 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) unsigned long type =3D strtoul(val, NULL, 0); =20 if (type > SMBIOS_MAX_TYPE) { - error_report("out of range!"); - exit(1); + error_setg(errp, "out of range!"); + return; } =20 if (test_bit(type, have_binfile_bitmap)) { - error_report("can't add fields, binary file already loaded!"); - exit(1); + error_setg(errp, "can't add fields, binary file already loaded= !"); + return; } set_bit(type, have_fields_bitmap); =20 switch (type) { case 0: - qemu_opts_validate(opts, qemu_smbios_type0_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_type0_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type0.vendor, opts, "vendor"); save_opt(&type0.version, opts, "version"); save_opt(&type0.date, opts, "date"); @@ -1051,14 +1061,18 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) val =3D qemu_opt_get(opts, "release"); if (val) { if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != =3D 2) { - error_report("Invalid release"); - exit(1); + error_setg(errp, "Invalid release"); + return; } type0.have_major_minor =3D true; } return; case 1: - qemu_opts_validate(opts, qemu_smbios_type1_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_type1_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type1.manufacturer, opts, "manufacturer"); save_opt(&type1.product, opts, "product"); save_opt(&type1.version, opts, "version"); @@ -1069,14 +1083,18 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) val =3D qemu_opt_get(opts, "uuid"); if (val) { if (qemu_uuid_parse(val, &qemu_uuid) !=3D 0) { - error_report("Invalid UUID"); - exit(1); + error_setg(errp, "Invalid UUID"); + return; } qemu_uuid_set =3D true; } return; case 2: - qemu_opts_validate(opts, qemu_smbios_type2_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_type2_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type2.manufacturer, opts, "manufacturer"); save_opt(&type2.product, opts, "product"); save_opt(&type2.version, opts, "version"); @@ -1085,7 +1103,11 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type2.location, opts, "location"); return; case 3: - qemu_opts_validate(opts, qemu_smbios_type3_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_type3_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type3.manufacturer, opts, "manufacturer"); save_opt(&type3.version, opts, "version"); save_opt(&type3.serial, opts, "serial"); @@ -1093,7 +1115,11 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type3.sku, opts, "sku"); return; case 4: - qemu_opts_validate(opts, qemu_smbios_type4_opts, &error_fatal); + qemu_opts_validate(opts, qemu_smbios_type4_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type4.sock_pfx, opts, "sock_pfx"); save_opt(&type4.manufacturer, opts, "manufacturer"); save_opt(&type4.version, opts, "version"); @@ -1102,11 +1128,19 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type4.part, opts, "part"); return; case 11: - qemu_opts_validate(opts, qemu_smbios_type11_opts, &error_fatal= ); + qemu_opts_validate(opts, qemu_smbios_type11_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt_list(&type11.nvalues, &type11.values, opts, "value"); return; case 17: - qemu_opts_validate(opts, qemu_smbios_type17_opts, &error_fatal= ); + qemu_opts_validate(opts, qemu_smbios_type17_opts, &err); + if (err) { + error_propagate(errp, err); + return; + } save_opt(&type17.loc_pfx, opts, "loc_pfx"); save_opt(&type17.bank, opts, "bank"); save_opt(&type17.manufacturer, opts, "manufacturer"); @@ -1116,12 +1150,12 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) type17.speed =3D qemu_opt_get_number(opts, "speed", 0); return; default: - error_report("Don't know how to build fields for SMBIOS type %= ld", - type); - exit(1); + error_setg(errp, + "Don't know how to build fields for SMBIOS type %ld= ", + type); + return; } } =20 - error_report("Must specify type=3D or file=3D"); - exit(1); + error_setg(errp, "Must specify type=3D or file=3D"); } --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539764948347995.4187592382783; Wed, 17 Oct 2018 01:29:08 -0700 (PDT) Received: from localhost ([::1]:34504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChCV-0001L3-5k for importer@patchew.org; Wed, 17 Oct 2018 04:29:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-000856-Io for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAZ-00010T-0z for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAY-0000zR-Ow for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00CDA155DB for ; Wed, 17 Oct 2018 08:27:06 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEA0653B00; Wed, 17 Oct 2018 08:27:05 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 40AAE1132947; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:36 +0200 Message-Id: <20181017082702.5581-13-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Oct 2018 08:27:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 12/38] migration: Fix !replay_can_snapshot() error handling 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: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. save_snapshot() and load_snapshot() do that, and then fail without setting an error. Wrong. The HMP commands survive this unscathed, since hmp_handle_error() does nothing when no error has been set. Callers main() (on behalf of -loadvm) and replay_vmstate_init() crash, but I'm not sure the error is possible there. Screwed up when commit 377b21ccea1 (v2.12.0) added incorrect error handling right next to correct examples. Fix by calling error_setg() instead of error_report(). Fixes: 377b21ccea1755a8b0dae822c29567c58dda6939 Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- migration/savevm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 2d10e45582..5f8eb38676 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2414,8 +2414,8 @@ int save_snapshot(const char *name, Error **errp) AioContext *aio_context; =20 if (!replay_can_snapshot()) { - error_report("Record/replay does not allow making snapshot " - "right now. Try once more later."); + error_setg(errp, "Record/replay does not allow making snapshot " + "right now. Try once more later."); return ret; } =20 @@ -2611,8 +2611,8 @@ int load_snapshot(const char *name, Error **errp) MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 if (!replay_can_snapshot()) { - error_report("Record/replay does not allow loading snapshot " - "right now. Try once more later."); + error_setg(errp, "Record/replay does not allow loading snapshot " + "right now. Try once more later."); return -EINVAL; } =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766081869467.7460028566685; Wed, 17 Oct 2018 01:48:01 -0700 (PDT) Received: from localhost ([::1]:34603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChUm-0000MO-Jb for importer@patchew.org; Wed, 17 Oct 2018 04:48:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAe-000872-6j for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-00016z-MT for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00013q-2m for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A99FA3082141 for ; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15AC169FC8; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 442ED113282C; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:37 +0200 Message-Id: <20181017082702.5581-14-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 13/38] l2tpv3: Improve -netdev/netdev_add/-net/... error reporting 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: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When -netdev l2tpv3 fails, it first reports a specific error, then a generic one, like this: $ qemu-system-x86_64 -netdev l2tpv3,id=3Dfoo,src=3D,dst=3D,txsession=3D1 qemu-system-x86_64: -netdev l2tpv3,id=3Dfoo,src=3D,dst=3D,txsession=3D1= : l2tpv3_open : could not resolve src, errno =3D Name or service not known qemu-system-x86_64: Device 'l2tpv3' could not be initialized With the command line, the messages go to stderr. In HMP, they go to the monitor. In QMP, the second one becomes the error reply, and the first one goes to stderr. Convert net_init_tap() to Error. This suppresses the unwanted second message, and makes the specific error the QMP error reply. Cc: Jason Wang Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- net/l2tpv3.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 6745b78990..81db24dc8c 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -28,6 +28,7 @@ #include #include "net/net.h" #include "clients.h" +#include "qapi/error.h" #include "qemu-common.h" #include "qemu/error-report.h" #include "qemu/option.h" @@ -528,7 +529,6 @@ int net_init_l2tpv3(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - /* FIXME error_setg(errp, ...) on failure */ const NetdevL2TPv3Options *l2tpv3; NetL2TPV3State *s; NetClientState *nc; @@ -555,7 +555,7 @@ int net_init_l2tpv3(const Netdev *netdev, } =20 if ((l2tpv3->has_offset) && (l2tpv3->offset > 256)) { - error_report("l2tpv3_open : offset must be less than 256 bytes"); + error_setg(errp, "offset must be less than 256 bytes"); goto outerr; } =20 @@ -563,6 +563,8 @@ int net_init_l2tpv3(const Netdev *netdev, if (l2tpv3->has_rxcookie && l2tpv3->has_txcookie) { s->cookie =3D true; } else { + error_setg(errp, + "require both 'rxcookie' and 'txcookie' or neither"= ); goto outerr; } } else { @@ -578,7 +580,7 @@ int net_init_l2tpv3(const Netdev *netdev, if (l2tpv3->has_udp && l2tpv3->udp) { s->udp =3D true; if (!(l2tpv3->has_srcport && l2tpv3->has_dstport)) { - error_report("l2tpv3_open : need both src and dst port for udp= "); + error_setg(errp, "need both src and dst port for udp"); goto outerr; } else { srcport =3D l2tpv3->srcport; @@ -639,20 +641,19 @@ int net_init_l2tpv3(const Netdev *netdev, gairet =3D getaddrinfo(l2tpv3->src, srcport, &hints, &result); =20 if ((gairet !=3D 0) || (result =3D=3D NULL)) { - error_report( - "l2tpv3_open : could not resolve src, errno =3D %s", - gai_strerror(gairet) - ); + error_setg(errp, "could not resolve src, errno =3D %s", + gai_strerror(gairet)); goto outerr; } fd =3D socket(result->ai_family, result->ai_socktype, result->ai_proto= col); if (fd =3D=3D -1) { fd =3D -errno; - error_report("l2tpv3_open : socket creation failed, errno =3D %d",= -fd); + error_setg(errp, "socket creation failed, errno =3D %d", + -fd); goto outerr; } if (bind(fd, (struct sockaddr *) result->ai_addr, result->ai_addrlen))= { - error_report("l2tpv3_open : could not bind socket err=3D%i", errn= o); + error_setg(errp, "could not bind socket err=3D%i", errno); goto outerr; } if (result) { @@ -677,10 +678,8 @@ int net_init_l2tpv3(const Netdev *netdev, result =3D NULL; gairet =3D getaddrinfo(l2tpv3->dst, dstport, &hints, &result); if ((gairet !=3D 0) || (result =3D=3D NULL)) { - error_report( - "l2tpv3_open : could not resolve dst, error =3D %s", - gai_strerror(gairet) - ); + error_setg(errp, "could not resolve dst, error =3D %s", + gai_strerror(gairet)); goto outerr; } =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765354784496.79454543775284; Wed, 17 Oct 2018 01:35:54 -0700 (PDT) Received: from localhost ([::1]:34540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChJ3-0006ss-NV for importer@patchew.org; Wed, 17 Oct 2018 04:35:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-00085A-KV for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAa-00013D-Mw for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAa-00010s-C6 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27168368E7 for ; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4D691057063; Wed, 17 Oct 2018 08:27:06 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 47B37113279E; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:38 +0200 Message-Id: <20181017082702.5581-15-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 14/38] net/socket: Fix invalid socket type error handling 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: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. net_socket_fd_init() does that, and then fails without setting an error. Wrong. I didn't analyze how exactly this can break. A caller that reports the error on failure would crash. Broken when commit c37f0bb1d0d (v2.11.0) converted the function to Error. Fix by calling error_setg() instead of error_report(). Fixes: c37f0bb1d0d24e3a6b5f4659bb305913dcb798a6 Cc: Jason Wang Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- net/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/socket.c b/net/socket.c index 6917fbcbf5..90ef3517be 100644 --- a/net/socket.c +++ b/net/socket.c @@ -453,8 +453,8 @@ static NetSocketState *net_socket_fd_init(NetClientStat= e *peer, case SOCK_STREAM: return net_socket_fd_init_stream(peer, model, name, fd, is_connect= ed); default: - error_report("socket type=3D%d for fd=3D%d must be either" - " SOCK_DGRAM or SOCK_STREAM", so_type, fd); + error_setg(errp, "socket type=3D%d for fd=3D%d must be either" + " SOCK_DGRAM or SOCK_STREAM", so_type, fd); closesocket(fd); } return NULL; --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765896980486.62641872606287; Wed, 17 Oct 2018 01:44:56 -0700 (PDT) Received: from localhost ([::1]:34585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChRn-0006Q0-Mw for importer@patchew.org; Wed, 17 Oct 2018 04:44:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAd-000866-HC for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-00015l-1F for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAb-00011f-9I for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E359D30015DA for ; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8682080FEB; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4B3E3113274F; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:39 +0200 Message-Id: <20181017082702.5581-16-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 17 Oct 2018 08:27:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 15/38] numa: Fix QMP command set-numa-node error handling 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. parse_numa_node() does that, and then exit()s. It also passes &error_fatal to machine_set_cpu_numa_node(). Both wrong. Attempting to configure numa when the machine doesn't support it kills the VM: $ qemu-system-x86_64 -nodefaults -S -display none -M none -preconfig -q= mp stdio {"QMP": {"version": {"qemu": {"micro": 50, "minor": 0, "major": 3}, "pa= ckage": "v3.0.0-837-gc5e4e49258"}, "capabilities": []}} {"execute": "qmp_capabilities"} {"return": {}} {"execute": "set-numa-node", "arguments": {"type": "node"}} NUMA is not supported by this machine-type $ echo $? 1 Messed up when commit 64c2a8f6d3f and 7c88e65d9e9 (v2.10.0) added incorrect error handling right next to correct examples. Latent bug until commit f3be67812c2 (v3.0.0) made it accessible via QMP. Fairly harmless in practice, because it's limited to RUN_STATE_PRECONFIG. The fix is obvious: replace error_report(); exit() by error_setg(); return. This affects parse_numa_node()'s other caller numa_complete_configuration(): since it ignores errors, the "NUMA is not supported by this machine-type" is now ignored, too. But that error is as unexpected there as any other. Change it to abort on error instead. Fixes: f3be67812c226162f86ce92634bd913714445420 Cc: Igor Mammedov Signed-off-by: Markus Armbruster Reviewed-by: Igor Mammedov --- numa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/numa.c b/numa.c index 81542d4ebb..1d7c49ad43 100644 --- a/numa.c +++ b/numa.c @@ -60,6 +60,7 @@ NodeInfo numa_info[MAX_NODES]; static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, Error **errp) { + Error *err =3D NULL; uint16_t nodenr; uint16List *cpus =3D NULL; MachineClass *mc =3D MACHINE_GET_CLASS(ms); @@ -82,8 +83,8 @@ static void parse_numa_node(MachineState *ms, NumaNodeOpt= ions *node, } =20 if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) { - error_report("NUMA is not supported by this machine-type"); - exit(1); + error_setg(errp, "NUMA is not supported by this machine-type"); + return; } for (cpus =3D node->cpus; cpus; cpus =3D cpus->next) { CpuInstanceProperties props; @@ -97,7 +98,11 @@ static void parse_numa_node(MachineState *ms, NumaNodeOp= tions *node, props =3D mc->cpu_index_to_instance_props(ms, cpus->value); props.node_id =3D nodenr; props.has_node_id =3D true; - machine_set_cpu_numa_node(ms, &props, &error_fatal); + machine_set_cpu_numa_node(ms, &props, &err); + if (err) { + error_propagate(errp, err); + return; + } } =20 if (node->has_mem && node->has_memdev) { @@ -367,7 +372,7 @@ void numa_complete_configuration(MachineState *ms) if (ms->ram_slots > 0 && nb_numa_nodes =3D=3D 0 && mc->auto_enable_numa_with_memhp) { NumaNodeOptions node =3D { }; - parse_numa_node(ms, &node, NULL); + parse_numa_node(ms, &node, &error_abort); } =20 assert(max_numa_nodeid <=3D MAX_NODES); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765314814971.969803121009; Wed, 17 Oct 2018 01:35:14 -0700 (PDT) Received: from localhost ([::1]:34534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChIP-0006PY-G2 for importer@patchew.org; Wed, 17 Oct 2018 04:35:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAd-000863-Dj for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAb-00014U-As for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAb-00011d-2Y for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7DC0690D; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F1575F7C6; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4EE0E1132751; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:40 +0200 Message-Id: <20181017082702.5581-17-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 17 Oct 2018 08:27:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 16/38] xen/pt: Fix incomplete conversion to realize() 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: Anthony Perard , Stefano Stabellini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The conversion of "xen-pci-passthrough" to realize() (commit 5a11d0f7549, v2.6.0) neglected to convert the xen_pt_config_init() error path. If xen_pt_config_init() fails, xen_pt_realize() reports the error, then returns success without completing its job. I don't know the exact impact, but it can't be good. Belatedly convert the error path. Fixes: 5a11d0f7549e24a10e178a9dc8ff5e698031d9a6 Cc: Stefano Stabellini Cc: Anthony Perard Signed-off-by: Markus Armbruster Acked-by: Anthony PERARD --- hw/xen/xen_pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index e5a6eff44f..f1f3a3727c 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -830,7 +830,7 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) xen_pt_config_init(s, &err); if (err) { error_append_hint(&err, "PCI Config space initialisation failed"); - error_report_err(err); + error_propagate(errp, err); rc =3D -1; goto err_out; } --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539767294554229.31561455794656; Wed, 17 Oct 2018 02:08:14 -0700 (PDT) Received: from localhost ([::1]:34742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChoG-000134-U9 for importer@patchew.org; Wed, 17 Oct 2018 05:08:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Ks-TC for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB2-0001zB-Eb for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB2-0001Vx-0F for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D359D307D858 for ; Wed, 17 Oct 2018 08:27:21 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB66C19E2C; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 526D011415DD; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:41 +0200 Message-Id: <20181017082702.5581-18-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 17 Oct 2018 08:27:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 17/38] seccomp: Clean up error reporting in parse_sandbox() 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: Eduardo Otubo Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. parse_sandbox() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Eduardo Otubo Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Acked-by: Eduardo Otubo --- qemu-seccomp.c | 18 +++++++++--------- vl.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/qemu-seccomp.c b/qemu-seccomp.c index 1baa5c69ed..5c73e6ad05 100644 --- a/qemu-seccomp.c +++ b/qemu-seccomp.c @@ -12,11 +12,12 @@ * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ + #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/module.h" -#include "qemu/error-report.h" #include #include #include "sysemu/seccomp.h" @@ -190,7 +191,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error *= *errp) * to provide a little bit of consistency for * the command line */ } else { - error_report("invalid argument for obsolete"); + error_setg(errp, "invalid argument for obsolete"); return -1; } } @@ -205,14 +206,13 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error= **errp) /* calling prctl directly because we're * not sure if host has CAP_SYS_ADMIN set*/ if (prctl(PR_SET_NO_NEW_PRIVS, 1)) { - error_report("failed to set no_new_privs " - "aborting"); + error_setg(errp, "failed to set no_new_privs aborting"= ); return -1; } } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for elevateprivileges"); + error_setg(errp, "invalid argument for elevateprivileges"); return -1; } } @@ -224,7 +224,7 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error *= *errp) } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for spawn"); + error_setg(errp, "invalid argument for spawn"); return -1; } } @@ -236,14 +236,14 @@ int parse_sandbox(void *opaque, QemuOpts *opts, Error= **errp) } else if (g_str_equal(value, "allow")) { /* default value */ } else { - error_report("invalid argument for resourcecontrol"); + error_setg(errp, "invalid argument for resourcecontrol"); return -1; } } =20 if (seccomp_start(seccomp_opts) < 0) { - error_report("failed to install seccomp syscall filter " - "in the kernel"); + error_setg(errp, "failed to install seccomp syscall filter " + "in the kernel"); return -1; } } diff --git a/vl.c b/vl.c index ff50199e64..643121e5d4 100644 --- a/vl.c +++ b/vl.c @@ -3972,8 +3972,8 @@ int main(int argc, char **argv, char **envp) =20 #ifdef CONFIG_SECCOMP olist =3D qemu_find_opts_err("sandbox", NULL); - if (olist && qemu_opts_foreach(olist, parse_sandbox, NULL, NULL)) { - exit(1); + if (olist) { + qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal); } #endif =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765274217148.50745930232097; Wed, 17 Oct 2018 01:34:34 -0700 (PDT) Received: from localhost ([::1]:34533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChHk-0005ww-EW for importer@patchew.org; Wed, 17 Oct 2018 04:34:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAd-000860-8U for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAb-00015a-RF for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAb-00011h-At for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E280A80F6D for ; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADD981057054 for ; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 560EE114168F; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:42 +0200 Message-Id: <20181017082702.5581-19-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Oct 2018 08:27:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 18/38] vl: Clean up error reporting in parse_add_fd() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. parse_add_fd() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Also change call of cleanup_add_fd(), which can't fail, for symmetry. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/vl.c b/vl.c index 643121e5d4..2ef066ad61 100644 --- a/vl.c +++ b/vl.c @@ -1059,12 +1059,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opt= s, Error **errp) fd_opaque =3D qemu_opt_get(opts, "opaque"); =20 if (fd < 0) { - error_report("fd option is required and must be non-negative"); + error_setg(errp, "fd option is required and must be non-negative"); return -1; } =20 if (fd <=3D STDERR_FILENO) { - error_report("fd cannot be a standard I/O stream"); + error_setg(errp, "fd cannot be a standard I/O stream"); return -1; } =20 @@ -1074,12 +1074,12 @@ static int parse_add_fd(void *opaque, QemuOpts *opt= s, Error **errp) */ flags =3D fcntl(fd, F_GETFD); if (flags =3D=3D -1 || (flags & FD_CLOEXEC)) { - error_report("fd is not valid or already in use"); + error_setg(errp, "fd is not valid or already in use"); return -1; } =20 if (fdset_id < 0) { - error_report("set option is required and must be non-negative"); + error_setg(errp, "set option is required and must be non-negative"= ); return -1; } =20 @@ -1092,7 +1092,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts,= Error **errp) } #endif if (dupfd =3D=3D -1) { - error_report("error duplicating fd: %s", strerror(errno)); + error_setg(errp, "error duplicating fd: %s", strerror(errno)); return -1; } =20 @@ -3983,15 +3983,11 @@ int main(int argc, char **argv, char **envp) } =20 #ifndef _WIN32 - if (qemu_opts_foreach(qemu_find_opts("add-fd"), - parse_add_fd, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("add-fd"), + parse_add_fd, NULL, &error_fatal); =20 - if (qemu_opts_foreach(qemu_find_opts("add-fd"), - cleanup_add_fd, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("add-fd"), + cleanup_add_fd, NULL, &error_fatal); #endif =20 current_machine =3D MACHINE(object_new(object_class_get_name( --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766623988382.5056803376501; Wed, 17 Oct 2018 01:57:03 -0700 (PDT) Received: from localhost ([::1]:34655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChdP-0007zW-CZ for importer@patchew.org; Wed, 17 Oct 2018 04:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H2-0t for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-00016u-M0 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44094) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00013w-36 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B58118125C for ; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 57D3343FFC; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 59C6B1142039; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:43 +0200 Message-Id: <20181017082702.5581-20-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 19/38] qom: Clean up error reporting in user_creatable_add_opts_foreach() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. user_creatable_add_opts_foreach() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- qemu-io.c | 8 +++----- qemu-nbd.c | 8 +++----- qom/object_interfaces.c | 4 +--- vl.c | 16 ++++++---------- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 13829f5e21..6df7731af4 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -620,11 +620,9 @@ int main(int argc, char **argv) exit(1); } =20 - if (qemu_opts_foreach(&qemu_object_opts, - user_creatable_add_opts_foreach, - NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(&qemu_object_opts, + user_creatable_add_opts_foreach, + NULL, &error_fatal); =20 if (!trace_init_backends()) { exit(1); diff --git a/qemu-nbd.c b/qemu-nbd.c index 7874bc973c..ca7109652e 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -766,11 +766,9 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - if (qemu_opts_foreach(&qemu_object_opts, - user_creatable_add_opts_foreach, - NULL, NULL)) { - exit(EXIT_FAILURE); - } + qemu_opts_foreach(&qemu_object_opts, + user_creatable_add_opts_foreach, + NULL, &error_fatal); =20 if (!trace_init_backends()) { exit(1); diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 941fd63afd..97b79b48bb 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -143,7 +143,6 @@ int user_creatable_add_opts_foreach(void *opaque, QemuO= pts *opts, Error **errp) { bool (*type_opt_predicate)(const char *, QemuOpts *) =3D opaque; Object *obj =3D NULL; - Error *err =3D NULL; const char *type; =20 type =3D qemu_opt_get(opts, "qom-type"); @@ -152,9 +151,8 @@ int user_creatable_add_opts_foreach(void *opaque, QemuO= pts *opts, Error **errp) return 0; } =20 - obj =3D user_creatable_add_opts(opts, &err); + obj =3D user_creatable_add_opts(opts, errp); if (!obj) { - error_report_err(err); return -1; } object_unref(obj); diff --git a/vl.c b/vl.c index 2ef066ad61..bb18f2d995 100644 --- a/vl.c +++ b/vl.c @@ -4228,11 +4228,9 @@ int main(int argc, char **argv, char **envp) page_size_init(); socket_init(); =20 - if (qemu_opts_foreach(qemu_find_opts("object"), - user_creatable_add_opts_foreach, - object_create_initial, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("object"), + user_creatable_add_opts_foreach, + object_create_initial, &error_fatal); =20 if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func, NULL, NULL)) { @@ -4363,11 +4361,9 @@ int main(int argc, char **argv, char **envp) exit(1); } =20 - if (qemu_opts_foreach(qemu_find_opts("object"), - user_creatable_add_opts_foreach, - object_create_delayed, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("object"), + user_creatable_add_opts_foreach, + object_create_delayed, &error_fatal); =20 if (tpm_init() < 0) { exit(1); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766277198941.5784639550056; Wed, 17 Oct 2018 01:51:17 -0700 (PDT) Received: from localhost ([::1]:34621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChXw-0002yT-2h for importer@patchew.org; Wed, 17 Oct 2018 04:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAl-0008Er-Dk for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-00016N-Aw for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAb-00013X-Vs for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 984D380F8F for ; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E8195DD79 for ; Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5D838114209D; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:44 +0200 Message-Id: <20181017082702.5581-21-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Oct 2018 08:27:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 20/38] vl: Clean up error reporting in chardev_init_func() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. chardev_init_func() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index bb18f2d995..aa03192019 100644 --- a/vl.c +++ b/vl.c @@ -2239,7 +2239,7 @@ static int chardev_init_func(void *opaque, QemuOpts *= opts, Error **errp) =20 if (!qemu_chr_new_from_opts(opts, &local_err)) { if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); return -1; } exit(0); @@ -4232,10 +4232,8 @@ int main(int argc, char **argv, char **envp) user_creatable_add_opts_foreach, object_create_initial, &error_fatal); =20 - if (qemu_opts_foreach(qemu_find_opts("chardev"), - chardev_init_func, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("chardev"), + chardev_init_func, NULL, &error_fatal); =20 #ifdef CONFIG_VIRTFS if (qemu_opts_foreach(qemu_find_opts("fsdev"), --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765540177651.5135610394799; Wed, 17 Oct 2018 01:39:00 -0700 (PDT) Received: from localhost ([::1]:34554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChM2-0001E1-Ow for importer@patchew.org; Wed, 17 Oct 2018 04:38:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H7-1E for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAc-00017L-Vs for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37594) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00014i-HD for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40B0F30001EA for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0701580FD1 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 60F1911420CE; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:45 +0200 Message-Id: <20181017082702.5581-22-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 21/38] vl: Clean up error reporting in machine_set_property() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. machine_set_property() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index aa03192019..c3c17106bf 100644 --- a/vl.c +++ b/vl.c @@ -2676,7 +2676,7 @@ static int machine_set_property(void *opaque, g_free(qom_name); =20 if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); return -1; } =20 @@ -4248,11 +4248,8 @@ int main(int argc, char **argv, char **envp) } =20 machine_opts =3D qemu_get_machine_opts(); - if (qemu_opt_foreach(machine_opts, machine_set_property, current_machi= ne, - NULL)) { - object_unref(OBJECT(current_machine)); - exit(1); - } + qemu_opt_foreach(machine_opts, machine_set_property, current_machine, + &error_fatal); =20 configure_accelerator(current_machine); =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765644170593.5555236801654; Wed, 17 Oct 2018 01:40:44 -0700 (PDT) Received: from localhost ([::1]:34568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChNi-0002eO-Vp for importer@patchew.org; Wed, 17 Oct 2018 04:40:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H0-0f for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAd-00017p-5Y for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00014j-IR for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44F7474867 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14BF85DD79 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 647F4114D2E7; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:46 +0200 Message-Id: <20181017082702.5581-23-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 22/38] vl: Clean up error reporting in mon_init_func() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. mon_init_func() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/vl.c b/vl.c index c3c17106bf..cd8e8a6586 100644 --- a/vl.c +++ b/vl.c @@ -2270,8 +2270,8 @@ static int mon_init_func(void *opaque, QemuOpts *opts= , Error **errp) } else if (strcmp(mode, "control") =3D=3D 0) { flags =3D MONITOR_USE_CONTROL; } else { - error_report("unknown monitor mode \"%s\"", mode); - exit(1); + error_setg(errp, "unknown monitor mode \"%s\"", mode); + return -1; } =20 if (qemu_opt_get_bool(opts, "pretty", 0)) @@ -2285,8 +2285,8 @@ static int mon_init_func(void *opaque, QemuOpts *opts= , Error **errp) chardev =3D qemu_opt_get(opts, "chardev"); chr =3D qemu_chr_find(chardev); if (chr =3D=3D NULL) { - error_report("chardev \"%s\" not found", chardev); - exit(1); + error_setg(errp, "chardev \"%s\" not found", chardev); + return -1; } =20 monitor_init(chr, flags); @@ -4412,10 +4412,8 @@ int main(int argc, char **argv, char **envp) default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS); default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS); =20 - if (qemu_opts_foreach(qemu_find_opts("mon"), - mon_init_func, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("mon"), + mon_init_func, NULL, &error_fatal); =20 if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) exit(1); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766781639586.4896441252419; Wed, 17 Oct 2018 01:59:41 -0700 (PDT) Received: from localhost ([::1]:34670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChg4-0002Xf-4u for importer@patchew.org; Wed, 17 Oct 2018 04:59:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H3-12 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAd-00018x-Eg for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41209) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00014q-S9 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E80230C9EE8 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 286C65DD95 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6804F1153BCB; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:47 +0200 Message-Id: <20181017082702.5581-24-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 23/38] vl: Clean up error reporting in parse_fw_cfg() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. parse_fw_cfg() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- vl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vl.c b/vl.c index cd8e8a6586..c5bc54f72b 100644 --- a/vl.c +++ b/vl.c @@ -2174,7 +2174,7 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts,= Error **errp) FWCfgState *fw_cfg =3D (FWCfgState *) opaque; =20 if (fw_cfg =3D=3D NULL) { - error_report("fw_cfg device not available"); + error_setg(errp, "fw_cfg device not available"); return -1; } name =3D qemu_opt_get(opts, "name"); @@ -2183,15 +2183,16 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opt= s, Error **errp) =20 /* we need name and either a file or the content string */ if (!(nonempty_str(name) && (nonempty_str(file) || nonempty_str(str)))= ) { - error_report("invalid argument(s)"); + error_setg(errp, "invalid argument(s)"); return -1; } if (nonempty_str(file) && nonempty_str(str)) { - error_report("file and string are mutually exclusive"); + error_setg(errp, "file and string are mutually exclusive"); return -1; } if (strlen(name) > FW_CFG_MAX_FILE_PATH - 1) { - error_report("name too long (max. %d char)", FW_CFG_MAX_FILE_PATH = - 1); + error_setg(errp, "name too long (max. %d char)", + FW_CFG_MAX_FILE_PATH - 1); return -1; } if (strncmp(name, "opt/", 4) !=3D 0) { @@ -2203,7 +2204,7 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts,= Error **errp) buf =3D g_memdup(str, size); } else { if (!g_file_get_contents(file, &buf, &size, NULL)) { - error_report("can't load %s", file); + error_setg(errp, "can't load %s", file); return -1; } } @@ -4476,10 +4477,8 @@ int main(int argc, char **argv, char **envp) hax_sync_vcpus(); } =20 - if (qemu_opts_foreach(qemu_find_opts("fw_cfg"), - parse_fw_cfg, fw_cfg_find(), NULL) !=3D 0) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("fw_cfg"), + parse_fw_cfg, fw_cfg_find(), &error_fatal); =20 /* init USB devices */ if (machine_usb(current_machine)) { --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765498737113.35769602066466; Wed, 17 Oct 2018 01:38:18 -0700 (PDT) Received: from localhost ([::1]:34553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChLL-0000l3-TK for importer@patchew.org; Wed, 17 Oct 2018 04:38:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008Gy-0Q for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAd-00018W-BO for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18323) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAc-00014o-LC for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56A36DF879 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23DBF7898F for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6B9681156105; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:48 +0200 Message-Id: <20181017082702.5581-25-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 24/38] vl: Clean up error reporting in device_init_func() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. device_init_func() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index c5bc54f72b..c053117028 100644 --- a/vl.c +++ b/vl.c @@ -2222,12 +2222,10 @@ static int device_help_func(void *opaque, QemuOpts = *opts, Error **errp) =20 static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) { - Error *err =3D NULL; DeviceState *dev; =20 - dev =3D qdev_device_add(opts, &err); + dev =3D qdev_device_add(opts, errp); if (!dev) { - error_report_err(err); return -1; } object_unref(OBJECT(dev)); @@ -4491,10 +4489,8 @@ int main(int argc, char **argv, char **envp) =20 /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); - if (qemu_opts_foreach(qemu_find_opts("device"), - device_init_func, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("device"), + device_init_func, NULL, &error_fatal); =20 cpu_synchronize_all_post_init(); =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539767147182278.8995120707722; Wed, 17 Oct 2018 02:05:47 -0700 (PDT) Received: from localhost ([::1]:34724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChlx-0007Ko-Lj for importer@patchew.org; Wed, 17 Oct 2018 05:05:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Kv-Ue for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB1-0001x0-Gm for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33522) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAx-0001G0-Tv for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53F4B30832E9 for ; Wed, 17 Oct 2018 08:27:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E7E578980; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6F0D011562E4; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:49 +0200 Message-Id: <20181017082702.5581-26-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 08:27:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 25/38] ui/keymaps: Fix handling of erroneous include files 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" While errors in the keyboard layout named with -k are fatal, errors in included files are reported, but otherwise ignored: $ cat worst include bad include worse $ ls -l bad worse ls: cannot access 'bad': No such file or directory ls: cannot access 'worse': No such file or directory $ qemu-system-x86_64 -nodefaults -S -monitor stdio -display vnc=3D:0 -k= bad QEMU 3.0.50 monitor - type 'help' for more information (qemu) Could not read keymap file: 'bad' $ qemu-system-x86_64 -nodefaults -S -monitor stdio -display vnc=3D:0 -k= worst QEMU 3.0.50 monitor - type 'help' for more information (qemu) Could not read keymap file: 'bad' Could not read keymap file: 'worse' Fix that. Note that parse_keyboard_layout() allocates the keymap, except when it's parsing an include file. To keep error handling simple, move the memory management to its caller init_keyboard_layout(). Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster --- ui/keymaps.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/ui/keymaps.c b/ui/keymaps.c index 43fe604724..b05fb028dc 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -79,10 +79,11 @@ static void add_keysym(char *line, int keysym, int keyc= ode, kbd_layout_t *k) trace_keymap_add(keysym, keycode, line); } =20 -static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table, - const char *language, - kbd_layout_t *k) +static int parse_keyboard_layout(kbd_layout_t *k, + const name2keysym_t *table, + const char *language) { + int ret; FILE *f; char * filename; char line[1024]; @@ -95,12 +96,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2ke= ysym_t *table, g_free(filename); if (!f) { fprintf(stderr, "Could not read keymap file: '%s'\n", language); - return NULL; - } - - if (!k) { - k =3D g_new0(kbd_layout_t, 1); - k->hash =3D g_hash_table_new(NULL, NULL); + return -1; } =20 for(;;) { @@ -118,7 +114,10 @@ static kbd_layout_t *parse_keyboard_layout(const name2= keysym_t *table, continue; } if (!strncmp(line, "include ", 8)) { - parse_keyboard_layout(table, line + 8, k); + if (parse_keyboard_layout(k, table, line + 8) < 0) { + ret =3D -1; + goto out; + } } else { int offset =3D 0; while (line[offset] !=3D 0 && @@ -164,15 +163,27 @@ static kbd_layout_t *parse_keyboard_layout(const name= 2keysym_t *table, } } } + + ret =3D 0; +out: fclose(f); - return k; + return ret; } =20 =20 kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, const char *language) { - return parse_keyboard_layout(table, language, NULL); + kbd_layout_t *k; + + k =3D g_new0(kbd_layout_t, 1); + k->hash =3D g_hash_table_new(NULL, NULL); + if (parse_keyboard_layout(k, table, language) < 0) { + g_hash_table_unref(k->hash); + g_free(k); + return NULL; + } + return k; } =20 =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 153976625337524.68467488338581; Wed, 17 Oct 2018 01:50:53 -0700 (PDT) Received: from localhost ([::1]:34612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChXE-0002Lx-O4 for importer@patchew.org; Wed, 17 Oct 2018 04:50:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Ky-Uz for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB2-0001zP-O7 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB2-0001GQ-8V for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B6EB30020A0; Wed, 17 Oct 2018 08:27:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3383478981; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 728CC11562E9; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:50 +0200 Message-Id: <20181017082702.5581-27-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 17 Oct 2018 08:27:14 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 26/38] ui: Convert vnc_display_init(), init_keyboard_layout() to Error 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: Fei Li , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Fei Li Signed-off-by: Fei Li Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/console.h | 2 +- ui/curses.c | 6 +++--- ui/keymaps.c | 11 ++++++----- ui/keymaps.h | 2 +- ui/sdl.c | 6 +++--- ui/vnc.c | 15 ++++++++++----- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index fb969caf70..c17803c530 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -453,7 +453,7 @@ void qemu_display_early_init(DisplayOptions *opts); void qemu_display_init(DisplayState *ds, DisplayOptions *opts); =20 /* vnc.c */ -void vnc_display_init(const char *id); +void vnc_display_init(const char *id, Error **errp); void vnc_display_open(const char *id, Error **errp); void vnc_display_add_client(const char *id, int csock, bool skipauth); int vnc_display_password(const char *id, const char *password); diff --git a/ui/curses.c b/ui/curses.c index 59d819fd4d..f4e7a12f74 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -28,6 +28,7 @@ #include #endif =20 +#include "qapi/error.h" #include "qemu-common.h" #include "ui/console.h" #include "ui/input.h" @@ -421,9 +422,8 @@ static void curses_keyboard_setup(void) keyboard_layout =3D "en-us"; #endif if(keyboard_layout) { - kbd_layout =3D init_keyboard_layout(name2keysym, keyboard_layout); - if (!kbd_layout) - exit(1); + kbd_layout =3D init_keyboard_layout(name2keysym, keyboard_layout, + &error_fatal); } } =20 diff --git a/ui/keymaps.c b/ui/keymaps.c index b05fb028dc..085889b555 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -27,6 +27,7 @@ #include "sysemu/sysemu.h" #include "trace.h" #include "qemu/error-report.h" +#include "qapi/error.h" =20 struct keysym2code { uint32_t count; @@ -81,7 +82,7 @@ static void add_keysym(char *line, int keysym, int keycod= e, kbd_layout_t *k) =20 static int parse_keyboard_layout(kbd_layout_t *k, const name2keysym_t *table, - const char *language) + const char *language, Error **errp) { int ret; FILE *f; @@ -95,7 +96,7 @@ static int parse_keyboard_layout(kbd_layout_t *k, f =3D filename ? fopen(filename, "r") : NULL; g_free(filename); if (!f) { - fprintf(stderr, "Could not read keymap file: '%s'\n", language); + error_setg(errp, "could not read keymap file: '%s'", language); return -1; } =20 @@ -114,7 +115,7 @@ static int parse_keyboard_layout(kbd_layout_t *k, continue; } if (!strncmp(line, "include ", 8)) { - if (parse_keyboard_layout(k, table, line + 8) < 0) { + if (parse_keyboard_layout(k, table, line + 8, errp) < 0) { ret =3D -1; goto out; } @@ -172,13 +173,13 @@ out: =20 =20 kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, - const char *language) + const char *language, Error **errp) { kbd_layout_t *k; =20 k =3D g_new0(kbd_layout_t, 1); k->hash =3D g_hash_table_new(NULL, NULL); - if (parse_keyboard_layout(k, table, language) < 0) { + if (parse_keyboard_layout(k, table, language, errp) < 0) { g_hash_table_unref(k->hash); g_free(k); return NULL; diff --git a/ui/keymaps.h b/ui/keymaps.h index 0693588225..98213a4191 100644 --- a/ui/keymaps.h +++ b/ui/keymaps.h @@ -53,7 +53,7 @@ typedef struct { typedef struct kbd_layout_t kbd_layout_t; =20 kbd_layout_t *init_keyboard_layout(const name2keysym_t *table, - const char *language); + const char *language, Error **errp); int keysym2scancode(kbd_layout_t *k, int keysym, bool shift, bool altgr, bool ctrl); int keycode_is_keypad(kbd_layout_t *k, int keycode); diff --git a/ui/sdl.c b/ui/sdl.c index a5fd503c25..190b16f575 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -29,6 +29,7 @@ #include #include =20 +#include "qapi/error.h" #include "qemu-common.h" #include "qemu/cutils.h" #include "ui/console.h" @@ -917,9 +918,8 @@ static void sdl1_display_init(DisplayState *ds, Display= Options *o) keyboard_layout =3D "en-us"; #endif if(keyboard_layout) { - kbd_layout =3D init_keyboard_layout(name2keysym, keyboard_layout); - if (!kbd_layout) - exit(1); + kbd_layout =3D init_keyboard_layout(name2keysym, keyboard_layout, + &error_fatal); } =20 g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be remov= ed\n" diff --git a/ui/vnc.c b/ui/vnc.c index cf221c83cc..98e3d3b1d8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3205,7 +3205,7 @@ static const DisplayChangeListenerOps dcl_ops =3D { .dpy_cursor_define =3D vnc_dpy_cursor_define, }; =20 -void vnc_display_init(const char *id) +void vnc_display_init(const char *id, Error **errp) { VncDisplay *vd; =20 @@ -3222,13 +3222,14 @@ void vnc_display_init(const char *id) =20 if (keyboard_layout) { trace_vnc_key_map_init(keyboard_layout); - vd->kbd_layout =3D init_keyboard_layout(name2keysym, keyboard_layo= ut); + vd->kbd_layout =3D init_keyboard_layout(name2keysym, + keyboard_layout, errp); } else { - vd->kbd_layout =3D init_keyboard_layout(name2keysym, "en-us"); + vd->kbd_layout =3D init_keyboard_layout(name2keysym, "en-us", errp= ); } =20 if (!vd->kbd_layout) { - exit(1); + return; } =20 vd->share_policy =3D VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; @@ -4079,7 +4080,11 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Erro= r **errp) char *id =3D (char *)qemu_opts_id(opts); =20 assert(id); - vnc_display_init(id); + vnc_display_init(id, &local_err); + if (local_err) { + error_report_err(local_err); + exit(1); + } vnc_display_open(id, &local_err); if (local_err !=3D NULL) { error_reportf_err(local_err, "Failed to start VNC server: "); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766452534680.8747858326565; Wed, 17 Oct 2018 01:54:12 -0700 (PDT) Received: from localhost ([::1]:34634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChal-0005WG-8r for importer@patchew.org; Wed, 17 Oct 2018 04:54:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H1-0l for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAd-00019Q-KU for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAd-00015S-1X for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86420155DB for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 438435F7C5; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7618311562F4; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:51 +0200 Message-Id: <20181017082702.5581-28-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 27/38] vnc: Clean up error reporting in vnc_init_func() 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. vnc_init_func() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. While there, drop a "Failed to start VNC server: " error message prefix that doesn't really add value. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/vnc.c | 8 ++++---- vl.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 98e3d3b1d8..0c1b477425 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -4082,13 +4082,13 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Err= or **errp) assert(id); vnc_display_init(id, &local_err); if (local_err) { - error_report_err(local_err); - exit(1); + error_propagate(errp, local_err); + return -1; } vnc_display_open(id, &local_err); if (local_err !=3D NULL) { - error_reportf_err(local_err, "Failed to start VNC server: "); - exit(1); + error_propagate(errp, local_err); + return -1; } return 0; } diff --git a/vl.c b/vl.c index c053117028..8e0006d49c 100644 --- a/vl.c +++ b/vl.c @@ -4526,7 +4526,7 @@ int main(int argc, char **argv, char **envp) /* init remote displays */ #ifdef CONFIG_VNC qemu_opts_foreach(qemu_find_opts("vnc"), - vnc_init_func, NULL, NULL); + vnc_init_func, NULL, &error_fatal); #endif =20 if (using_spice) { --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766977330278.8633024047841; Wed, 17 Oct 2018 02:02:57 -0700 (PDT) Received: from localhost ([::1]:34706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChj3-0004xh-3d for importer@patchew.org; Wed, 17 Oct 2018 05:02:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008H6-1A for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAd-00019g-RD for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAd-00015U-7O for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F10981F0D for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49BF0BA92; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 799AB1156355; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:52 +0200 Message-Id: <20181017082702.5581-29-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Oct 2018 08:27:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 28/38] numa: Clean up error reporting in parse_numa() 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: Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. parse_numa() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. While there, give parse_numa() internal linkage. Cc: Eduardo Habkost Signed-off-by: Markus Armbruster Reviewed-by: Eduardo Habkost --- include/sysemu/numa.h | 1 - numa.c | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 7a0ae751aa..21713b7e2f 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -22,7 +22,6 @@ struct NumaNodeMem { }; =20 extern NodeInfo numa_info[MAX_NODES]; -int parse_numa(void *opaque, QemuOpts *opts, Error **errp); void parse_numa_opts(MachineState *ms); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[]); diff --git a/numa.c b/numa.c index 1d7c49ad43..50ec016013 100644 --- a/numa.c +++ b/numa.c @@ -215,7 +215,7 @@ end: error_propagate(errp, err); } =20 -int parse_numa(void *opaque, QemuOpts *opts, Error **errp) +static int parse_numa(void *opaque, QemuOpts *opts, Error **errp) { NumaOptions *object =3D NULL; MachineState *ms =3D MACHINE(opaque); @@ -239,7 +239,7 @@ int parse_numa(void *opaque, QemuOpts *opts, Error **er= rp) end: qapi_free_NumaOptions(object); if (err) { - error_report_err(err); + error_propagate(errp, err); return -1; } =20 @@ -444,9 +444,7 @@ void numa_complete_configuration(MachineState *ms) =20 void parse_numa_opts(MachineState *ms) { - if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, &error_fatal= ); } =20 void qmp_set_numa_node(NumaOptions *cmd, Error **errp) --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766264613938.933499878105; Wed, 17 Oct 2018 01:51:04 -0700 (PDT) Received: from localhost ([::1]:34619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChXj-0002lD-7r for importer@patchew.org; Wed, 17 Oct 2018 04:51:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAv-0008Py-AY for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAo-0001Wb-2R for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAe-00016c-66 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38277120DF; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC7C280FEB; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7D2A411564B6; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:53 +0200 Message-Id: <20181017082702.5581-30-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 29/38] tpm: Clean up error reporting in tpm_init_tpmdev() 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: Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. tpm_init_tpmdev() does that, and then fails without setting an error. Its caller main(), via tpm_init() and qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Stefan Berger Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- include/sysemu/tpm.h | 2 +- stubs/tpm.c | 3 +-- tpm.c | 22 +++++++++------------- vl.c | 4 +--- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h index 9ae1ab6da3..17a97ed77a 100644 --- a/include/sysemu/tpm.h +++ b/include/sysemu/tpm.h @@ -16,7 +16,7 @@ #include "qom/object.h" =20 int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); -int tpm_init(void); +void tpm_init(void); void tpm_cleanup(void); =20 typedef enum TPMVersion { diff --git a/stubs/tpm.c b/stubs/tpm.c index 6729bc8517..80939cd3db 100644 --- a/stubs/tpm.c +++ b/stubs/tpm.c @@ -9,9 +9,8 @@ #include "qapi/qapi-commands-tpm.h" #include "sysemu/tpm.h" =20 -int tpm_init(void) +void tpm_init(void) { - return 0; } =20 void tpm_cleanup(void) diff --git a/tpm.c b/tpm.c index 93031723ad..9c9e20bbb7 100644 --- a/tpm.c +++ b/tpm.c @@ -89,19 +89,19 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts,= Error **errp) int i; =20 if (!QLIST_EMPTY(&tpm_backends)) { - error_report("Only one TPM is allowed."); + error_setg(errp, "Only one TPM is allowed."); return 1; } =20 id =3D qemu_opts_id(opts); if (id =3D=3D NULL) { - error_report(QERR_MISSING_PARAMETER, "id"); + error_setg(errp, QERR_MISSING_PARAMETER, "id"); return 1; } =20 value =3D qemu_opt_get(opts, "type"); if (!value) { - error_report(QERR_MISSING_PARAMETER, "type"); + error_setg(errp, QERR_MISSING_PARAMETER, "type"); tpm_display_backend_drivers(); return 1; } @@ -109,8 +109,8 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts,= Error **errp) i =3D qapi_enum_parse(&TpmType_lookup, value, -1, NULL); be =3D i >=3D 0 ? tpm_be_find_by_type(i) : NULL; if (be =3D=3D NULL) { - error_report(QERR_INVALID_PARAMETER_VALUE, - "type", "a TPM backend type"); + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", + "a TPM backend type"); tpm_display_backend_drivers(); return 1; } @@ -118,7 +118,7 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts,= Error **errp) /* validate backend specific opts */ qemu_opts_validate(opts, be->opts, &local_err); if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); return 1; } =20 @@ -151,14 +151,10 @@ void tpm_cleanup(void) * Initialize the TPM. Process the tpmdev command line options describing = the * TPM backend. */ -int tpm_init(void) +void tpm_init(void) { - if (qemu_opts_foreach(qemu_find_opts("tpmdev"), - tpm_init_tpmdev, NULL, NULL)) { - return -1; - } - - return 0; + qemu_opts_foreach(qemu_find_opts("tpmdev"), + tpm_init_tpmdev, NULL, &error_fatal); } =20 /* diff --git a/vl.c b/vl.c index 8e0006d49c..abfe991ed6 100644 --- a/vl.c +++ b/vl.c @@ -4359,9 +4359,7 @@ int main(int argc, char **argv, char **envp) user_creatable_add_opts_foreach, object_create_delayed, &error_fatal); =20 - if (tpm_init() < 0) { - exit(1); - } + tpm_init(); =20 /* init the bluetooth world */ if (foreach_device_config(DEV_BT, bt_parse)) --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765676039191.3607458224118; Wed, 17 Oct 2018 01:41:16 -0700 (PDT) Received: from localhost ([::1]:34570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChOE-00038i-QK for importer@patchew.org; Wed, 17 Oct 2018 04:41:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAo-0008Gz-0m for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAe-00019s-0f for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAd-00016L-H1 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 152E93086258 for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBA4D5F7C5; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8162111564DC; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:54 +0200 Message-Id: <20181017082702.5581-31-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 30/38] spice: Clean up error reporting in add_channel() 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() in a function that takes an Error ** argument is suspicious. add_channel() does that, and then exit()s. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/spice-core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index a4fbbc3898..ebaae24643 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -597,9 +597,9 @@ static int add_channel(void *opaque, const char *name, = const char *value, if (strcmp(name, "tls-channel") =3D=3D 0) { int *tls_port =3D opaque; if (!*tls_port) { - error_report("spice: tried to setup tls-channel" - " without specifying a TLS port"); - exit(1); + error_setg(errp, "spice: tried to setup tls-channel" + " without specifying a TLS port"); + return -1; } security =3D SPICE_CHANNEL_SECURITY_SSL; } @@ -615,8 +615,9 @@ static int add_channel(void *opaque, const char *name, = const char *value, rc =3D spice_server_set_channel_security(spice_server, value, secu= rity); } if (rc !=3D 0) { - error_report("spice: failed to set channel security for %s", value= ); - exit(1); + error_setg(errp, "spice: failed to set channel security for %s", + value); + return -1; } return 0; } @@ -787,7 +788,7 @@ void qemu_spice_init(void) spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); =20 - qemu_opt_foreach(opts, add_channel, &tls_port, NULL); + qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal); =20 spice_server_set_name(spice_server, qemu_name); spice_server_set_uuid(spice_server, (unsigned char *)&qemu_uuid); --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766077990414.7689523082689; Wed, 17 Oct 2018 01:47:57 -0700 (PDT) Received: from localhost ([::1]:34602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChUi-0000K1-G5 for importer@patchew.org; Wed, 17 Oct 2018 04:47:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAz-0000BH-8I for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAw-0001ni-Qd for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44568) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAr-00016j-6R for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 497543082130; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAEE45F7C6; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 84FAE11565AA; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:55 +0200 Message-Id: <20181017082702.5581-32-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 31/38] fsdev: Clean up error reporting in qemu_fsdev_add() 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: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calling error_report() from within a function that takes an Error ** argument is suspicious. qemu_fsdev_add() does that, and its caller fsdev_init_func() then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Cc: Greg Kurz Signed-off-by: Markus Armbruster Acked-by: Greg Kurz --- fsdev/qemu-fsdev-dummy.c | 2 +- fsdev/qemu-fsdev.c | 12 +++++------- fsdev/qemu-fsdev.h | 2 +- hw/9pfs/xen-9p-backend.c | 7 ++++++- vl.c | 8 +++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 6dc0fbc4c4..489cd29081 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -15,7 +15,7 @@ #include "qemu/config-file.h" #include "qemu/module.h" =20 -int qemu_fsdev_add(QemuOpts *opts) +int qemu_fsdev_add(QemuOpts *opts, Error **errp) { return 0; } diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 8a4afbffbd..7a3b87cc9e 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -30,7 +30,7 @@ static FsDriverTable FsDrivers[] =3D { { .name =3D "proxy", .ops =3D &proxy_ops}, }; =20 -int qemu_fsdev_add(QemuOpts *opts) +int qemu_fsdev_add(QemuOpts *opts, Error **errp) { int i; struct FsDriverListEntry *fsle; @@ -38,10 +38,9 @@ int qemu_fsdev_add(QemuOpts *opts) const char *fsdriver =3D qemu_opt_get(opts, "fsdriver"); const char *writeout =3D qemu_opt_get(opts, "writeout"); bool ro =3D qemu_opt_get_bool(opts, "readonly", 0); - Error *local_err =3D NULL; =20 if (!fsdev_id) { - error_report("fsdev: No id specified"); + error_setg(errp, "fsdev: No id specified"); return -1; } =20 @@ -53,11 +52,11 @@ int qemu_fsdev_add(QemuOpts *opts) } =20 if (i =3D=3D ARRAY_SIZE(FsDrivers)) { - error_report("fsdev: fsdriver %s not found", fsdriver); + error_setg(errp, "fsdev: fsdriver %s not found", fsdriver); return -1; } } else { - error_report("fsdev: No fsdriver specified"); + error_setg(errp, "fsdev: No fsdriver specified"); return -1; } =20 @@ -76,8 +75,7 @@ int qemu_fsdev_add(QemuOpts *opts) } =20 if (fsle->fse.ops->parse_opts) { - if (fsle->fse.ops->parse_opts(opts, &fsle->fse, &local_err)) { - error_report_err(local_err); + if (fsle->fse.ops->parse_opts(opts, &fsle->fse, errp)) { g_free(fsle->fse.fsdev_id); g_free(fsle); return -1; diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 65e4b1cfab..d9716b4144 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -38,7 +38,7 @@ typedef struct FsDriverListEntry { QTAILQ_ENTRY(FsDriverListEntry) next; } FsDriverListEntry; =20 -int qemu_fsdev_add(QemuOpts *opts); +int qemu_fsdev_add(QemuOpts *opts, Error **errp); FsDriverEntry *get_fsdev_fsentry(char *id); extern FileOperations local_ops; extern FileOperations handle_ops; diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 6026780f95..3f54a21c76 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -14,6 +14,7 @@ #include "hw/9pfs/9p.h" #include "hw/xen/xen_backend.h" #include "hw/9pfs/xen-9pfs.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "fsdev/qemu-fsdev.h" @@ -355,6 +356,7 @@ static int xen_9pfs_free(struct XenDevice *xendev) =20 static int xen_9pfs_connect(struct XenDevice *xendev) { + Error *err =3D NULL; int i; Xen9pfsDev *xen_9pdev =3D container_of(xendev, Xen9pfsDev, xendev); V9fsState *s =3D &xen_9pdev->state; @@ -452,7 +454,10 @@ static int xen_9pfs_connect(struct XenDevice *xendev) qemu_opt_set(fsdev, "path", xen_9pdev->path, NULL); qemu_opt_set(fsdev, "security_model", xen_9pdev->security_model, NULL); qemu_opts_set_id(fsdev, s->fsconf.fsdev_id); - qemu_fsdev_add(fsdev); + qemu_fsdev_add(fsdev, &err); + if (err) { + error_report_err(err); + } v9fs_device_realize_common(s, &xen_9p_transport, NULL); =20 return 0; diff --git a/vl.c b/vl.c index abfe991ed6..2a8ef05aef 100644 --- a/vl.c +++ b/vl.c @@ -2249,7 +2249,7 @@ static int chardev_init_func(void *opaque, QemuOpts *= opts, Error **errp) #ifdef CONFIG_VIRTFS static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) { - return qemu_fsdev_add(opts); + return qemu_fsdev_add(opts, errp); } #endif =20 @@ -4235,10 +4235,8 @@ int main(int argc, char **argv, char **envp) chardev_init_func, NULL, &error_fatal); =20 #ifdef CONFIG_VIRTFS - if (qemu_opts_foreach(qemu_find_opts("fsdev"), - fsdev_init_func, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("fsdev"), + fsdev_init_func, NULL, &error_fatal); #endif =20 if (qemu_opts_foreach(qemu_find_opts("device"), --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766070888705.2629066540661; Wed, 17 Oct 2018 01:47:50 -0700 (PDT) Received: from localhost ([::1]:34601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChUb-0000Cr-Fu for importer@patchew.org; Wed, 17 Oct 2018 04:47:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAu-0008Mz-CI for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAl-0001PE-En for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAe-00017F-1N for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A934981DEC for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E107780FEC; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8885A110E7DB; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:56 +0200 Message-Id: <20181017082702.5581-33-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 32/38] vl: Assert drive_new() does not fail in default_drive() 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: Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If creating (empty) default drives fails, it's a bug. Therefore, assert() is more appropriate than exit(1). Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 2a8ef05aef..65366b961e 100644 --- a/vl.c +++ b/vl.c @@ -1156,9 +1156,7 @@ static void default_drive(int enable, int snapshot, B= lockInterfaceType type, } =20 dinfo =3D drive_new(opts, type); - if (!dinfo) { - exit(1); - } + assert(dinfo); dinfo->is_default =3D true; =20 } --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765864389615.2434914957787; Wed, 17 Oct 2018 01:44:24 -0700 (PDT) Received: from localhost ([::1]:34582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChR7-0005tR-SA for importer@patchew.org; Wed, 17 Oct 2018 04:44:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAu-0008My-CB for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAl-0001PN-Ez for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAd-00016p-Se for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DFD0317C40B for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAEF618763; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8C233110E7DC; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:57 +0200 Message-Id: <20181017082702.5581-34-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 33/38] blockdev: Convert drive_new() to Error 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: Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Calling error_report() from within a function that takes an Error ** argument is suspicious. drive_new() calls error_report() even though it can run within drive_init_func(), which takes an Error ** argument. drive_init_func()'s caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway: * Convert drive_new() to Error * Update add_init_drive() to report the error received from drive_new() * Make main() pass &error_fatal through qemu_opts_foreach(), drive_init_func() to drive_new() * Make default_drive() pass &error_abort through qemu_opts_foreach(), drive_init_func() to drive_new() Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- blockdev.c | 27 ++++++++++++++------------- device-hotplug.c | 5 ++++- include/sysemu/blockdev.h | 3 ++- vl.c | 8 ++++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/blockdev.c b/blockdev.c index a8755bd908..574adbcb7f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -759,7 +759,8 @@ QemuOptsList qemu_legacy_drive_opts =3D { }, }; =20 -DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_= type) +DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_= type, + Error **errp) { const char *value; BlockBackend *blk; @@ -808,7 +809,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, &local_err); if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); return NULL; } } @@ -819,7 +820,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) bool writethrough; =20 if (bdrv_parse_cache_mode(value, &flags, &writethrough) !=3D 0) { - error_report("invalid cache option"); + error_setg(errp, "invalid cache option"); return NULL; } =20 @@ -847,7 +848,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); goto fail; } =20 @@ -860,7 +861,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) media =3D MEDIA_CDROM; read_only =3D true; } else { - error_report("'%s' invalid media", value); + error_setg(errp, "'%s' invalid media", value); goto fail; } } @@ -885,7 +886,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) type++) { } if (type =3D=3D IF_COUNT) { - error_report("unsupported bus type '%s'", value); + error_setg(errp, "unsupported bus type '%s'", value); goto fail; } } else { @@ -902,7 +903,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) =20 if (index !=3D -1) { if (bus_id !=3D 0 || unit_id !=3D -1) { - error_report("index cannot be used with bus and unit"); + error_setg(errp, "index cannot be used with bus and unit"); goto fail; } bus_id =3D drive_index_to_bus_id(type, index); @@ -921,13 +922,13 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfa= ceType block_default_type) } =20 if (max_devs && unit_id >=3D max_devs) { - error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); + error_setg(errp, "unit %d too big (max is %d)", unit_id, max_devs = - 1); goto fail; } =20 if (drive_get(type, bus_id, unit_id) !=3D NULL) { - error_report("drive with bus=3D%d, unit=3D%d (index=3D%d) exists", - bus_id, unit_id, index); + error_setg(errp, "drive with bus=3D%d, unit=3D%d (index=3D%d) exis= ts", + bus_id, unit_id, index); goto fail; } =20 @@ -970,7 +971,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) if (werror !=3D NULL) { if (type !=3D IF_IDE && type !=3D IF_SCSI && type !=3D IF_VIRTIO && type !=3D IF_NONE) { - error_report("werror is not supported by this bus type"); + error_setg(errp, "werror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "werror", werror); @@ -980,7 +981,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) if (rerror !=3D NULL) { if (type !=3D IF_IDE && type !=3D IF_VIRTIO && type !=3D IF_SCSI && type !=3D IF_NONE) { - error_report("rerror is not supported by this bus type"); + error_setg(errp, "rerror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "rerror", rerror); @@ -991,7 +992,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterface= Type block_default_type) bs_opts =3D NULL; if (!blk) { if (local_err) { - error_report_err(local_err); + error_propagate(errp, local_err); } goto fail; } else { diff --git a/device-hotplug.c b/device-hotplug.c index cd427e2c76..6090d5f1e9 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -28,6 +28,7 @@ #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "qapi/qmp/qdict.h" +#include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "sysemu/sysemu.h" @@ -36,6 +37,7 @@ =20 static DriveInfo *add_init_drive(const char *optstr) { + Error *err =3D NULL; DriveInfo *dinfo; QemuOpts *opts; MachineClass *mc; @@ -45,8 +47,9 @@ static DriveInfo *add_init_drive(const char *optstr) return NULL; =20 mc =3D MACHINE_GET_CLASS(current_machine); - dinfo =3D drive_new(opts, mc->block_default_type); + dinfo =3D drive_new(opts, mc->block_default_type, &err); if (!dinfo) { + error_report_err(err); qemu_opts_del(opts); return NULL; } diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index 24954b94e0..d34c4920dc 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -54,7 +54,8 @@ DriveInfo *drive_get_next(BlockInterfaceType type); QemuOpts *drive_def(const char *optstr); QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, const char *optstr); -DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type); +DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, + Error **errp); =20 /* device-hotplug */ =20 diff --git a/vl.c b/vl.c index 65366b961e..22beca29d1 100644 --- a/vl.c +++ b/vl.c @@ -1129,7 +1129,7 @@ static int drive_init_func(void *opaque, QemuOpts *op= ts, Error **errp) { BlockInterfaceType *block_default_type =3D opaque; =20 - return drive_new(opts, *block_default_type) =3D=3D NULL; + return drive_new(opts, *block_default_type, errp) =3D=3D NULL; } =20 static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **err= p) @@ -1155,8 +1155,7 @@ static void default_drive(int enable, int snapshot, B= lockInterfaceType type, drive_enable_snapshot(NULL, opts, NULL); } =20 - dinfo =3D drive_new(opts, type); - assert(dinfo); + dinfo =3D drive_new(opts, type, &error_abort); dinfo->is_default =3D true; =20 } @@ -4396,7 +4395,8 @@ int main(int argc, char **argv, char **envp) NULL, NULL); } if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, - &machine_class->block_default_type, NULL)) { + &machine_class->block_default_type, &error_fatal= )) { + /* We printed help */ exit(1); } =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765890392916.7774705278366; Wed, 17 Oct 2018 01:44:50 -0700 (PDT) Received: from localhost ([::1]:34583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChRc-0006Gg-8l for importer@patchew.org; Wed, 17 Oct 2018 04:44:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAp-0008JW-Sz for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAe-00019z-3c for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37602) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAd-00016U-LM for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2687F308FEC3 for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7F5219E23 for ; Wed, 17 Oct 2018 08:27:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8FAF41162B5A; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:58 +0200 Message-Id: <20181017082702.5581-35-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 34/38] vl: Fix exit status for -drive format=help 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vl.c b/vl.c index 22beca29d1..89520d8007 100644 --- a/vl.c +++ b/vl.c @@ -4397,7 +4397,7 @@ int main(int argc, char **argv, char **envp) if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine_class->block_default_type, &error_fatal= )) { /* We printed help */ - exit(1); + exit(0); } =20 default_drive(default_cdrom, snapshot, machine_class->block_default_ty= pe, 2, --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539765713895748.7544091427849; Wed, 17 Oct 2018 01:41:53 -0700 (PDT) Received: from localhost ([::1]:34571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChOq-0003bz-HK for importer@patchew.org; Wed, 17 Oct 2018 04:41:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAw-0008Vz-PU for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAp-0001Yp-UO for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAg-00017H-7O for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:15 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABA9A30E4EB3 for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 703C75F7C5 for ; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 932871162B5D; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:26:59 +0200 Message-Id: <20181017082702.5581-36-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 35/38] vl: Simplify call of parse_name() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" main() checks for parse_name() failure even though it can't actually fail. That's okay. Simplify it to check by passing &error_fatal, like the other users of qemu_opts_foreach(). Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- vl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index 89520d8007..01d71371c2 100644 --- a/vl.c +++ b/vl.c @@ -3973,10 +3973,8 @@ int main(int argc, char **argv, char **envp) } #endif =20 - if (qemu_opts_foreach(qemu_find_opts("name"), - parse_name, NULL, NULL)) { - exit(1); - } + qemu_opts_foreach(qemu_find_opts("name"), + parse_name, NULL, &error_fatal); =20 #ifndef _WIN32 qemu_opts_foreach(qemu_find_opts("add-fd"), --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766275193540.9527219850455; Wed, 17 Oct 2018 01:51:15 -0700 (PDT) Received: from localhost ([::1]:34620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChXu-0002vv-39 for importer@patchew.org; Wed, 17 Oct 2018 04:51:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB1-0000Gb-Fd for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAx-0001qc-Q8 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30559) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAx-0001Fi-CD for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25A7467EC2 for ; Wed, 17 Oct 2018 08:27:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E7E35C22E; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 975DA1162B5E; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:27:00 +0200 Message-Id: <20181017082702.5581-37-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 17 Oct 2018 08:27:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 36/38] block: Clean up bdrv_img_create()'s error reporting 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: Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_img_create() takes an Error ** argument and uses it in the conventional way, except for one place: when qemu_opts_do_parse() fails, it first reports its error to stderr or the HMP monitor with error_report_err(), then error_setg()'s a generic error. When the caller reports that second error similarly, this produces two consecutive error messages on stderr or the HMP monitor. When the caller does something else with it, such as send it via QMP, the first error still goes to stderr or the HMP monitor. Fortunately, no such caller exists. Simply use the first error as is. Update expected output of qemu-iotest 049 accordingly. Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- block.c | 3 --- tests/qemu-iotests/049.out | 12 ++++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 5d51419d21..08d64cdc61 100644 --- a/block.c +++ b/block.c @@ -4803,9 +4803,6 @@ void bdrv_img_create(const char *filename, const char= *fmt, if (options) { qemu_opts_do_parse(opts, options, NULL, &local_err); if (local_err) { - error_report_err(local_err); - local_err =3D NULL; - error_setg(errp, "Invalid options for file format '%s'", fmt); goto out; } } diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 0871bff564..6b505408dd 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -95,35 +95,31 @@ qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1024 qemu-img: Image size must be less than 8 EiB! =20 qemu-img create -f qcow2 -o size=3D-1024 TEST_DIR/t.qcow2 -qemu-img: Value '-1024' is out of range for parameter 'size' -qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' +qemu-img: TEST_DIR/t.qcow2: Value '-1024' is out of range for parameter 's= ize' =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- -1k qemu-img: Image size must be less than 8 EiB! =20 qemu-img create -f qcow2 -o size=3D-1k TEST_DIR/t.qcow2 -qemu-img: Value '-1k' is out of range for parameter 'size' -qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' +qemu-img: TEST_DIR/t.qcow2: Value '-1k' is out of range for parameter 'siz= e' =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1kilobyte qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suf= fixes for qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabyt= es. =20 qemu-img create -f qcow2 -o size=3D1kilobyte TEST_DIR/t.qcow2 -qemu-img: Parameter 'size' expects a non-negative number below 2^64 +qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number= below 2^64 Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta- and exabytes, respectively. -qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- foobar qemu-img: Invalid image size specified! You may use k, M, G, T, P or E suf= fixes for qemu-img: kilobytes, megabytes, gigabytes, terabytes, petabytes and exabyt= es. =20 qemu-img create -f qcow2 -o size=3Dfoobar TEST_DIR/t.qcow2 -qemu-img: Parameter 'size' expects a non-negative number below 2^64 +qemu-img: TEST_DIR/t.qcow2: Parameter 'size' expects a non-negative number= below 2^64 Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta- and exabytes, respectively. -qemu-img: TEST_DIR/t.qcow2: Invalid options for file format 'qcow2' =20 =3D=3D Check correct interpretation of suffixes for cluster size =3D=3D =20 --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766416869468.88623938325975; Wed, 17 Oct 2018 01:53:36 -0700 (PDT) Received: from localhost ([::1]:34631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChaB-0004zz-Mk for importer@patchew.org; Wed, 17 Oct 2018 04:53:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChB4-0000Kx-Ux for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChB2-0001yf-5u for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChB1-00018X-N4 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24001D3C14 for ; Wed, 17 Oct 2018 08:27:11 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BCAE18763; Wed, 17 Oct 2018 08:27:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9B12C1162B62; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:27:01 +0200 Message-Id: <20181017082702.5581-38-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 17 Oct 2018 08:27:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 37/38] raw: Convert a warning to warn_report() 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: Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Convert the warning about dangerous automatic probing of raw images to warn_report(). Split its text to conform to conventions spelled out in warn_report()'s contract. Update expected output of qemu-iotest 109 accordingly. Update qemu-iotest 099's output filtering to keep filtering out the warning. Cc: Kevin Wolf Cc: Max Reitz Signed-off-by: Markus Armbruster --- block/raw-format.c | 17 ++++++------ tests/qemu-iotests/099 | 3 ++- tests/qemu-iotests/109.out | 55 +++++++++++++++++++++++--------------- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/block/raw-format.c b/block/raw-format.c index 6f6dc99b2c..d65fd0ffce 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -29,6 +29,7 @@ #include "qemu/osdep.h" #include "block/block_int.h" #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/option.h" =20 typedef struct BDRVRawState { @@ -436,14 +437,14 @@ static int raw_open(BlockDriverState *bs, QDict *opti= ons, int flags, bs->file->bs->supported_zero_flags); =20 if (bs->probed && !bdrv_is_read_only(bs)) { - fprintf(stderr, - "WARNING: Image format was not specified for '%s' and prob= ing " - "guessed raw.\n" - " Automatically detecting the format is dangerous = for " - "raw images, write operations on block 0 will be restricte= d.\n" - " Specify the 'raw' format explicitly to remove th= e " - "restrictions.\n", - bs->file->bs->filename); + warn_report("Image format was not specified for '%s' and probing " + "guessed raw", + bs->file->bs->filename); + error_printf("Automatically detecting the format is dangerous for " + "raw images, write\n" + "operations on block 0 will be restricted.\n" + "Specify the 'raw' format explicitly to remove the " + "restrictions.\n"); } =20 ret =3D raw_read_options(options, bs, s, errp); diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 index caaf58eee5..f2a62448d8 100755 --- a/tests/qemu-iotests/099 +++ b/tests/qemu-iotests/099 @@ -57,7 +57,8 @@ function run_qemu() # which is how we can extract it) do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_imgfmt | _filter_qmp= \ | _filter_qemu | grep "drv0" \ - | sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g' + | sed -e 's/^.*"file": "\(\(\\"\|[^"]\)*\)".*$/\1/' -e 's/\\"/"/g'= \ + -e '/probing guessed raw/d' } =20 function test_qemu() diff --git a/tests/qemu-iotests/109.out b/tests/qemu-iotests/109.out index ad0ee6fb48..99add53271 100644 --- a/tests/qemu-iotests/109.out +++ b/tests/qemu-iotests/109.out @@ -5,8 +5,9 @@ QA output created by 109 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -43,8 +44,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -81,8 +83,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -119,8 +122,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -157,8 +161,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -195,8 +200,9 @@ Images are identical. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Formatting 'TEST_DIR/t.raw.src', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -232,8 +238,9 @@ Images are identical. =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -269,8 +276,9 @@ Images are identical. =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -306,8 +314,9 @@ Images are identical. =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -343,8 +352,9 @@ Images are identical. =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} @@ -380,8 +390,9 @@ Images are identical. =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 {"return": {}} -WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw. - Automatically detecting the format is dangerous for raw images, w= rite operations on block 0 will be restricted. +warning: Image format was not specified for 'TEST_DIR/t.raw' and probing g= uessed raw +Automatically detecting the format is dangerous for raw images, write +operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "src"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "src"}} --=20 2.17.1 From nobody Thu Nov 6 01:29:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539766620079335.2621637507799; Wed, 17 Oct 2018 01:57:00 -0700 (PDT) Received: from localhost ([::1]:34654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChdP-0007wt-Dg for importer@patchew.org; Wed, 17 Oct 2018 04:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChFo-0004TS-Uk for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChFk-00077B-DN for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43494) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChFk-000767-6c for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 902B767EC2 for ; Wed, 17 Oct 2018 08:32:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C1B05DDFF; Wed, 17 Oct 2018 08:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9E9F51162B63; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:27:02 +0200 Message-Id: <20181017082702.5581-39-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 17 Oct 2018 08:32:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 38/38] vpc: Fail open on bad header checksum 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: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" vpc_open() merely prints a warning when it finds a bad header checksum. Turn that into a hard error. Cc: Kevin Wolf Signed-off-by: Markus Armbruster --- block/vpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index bf294abfa7..1729c0cb44 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -284,9 +284,11 @@ static int vpc_open(BlockDriverState *bs, QDict *optio= ns, int flags, =20 checksum =3D be32_to_cpu(footer->checksum); footer->checksum =3D 0; - if (vpc_checksum(s->footer_buf, HEADER_SIZE) !=3D checksum) - fprintf(stderr, "block-vpc: The header checksum of '%s' is " - "incorrect.\n", bs->filename); + if (vpc_checksum(s->footer_buf, HEADER_SIZE) !=3D checksum) { + error_setg(errp, "incorrect header checksum"); + ret =3D -EINVAL; + goto fail; + } =20 /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum =3D cpu_to_be32(checksum); --=20 2.17.1