From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: pbonzini@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org,
ehabkost@redhat.com, eric.auger.pro@gmail.com
Subject: Re: [PATCH] qom: Allow object_property_add_child() to fail
Date: Tue, 23 Jun 2020 17:05:08 +0100 [thread overview]
Message-ID: <20200623160508.GK751477@redhat.com> (raw)
In-Reply-To: <20200623155452.30954-1-eric.auger@redhat.com>
On Tue, Jun 23, 2020 at 05:54:52PM +0200, Eric Auger wrote:
> object_property_add() does not allow object_property_try_add()
> to gracefully fail as &error_abort is passed as an error handle.
>
> However such failure can easily be triggered from the QMP shell when,
> for instance, one attempts to create an object with an id that already
> exists:
>
> For instance, call twice:
> object-add qom-type=memory-backend-ram id=mem1 props.size=1073741824
> and QEMU aborts.
>
> This behavior is undesired as a user/management application mistake
> in reusing a property ID shouldn't result in loss of the VM and live
> data within.
>
> This patch introduces two new functions, object_property_add_err() and
> object_property_add_child_err() whose prototype features an error handle.
> object_property_add_child_err() now gets called from user_creatable_add_type.
> This solution was chosen instead of changing the prototype of existing
> functions because the number of existing callers is huge.
>
> The error now is returned gracefully to the QMP client.
>
> (QEMU) object-add qom-type=memory-backend-ram id=mem2 props.size=4294967296
> {"return": {}}
> (QEMU) object-add qom-type=memory-backend-ram id=mem2 props.size=4294967296
> {"error": {"class": "GenericError", "desc": "attempt to add duplicate property
> 'mem2' to object (type 'container')"}}
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> include/qom/object.h | 24 ++++++++++++++++++++++--
> qom/object.c | 33 ++++++++++++++++++++++++++++-----
> qom/object_interfaces.c | 7 +++++--
> 3 files changed, 55 insertions(+), 9 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
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:[~2020-06-23 16:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 15:54 [PATCH] qom: Allow object_property_add_child() to fail Eric Auger
2020-06-23 16:05 ` Daniel P. Berrangé [this message]
2020-06-23 16:20 ` Paolo Bonzini
2020-06-23 16:22 ` Paolo Bonzini
2020-06-23 16:24 ` Auger Eric
2020-06-23 16:23 ` Paolo Bonzini
2020-06-24 8:22 ` Markus Armbruster
2020-06-24 8:40 ` Auger Eric
2020-06-24 8:51 ` Daniel P. Berrangé
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=20200623160508.GK751477@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).