aboutsummaryrefslogtreecommitdiff
path: root/qom/object_interfaces.c
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2017-06-03 18:13:32 -0500
committerMarkus Armbruster <armbru@redhat.com>2017-06-06 09:29:46 +0200
commitc645d5acee0ae022534cb609184277ec2b4a8577 (patch)
tree77ab277c0c59d7dcf791cbd2e86c1feceea5c6fd /qom/object_interfaces.c
parenta1af255f065ccf3f47a7bfe88f1dbc9eeca36935 (diff)
monitor: fix object_del for command-line-created objects
Currently objects specified on the command-line are only partially cleaned up when 'object_del' is issued in either HMP or QMP: the object itself is fully finalized, but the QemuOpts are not removed. This results in the following behavior: x86_64-softmmu/qemu-system-x86_64 -monitor stdio \ -object memory-backend-ram,id=ram1,size=256M QEMU 2.7.91 monitor - type 'help' for more information (qemu) object_del ram1 (qemu) object_del ram1 object 'ram1' not found (qemu) object_add memory-backend-ram,id=ram1,size=256M Duplicate ID 'ram1' for object Try "help object_add" for more information which can be an issue for use-cases like memory hotplug. This happens on the HMP side because hmp_object_add() attempts to create a temporary QemuOpts entry with ID 'ram1', which ends up conflicting with the command-line-created entry, since it was never cleaned up during the previous hmp_object_del() call. We address this by adding a check in user_creatable_del(), which is called by both qmp_object_del() and hmp_object_del() to handle the actual object cleanup, to determine whether an option group entry matching the object's ID is present and removing it if it is. Note that qmp_object_add() never attempts to create a temporary QemuOpts entry, so it does not encounter the duplicate ID error, which is why this isn't generally visible in libvirt. Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Cc: Eric Blake <eblake@redhat.com> Cc: Daniel Berrange <berrange@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1496531612-22166-3-git-send-email-mdroth@linux.vnet.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qom/object_interfaces.c')
-rw-r--r--qom/object_interfaces.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index d4253a88de..ff27e0669e 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -4,6 +4,7 @@
#include "qemu/module.h"
#include "qapi-visit.h"
#include "qapi/opts-visitor.h"
+#include "qemu/config-file.h"
void user_creatable_complete(Object *obj, Error **errp)
{
@@ -181,6 +182,14 @@ void user_creatable_del(const char *id, Error **errp)
error_setg(errp, "object '%s' is in use, can not be deleted", id);
return;
}
+
+ /*
+ * if object was defined on the command-line, remove its corresponding
+ * option group entry
+ */
+ qemu_opts_del(qemu_opts_find(qemu_find_opts_err("object", &error_abort),
+ id));
+
object_unparent(obj);
}