qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: anthony@codemonkey.ws
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 2/5] vl.c: -object: don't ignore duplicate 'id'
Date: Tue, 28 Jan 2014 12:27:06 -0500	[thread overview]
Message-ID: <1390930029-14697-3-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1390930029-14697-1-git-send-email-lcapitulino@redhat.com>

From: Igor Mammedov <imammedo@redhat.com>

object_property_add_child() may fail if 'id' matches
an already existing object. Which means an incorrect
command line.
So instead of silently ignoring error, report it and
terminate QEMU.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 vl.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index 7f4fe0d..cf3de56 100644
--- a/vl.c
+++ b/vl.c
@@ -2800,6 +2800,7 @@ static int object_create(QemuOpts *opts, void *opaque)
 {
     const char *type = qemu_opt_get(opts, "qom-type");
     const char *id = qemu_opts_id(opts);
+    Error *local_err = NULL;
     Object *obj;
 
     g_assert(type != NULL);
@@ -2816,8 +2817,14 @@ static int object_create(QemuOpts *opts, void *opaque)
     }
 
     object_property_add_child(container_get(object_get_root(), "/objects"),
-                              id, obj, NULL);
+                              id, obj, &local_err);
+
     object_unref(obj);
+    if (local_err) {
+        qerror_report_err(local_err);
+        error_free(local_err);
+        return -1;
+    }
     return 0;
 }
 
-- 
1.8.1.4

  parent reply	other threads:[~2014-01-28 17:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 17:27 [Qemu-devel] [PULL 0/5] QMP queue Luiz Capitulino
2014-01-28 17:27 ` [Qemu-devel] [PULL 1/5] object_add: consolidate error handling Luiz Capitulino
2014-01-28 17:27 ` Luiz Capitulino [this message]
2014-01-28 17:27 ` [Qemu-devel] [PULL 3/5] add optional 2nd stage initialization to -object/object-add commands Luiz Capitulino
2014-01-28 17:34   ` Eric Blake
2014-01-28 17:49     ` Luiz Capitulino
2014-01-28 17:27 ` [Qemu-devel] [PULL 4/5] virtio_rng: replace custom backend API with UserCreatable.complete() callback Luiz Capitulino
2014-01-28 17:27 ` [Qemu-devel] [PULL 5/5] monitor: Cleanup mon->outbuf on write error Luiz Capitulino
2014-02-01 23:41 ` [Qemu-devel] [PULL 0/5] QMP queue Peter Maydell

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=1390930029-14697-3-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=anthony@codemonkey.ws \
    --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).