From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com,
mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com,
gengdongjiu1@gmail.com, peter.maydell@linaro.org,
alistair@alistair23.me, edgar.iglesias@gmail.com,
npiggin@gmail.com, harshpb@linux.ibm.com, palmer@dabbelt.com,
liwei1518@gmail.com, dbarboza@ventanamicro.com,
zhiwei_liu@linux.alibaba.com, sstabellini@kernel.org,
anthony@xenproject.org, paul@xen.org, peterx@redhat.com,
farosas@suse.de, eblake@redhat.com, vsementsov@yandex-team.ru,
eduardo@habkost.net, marcel.apfelbaum@gmail.com,
philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com,
qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
qemu-riscv@nongnu.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH 5/5] error: Consistently name Error * objects err, and not errp
Date: Wed, 19 Nov 2025 13:35:32 +0000 [thread overview]
Message-ID: <aR3HpH88od11v8qL@redhat.com> (raw)
In-Reply-To: <3ffe11b9-db81-4930-aefa-e55d758645bf@citrix.com>
On Wed, Nov 19, 2025 at 01:22:06PM +0000, Andrew Cooper wrote:
> On 19/11/2025 1:08 pm, Markus Armbruster wrote:
> > diff --git a/hw/xen/xen-pvh-common.c b/hw/xen/xen-pvh-common.c
> > index b93ff80c85..3e62ec09d0 100644
> > --- a/hw/xen/xen-pvh-common.c
> > +++ b/hw/xen/xen-pvh-common.c
> > @@ -101,7 +101,7 @@ static void xen_create_virtio_mmio_devices(XenPVHMachineState *s)
> > #ifdef CONFIG_TPM
> > static void xen_enable_tpm(XenPVHMachineState *s)
> > {
> > - Error *errp = NULL;
> > + Error *err = NULL;
> > DeviceState *dev;
> > SysBusDevice *busdev;
> >
> > @@ -111,8 +111,15 @@ static void xen_enable_tpm(XenPVHMachineState *s)
> > return;
> > }
> > dev = qdev_new(TYPE_TPM_TIS_SYSBUS);
> > - object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &errp);
> > - object_property_set_str(OBJECT(dev), "tpmdev", be->id, &errp);
> > + /*
> > + * FIXME This use of &err is is wrong. If both calls fail, the
> > + * second will trip error_setv()'s assertion. If just one call
> > + * fails, we leak an Error object. Setting the same property
> > + * twice (first to a QOM path, then to an ID string) is almost
> > + * certainly wrong, too.
> > + */
> > + object_property_set_link(OBJECT(dev), "tpmdev", OBJECT(be), &err);
> > + object_property_set_str(OBJECT(dev), "tpmdev", be->id, &err);
>
> To your question, I don't know the answer, but I think it's far more
> likely that the original author didn't grok the proper use of &errp,
> than for this behaviour to be intentional.
>
> Surely we just want a failure path and abort the construction if this
> goes wrong?
In the caller of xen_enable_tpm, we just have error_report+exit calls,
so there's no error propagation ability in the call chain.
The caller will also skip xen_enable_tpm unless a TPM was explicitly
requested in the config.
Given that, I'm inclined to say that the object_property_set_* calls
in xen_enable_tpm should be using &error_abort, as a failure to setup
the explicitly requested TPM should be fatal.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-11-19 13:36 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 13:08 [PATCH 0/5] A bit of cleanup around Error Markus Armbruster
2025-11-19 13:08 ` [PATCH 1/5] hw/core/loader: Make load_elf_hdr() return bool, simplify caller Markus Armbruster
2025-11-19 15:37 ` Richard Henderson
2025-11-19 16:34 ` Vladimir Sementsov-Ogievskiy
2025-11-19 19:12 ` Markus Armbruster
2025-11-20 10:51 ` Philippe Mathieu-Daudé
2025-11-19 18:06 ` Peter Xu
2025-11-20 12:04 ` Daniel Henrique Barboza
2025-11-20 12:55 ` BALATON Zoltan
2025-11-20 19:12 ` Markus Armbruster
2025-11-20 14:53 ` Zhao Liu
2025-11-19 13:08 ` [PATCH 2/5] hw/nvram/xlnx-bbram: More idiomatic and simpler error reporting Markus Armbruster
2025-11-19 16:39 ` Vladimir Sementsov-Ogievskiy
2025-11-19 19:10 ` Markus Armbruster
2025-11-19 18:09 ` Peter Xu
2025-11-20 8:10 ` Luc Michel
2025-11-20 14:54 ` Zhao Liu
2025-11-19 13:08 ` [PATCH 3/5] nbd/client-connection: Replace error_propagate() by assignment Markus Armbruster
2025-11-19 16:43 ` Vladimir Sementsov-Ogievskiy
2025-11-19 18:09 ` Peter Xu
2025-11-20 14:55 ` Zhao Liu
2025-11-19 13:08 ` [PATCH 4/5] error: error_free(NULL) is safe, drop unnecessary conditionals Markus Armbruster
2025-11-19 15:38 ` Richard Henderson
2025-11-19 16:44 ` Vladimir Sementsov-Ogievskiy
2025-11-19 18:04 ` Peter Xu
2025-11-20 14:56 ` Zhao Liu
2025-11-19 13:08 ` [PATCH 5/5] error: Consistently name Error * objects err, and not errp Markus Armbruster
2025-11-19 13:22 ` Andrew Cooper
2025-11-19 13:35 ` Daniel P. Berrangé [this message]
2025-11-19 13:48 ` Markus Armbruster
2025-11-20 14:57 ` Zhao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aR3HpH88od11v8qL@redhat.com \
--to=berrange@redhat.com \
--cc=alistair@alistair23.me \
--cc=andrew.cooper3@citrix.com \
--cc=anisinha@redhat.com \
--cc=anthony@xenproject.org \
--cc=armbru@redhat.com \
--cc=dbarboza@ventanamicro.com \
--cc=eblake@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=gengdongjiu1@gmail.com \
--cc=harshpb@linux.ibm.com \
--cc=hreitz@redhat.com \
--cc=imammedo@redhat.com \
--cc=kwolf@redhat.com \
--cc=liwei1518@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=paul@xen.org \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=vsementsov@yandex-team.ru \
--cc=wangyanan55@huawei.com \
--cc=xen-devel@lists.xenproject.org \
--cc=zhao1.liu@intel.com \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).