]> Git Repo - qemu.git/commitdiff
monitor: add object-del (QMP) and object_del (HMP) command
authorPaolo Bonzini <[email protected]>
Fri, 20 Dec 2013 22:21:09 +0000 (23:21 +0100)
committerLuiz Capitulino <[email protected]>
Mon, 6 Jan 2014 18:45:47 +0000 (13:45 -0500)
These two commands invoke the "unparent" method of Object.

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Tested-by: Igor Mammedov <[email protected]>
Signed-off-by: Luiz Capitulino <[email protected]>
hmp-commands.hx
hmp.c
hmp.h
qapi-schema.json
qmp-commands.hx
qmp.c

index 929550d66b9dd48e4b832ac751ff52c5cb7936b9..4d5e2b5142fd0abba73b5cccf310b87f1e64a4d3 100644 (file)
@@ -1241,6 +1241,20 @@ STEXI
 @item netdev_del
 @findex netdev_del
 Remove host network device.
+ETEXI
+
+    {
+        .name       = "object_del",
+        .args_type  = "id:s",
+        .params     = "id",
+        .help       = "destroy QOM object",
+        .mhandler.cmd = hmp_object_del,
+    },
+
+STEXI
+@item object_del
+@findex object_del
+Destroy QOM object.
 ETEXI
 
 #ifdef CONFIG_SLIRP
diff --git a/hmp.c b/hmp.c
index c513f9b68508aaae43b4a470f8f26c20a044acf6..fe05c6b860c6b6db3ada1562709eb73dc9c16039 100644 (file)
--- 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 f92fc8922dc9b74da929b3952ccf6e8cdc698b83..7a11f68a3bc9642b3dabd35b8a220d2bf030d988 100644 (file)
--- 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
index c3c939c8c3f6bc85d4280a2ef3ae900657a68371..af3a83bf0b3d38377c430e9ac8f72825dbe4af97 100644 (file)
 ##
 { '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
 #
index fba15cdc3be2310878dedf2d3551687ae34982bf..71422cd99c964c6927b976697053b0fcadbd5180 100644 (file)
@@ -878,6 +878,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",
diff --git a/qmp.c b/qmp.c
index 1d7a04d7a0b452678081672598c870f00dce7201..73aab5876c1319d58cb56c5240d15c47aedd02cb 100644 (file)
--- 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);
+}
This page took 0.033633 seconds and 4 git commands to generate.