[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 50/79] monitor: fix object_del for command-line-crea
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 50/79] monitor: fix object_del for command-line-created objects |
Date: |
Mon, 28 Aug 2017 19:14:25 -0500 |
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" <address@hidden>
Cc: Markus Armbruster <address@hidden>
Cc: Eric Blake <address@hidden>
Cc: Daniel Berrange <address@hidden>
Cc: address@hidden
Signed-off-by: Michael Roth <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
(cherry picked from commit c645d5acee0ae022534cb609184277ec2b4a8577)
Signed-off-by: Michael Roth <address@hidden>
---
qom/object_interfaces.c | 9 +++++++++
tests/check-qom-proplist.c | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index d4253a8..ff27e06 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);
}
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index e3b3ae4..8e432e9 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -438,9 +438,9 @@ static void test_dummy_createcmdl(void)
* check for this in user_creatable_del() and remove the QemuOpts if
* it is present.
*
- * FIXME: add an assert to verify that the QemuOpts is cleaned up
- * once the corresponding cleanup code is added.
+ * The below check ensures this works as expected.
*/
+ g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
}
static void test_dummy_badenum(void)
--
2.7.4
- [Qemu-devel] [PATCH 54/79] spapr: add pre_plug function for memory, (continued)
- [Qemu-devel] [PATCH 54/79] spapr: add pre_plug function for memory, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 48/79] linuxboot_dma: compile for i486, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 51/79] pc: Use "min-[x]level" on compat_props, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 58/79] nbd: Fully initialize client in case of failed negotiation, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 63/79] nbd: fix NBD over TLS, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 61/79] blkdebug: Catch bs->exact_filename overflow, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 42/79] blkdebug: Add ability to override unmap geometries, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 40/79] blkdebug: Add pass-through write_zero and discard support, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 45/79] block: Guarantee that *file is set on bdrv_get_block_status(), Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 47/79] virtio-serial-bus: Unset hotplug handler when unrealize, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 50/79] monitor: fix object_del for command-line-created objects,
Michael Roth <=
- [Qemu-devel] [PATCH 65/79] 9pfs: local: remove: use correct path component, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 04/79] qemu-img/convert: Use @opts for one thing only, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 56/79] target/xtensa: handle unknown registers in gdbstub, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 57/79] commit: Fix use after free in completion, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 62/79] blkverify: Catch bs->exact_filename overflow, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 67/79] spapr: fix migration to pseries machine < 2.8, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 66/79] hid: Reset kbd modifiers on reset, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 60/79] commit: Fix completion with extra reference, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 59/79] nbd: Fix regression on resiliency to port scan, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 71/79] virtio-net: fix offload ctrl endian, Michael Roth, 2017/08/28