qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: anthony@codemonkey.ws
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 12/13] monitor: add object-del (QMP) and object_del (HMP) command
Date: Wed, 18 Dec 2013 12:00:02 -0500	[thread overview]
Message-ID: <1387386003-8949-13-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1387386003-8949-1-git-send-email-lcapitulino@redhat.com>

From: Paolo Bonzini <pbonzini@redhat.com>

These two commands invoke the "unparent" method of Object.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hmp-commands.hx  | 14 ++++++++++++++
 hmp.c            |  9 +++++++++
 hmp.h            |  1 +
 qapi-schema.json | 14 ++++++++++++++
 qmp-commands.hx  | 24 ++++++++++++++++++++++++
 qmp.c            | 13 +++++++++++++
 6 files changed, 75 insertions(+)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 2951d1e..0ace14f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1257,6 +1257,20 @@ STEXI
 Create QOM object.
 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
     {
         .name       = "hostfwd_add",
diff --git a/hmp.c b/hmp.c
index a1669ab..9f4c9b3 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1622,3 +1622,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 521449b..94264d6 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_object_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 451310b..4b9a34e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2779,6 +2779,20 @@
   'gen': 'no' }
 
 ##
+# @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 d09ea53..02cc815 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -904,6 +904,30 @@ 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",
diff --git a/qmp.c b/qmp.c
index 580f5e6..b662217 100644
--- a/qmp.c
+++ b/qmp.c
@@ -591,3 +591,16 @@ out:
 
     return 0;
 }
+
+void qmp_object_del(const char *id, Error **errp)
+{
+    Object *obj;
+
+    obj = object_resolve_path_component(container_get(object_get_root(), "/objects"),
+                                        id);
+    if (!obj) {
+        error_setg(errp, "object id not found");
+        return;
+    }
+    object_unparent(obj);
+}
-- 
1.8.1.4

  parent reply	other threads:[~2013-12-18 17:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 16:59 [Qemu-devel] [PULL 00/13] QMP queue Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 01/13] vl: add missing transition debug->finish_migrate Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 02/13] error: Add error_abort Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 03/13] hw/core/qdev: Delete dead code Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 04/13] hw: Remove assert_no_error usages Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 05/13] target-i386: Remove assert_no_error usage Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 06/13] qemu-option: Remove qemu_opts_create_nofail Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 07/13] qerror: Remove assert_no_error() Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 08/13] rng: initialize file descriptor to -1 Luiz Capitulino
2013-12-18 16:59 ` [Qemu-devel] [PULL 09/13] qom: fix leak for objects created with -object Luiz Capitulino
2013-12-18 17:00 ` [Qemu-devel] [PULL 10/13] qom: catch errors in object_property_add_child Luiz Capitulino
2013-12-18 19:09   ` Andreas Färber
2013-12-18 19:58     ` Markus Armbruster
2013-12-18 22:17     ` Luiz Capitulino
2013-12-20  2:27   ` Peter Crosthwaite
2013-12-18 17:00 ` [Qemu-devel] [PULL 11/13] monitor: add object-add (QMP) and object_add (HMP) command Luiz Capitulino
2013-12-20  2:15   ` Peter Crosthwaite
2013-12-20 13:33     ` Luiz Capitulino
2013-12-18 17:00 ` Luiz Capitulino [this message]
2013-12-18 17:00 ` [Qemu-devel] [PULL 13/13] qemu-monitor: HMP cpu-add wrapper Luiz Capitulino
2013-12-20  0:32 ` [Qemu-devel] [PULL 00/13] QMP queue Peter Maydell
2013-12-20  0:44   ` Li Guang
2013-12-20  0:49 ` Anthony Liguori
2013-12-20  4:00   ` Peter Crosthwaite
2013-12-20 13:28     ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387386003-8949-13-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).