[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/14] monitor: add object-del (QMP) and object_del (
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 06/14] monitor: add object-del (QMP) and object_del (HMP) command |
Date: |
Mon, 6 Jan 2014 17:03:07 -0500 |
From: Paolo Bonzini <address@hidden>
These two commands invoke the "unparent" method of Object.
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Tested-by: Igor Mammedov <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
hmp-commands.hx | 14 ++++++++++++++
hmp.c | 9 +++++++++
hmp.h | 1 +
qapi-schema.json | 14 ++++++++++++++
qmp-commands.hx | 25 +++++++++++++++++++++++++
qmp.c | 14 ++++++++++++++
6 files changed, 77 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 929550d..4d5e2b5 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1243,6 +1243,20 @@ STEXI
Remove host network device.
ETEXI
+ {
+ .name = "object_del",
+ .args_type = "id:s",
+ .params = "id",
+ .help = "destroy QOM object",
+ .mhandler.cmd = hmp_object_del,
+ },
+
+STEXI
address@hidden object_del
address@hidden object_del
+Destroy QOM object.
+ETEXI
+
#ifdef CONFIG_SLIRP
{
.name = "hostfwd_add",
diff --git a/hmp.c b/hmp.c
index c513f9b..fe05c6b 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1574,3 +1574,12 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
+
+void hmp_object_del(Monitor *mon, const QDict *qdict)
+{
+ const char *id = qdict_get_str(qdict, "id");
+ Error *err = NULL;
+
+ qmp_object_del(id, &err);
+ hmp_handle_error(mon, &err);
+}
diff --git a/hmp.h b/hmp.h
index f92fc89..7a11f68 100644
--- a/hmp.h
+++ b/hmp.h
@@ -90,5 +90,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
void hmp_qemu_io(Monitor *mon, const QDict *qdict);
void hmp_cpu_add(Monitor *mon, const QDict *qdict);
+void hmp_object_del(Monitor *mon, const QDict *qdict);
#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index c3c939c..af3a83b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2759,6 +2759,20 @@
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
##
+# @object-del:
+#
+# Remove a QOM object.
+#
+# @id: the name of the QOM object to remove
+#
+# Returns: Nothing on success
+# Error if @id is not a valid id for a QOM object
+#
+# Since: 2.0
+##
+{ 'command': 'object-del', 'data': {'id': 'str'} }
+
+##
# @NetdevNoneOptions
#
# Use it alone to have zero network devices.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index fba15cd..71422cd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -879,6 +879,31 @@ Example:
EQMP
{
+ .name = "object-del",
+ .args_type = "id:s",
+ .mhandler.cmd_new = qmp_marshal_input_object_del,
+ },
+
+SQMP
+object-del
+----------
+
+Remove QOM object.
+
+Arguments:
+
+- "id": the object's ID (json-string)
+
+Example:
+
+-> { "execute": "object-del", "arguments": { "id": "rng1" } }
+<- { "return": {} }
+
+
+EQMP
+
+
+ {
.name = "block_resize",
.args_type = "device:B,size:o",
.mhandler.cmd_new = qmp_marshal_input_block_resize,
diff --git a/qmp.c b/qmp.c
index 1d7a04d..73aab58 100644
--- a/qmp.c
+++ b/qmp.c
@@ -529,3 +529,17 @@ void qmp_add_client(const char *protocol, const char
*fdname,
error_setg(errp, "protocol '%s' is invalid", protocol);
close(fd);
}
+
+void qmp_object_del(const char *id, Error **errp)
+{
+ Object *container;
+ Object *obj;
+
+ container = container_get(object_get_root(), "/objects");
+ obj = object_resolve_path_component(container, id);
+ if (!obj) {
+ error_setg(errp, "object id not found");
+ return;
+ }
+ object_unparent(obj);
+}
--
1.8.1.4
- [Qemu-devel] [PULL 00/14] QMP queue, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 01/14] vl: add missing transition debug->finish_migrate, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 02/14] qemu-monitor: HMP cpu-add wrapper, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 03/14] rng: initialize file descriptor to -1, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 08/14] error: Add error_abort, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 05/14] qom: catch errors in object_property_add_child, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 09/14] qdev: Delete dead code, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 06/14] monitor: add object-del (QMP) and object_del (HMP) command,
Luiz Capitulino <=
- [Qemu-devel] [PULL 04/14] qom: fix leak for objects created with -object, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 12/14] qemu-option: Remove qemu_opts_create_nofail, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 10/14] hw: Remove assert_no_error usages, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 11/14] target-i386: Remove assert_no_error usage, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 07/14] monitor: add object-add (QMP) and object_add (HMP) command, Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 13/14] qerror: Remove assert_no_error(), Luiz Capitulino, 2014/01/06
- [Qemu-devel] [PULL 14/14] migration: qmp_migrate(): keep working after syntax error, Luiz Capitulino, 2014/01/06
- Re: [Qemu-devel] [PULL 00/14] QMP queue, Peter Maydell, 2014/01/06
- Re: [Qemu-devel] [PULL 00/14] QMP queue, Peter Crosthwaite, 2014/01/13