From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8CRZ-0005hf-Pj for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8CRT-0004cl-9N for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8CRT-0004cN-29 for qemu-devel@nongnu.org; Tue, 28 Jan 2014 12:27:19 -0500 From: Luiz Capitulino Date: Tue, 28 Jan 2014 12:27:06 -0500 Message-Id: <1390930029-14697-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1390930029-14697-1-git-send-email-lcapitulino@redhat.com> References: <1390930029-14697-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PULL 2/5] vl.c: -object: don't ignore duplicate 'id' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: qemu-devel@nongnu.org From: Igor Mammedov 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 Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Luiz Capitulino --- 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