Received: from eggs.gnu.org ([2001:4830:134:3::10]:42134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf1CI-0001PJ-H2 for qemu-devel@nongnu.org; Thu, 24 Sep 2015 03:44:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf1CF-0002Fi-B6 for qemu-devel@nongnu.org; Thu, 24 Sep 2015 03:44:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf1CF-0002FY-5Q for qemu-devel@nongnu.org; Thu, 24 Sep 2015 03:44:03 -0400 From: Markus Armbruster References: <1442405768-23019-1-git-send-email-yanghy@cn.fujitsu.com> <1442405768-23019-2-git-send-email-yanghy@cn.fujitsu.com> Date: Thu, 24 Sep 2015 09:43:59 +0200 In-Reply-To: <1442405768-23019-2-git-send-email-yanghy@cn.fujitsu.com> (Yang Hongyang's message of "Wed, 16 Sep 2015 20:15:57 +0800") Message-ID: <87a8sctg74.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v11 01/12] qmp: delete qemu opts when delete an object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yang Hongyang Cc: thuth@redhat.com, zhang.zhanghailiang@huawei.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, Paolo Bonzini This has finally reached the front of my review queue. I apologize for the loooong delay. Copying Paolo for another pair of eyeballs (he wrote this code). Yang Hongyang writes: > When delete an object, we need to delete the associated qemu opts, > otherwise, we can not add another object with the same name using > object_add. > The case happens when we start qemu with: > -object xxx,id=aa > then we delete this object with: > object_del aa > then add the object with: > object_add xxx,id=aa > > QEMU will return error with Duplicate ID error. > > Signed-off-by: Yang Hongyang > --- > qmp.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/qmp.c b/qmp.c > index 9623c80..4bd44c3 100644 > --- a/qmp.c > +++ b/qmp.c > @@ -686,6 +686,7 @@ void qmp_object_del(const char *id, Error **errp) > { > Object *container; > Object *obj; > + QemuOpts *opts; > > container = object_get_objects_root(); > obj = object_resolve_path_component(container, id); > @@ -699,6 +700,9 @@ void qmp_object_del(const char *id, Error **errp) > return; > } > object_unparent(obj); > + > + opts = qemu_opts_find(qemu_find_opts_err("object", NULL), id); > + qemu_opts_del(opts); qemu_find_opts_err("object", &error_abort) please, because when it fails, we want to die right away, not when the null pointer it returns gets dereferenced. Same sloppiness in netdev_del_completion() and qmp_netdev_del(), not your patch's fault. Elsewhere, we store the QemuOpts in the object just so we can delete it: DeviceState, DriveInfo. Paolo, what do you think? > } > > MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)