From patchwork Wed Sep 9 07:24:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Hongyang X-Patchwork-Id: 515720 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3E2D514076A for ; Wed, 9 Sep 2015 17:26:03 +1000 (AEST) Received: from localhost ([::1]:40376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZlY-0001oM-F2 for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2015 03:26:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZkg-0000is-5O for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZZkd-0005Cm-2I for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:06 -0400 Received: from [59.151.112.132] (port=53279 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZZkc-000588-NK for qemu-devel@nongnu.org; Wed, 09 Sep 2015 03:25:03 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100509174" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Sep 2015 15:27:53 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t897Oh53032189; Wed, 9 Sep 2015 15:24:43 +0800 Received: from localhost (10.167.226.223) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 9 Sep 2015 15:24:55 +0800 From: Yang Hongyang To: Date: Wed, 9 Sep 2015 15:24:32 +0800 Message-ID: <1441783481-17698-2-git-send-email-yanghy@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441783481-17698-1-git-send-email-yanghy@cn.fujitsu.com> References: <1441783481-17698-1-git-send-email-yanghy@cn.fujitsu.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: thuth@redhat.com, zhang.zhanghailiang@huawei.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, armbru@redhat.com, stefanha@redhat.com, Yang Hongyang Subject: [Qemu-devel] [PATCH v10 01/10] qmp: delete qemu opts when delete an object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 403805a..c6b85dd 100644 --- a/qmp.c +++ b/qmp.c @@ -680,6 +680,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); @@ -693,6 +694,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); } MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)