All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] qom: Implement qom-get HMP command
@ 2020-04-07 11:44 Cédric Le Goater
  2020-04-27 19:19 ` Dr. David Alan Gilbert
  2020-05-02  6:02 ` Markus Armbruster
  0 siblings, 2 replies; 8+ messages in thread
From: Cédric Le Goater @ 2020-04-07 11:44 UTC (permalink / raw)
  To: Dr . David Alan Gilbert
  Cc: Daniel P . Berrangé,
	Eduardo Habkost, qemu-devel, Cédric Le Goater,
	Paolo Bonzini, Andreas Färber

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Reimplement it based on qmp_qom_get() to avoid converting QObjects back
to strings.

Inspired-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>

Slight fix for bit-rot:
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
[clg: updates for QEMU 5.0 ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 I would like to restart the discussion on qom-get command to understand
 what was the conclusion and see if things have changed since.

 Thanks,

 C.

 include/monitor/hmp.h |  1 +
 qom/qom-hmp-cmds.c    | 23 +++++++++++++++++++++++
 hmp-commands.hx       | 13 +++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index e33ca5a911a5..c986cfd28bc3 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -96,6 +96,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict);
 void hmp_info_numa(Monitor *mon, const QDict *qdict);
 void hmp_info_memory_devices(Monitor *mon, const QDict *qdict);
 void hmp_qom_list(Monitor *mon, const QDict *qdict);
+void hmp_qom_get(Monitor *mon, const QDict *qdict);
 void hmp_qom_set(Monitor *mon, const QDict *qdict);
 void hmp_info_qom_tree(Monitor *mon, const QDict *dict);
 void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
index cd08233a4cfe..b14cf6e785f4 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -40,6 +40,29 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, err);
 }
 
+void hmp_qom_get(Monitor *mon, const QDict *qdict)
+{
+    const char *path = qdict_get_str(qdict, "path");
+    const char *property = qdict_get_str(qdict, "property");
+    Error *err = NULL;
+    Object *obj;
+    char *value;
+
+    obj = object_resolve_path(path, NULL);
+    if (obj == NULL) {
+        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "Device '%s' not found", path);
+        hmp_handle_error(mon, err);
+        return;
+    }
+    value = object_property_print(obj, property, true, &err);
+    if (err == NULL) {
+        monitor_printf(mon, "%s\n", value);
+        g_free(value);
+    }
+    hmp_handle_error(mon, err);
+}
+
 void hmp_qom_set(Monitor *mon, const QDict *qdict)
 {
     const char *path = qdict_get_str(qdict, "path");
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 7f0f3974ad90..4e39b9caed3e 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1790,6 +1790,19 @@ SRST
   Print QOM properties of object at location *path*
 ERST
 
+    {
+        .name       = "qom-get",
+        .args_type  = "path:s,property:s",
+        .params     = "path property",
+        .help       = "print QOM property",
+        .cmd        = hmp_qom_get,
+    },
+
+SRST
+``qom-get``  *path* *property*
+  Print QOM property *property* of object at location *path*
+ERST
+
     {
         .name       = "qom-set",
         .args_type  = "path:s,property:s,value:s",
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-21 14:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 11:44 [RFC PATCH] qom: Implement qom-get HMP command Cédric Le Goater
2020-04-27 19:19 ` Dr. David Alan Gilbert
2020-04-29  7:45   ` Cédric Le Goater
2020-05-02  6:02 ` Markus Armbruster
2020-05-07 17:06   ` Dr. David Alan Gilbert
2020-05-08  6:48     ` Markus Armbruster
2020-05-20  9:59       ` Dr. David Alan Gilbert
2020-05-21 14:24         ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.