[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/28] hmp: special case help options for object_add
From: |
Paolo Bonzini |
Subject: |
[PATCH 12/28] hmp: special case help options for object_add |
Date: |
Wed, 2 Dec 2020 04:02:49 -0500 |
Fix "object_add help" and "object_add TYPE,help".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/qom/object_interfaces.h | 9 ++++++++-
monitor/hmp-cmds.c | 22 ++++++++--------------
qom/object_interfaces.c | 2 +-
3 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 07d5cc8832..abb23eaea3 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -149,6 +149,13 @@ typedef bool (*user_creatable_add_opts_predicate)(const
char *type);
int user_creatable_add_opts_foreach(void *opaque,
QemuOpts *opts, Error **errp);
+/**
+ * user_creatable_print_types:
+ *
+ * Prints a list of user-creatable objects to stdout or the monitor.
+ */
+void user_creatable_print_types(void);
+
/**
* user_creatable_print_help:
* @type: the QOM type to be added
@@ -174,7 +181,7 @@ bool user_creatable_print_help(const char *type, QemuOpts
*opts);
* no help was requested. It should only be called if we know that help is
* requested and it will always print some help.
*/
-void user_creatable_print_help_from_qdict(QDict *args);
+void user_creatable_print_help_from_qdict(const QDict *args);
/**
* user_creatable_del:
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 65d8ff4849..153ece8176 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -1664,23 +1664,17 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
void hmp_object_add(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
- QemuOpts *opts;
- Object *obj = NULL;
- opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
- if (err) {
- goto end;
+ if (is_help_option(qdict_get_str(qdict, "qom-type"))) {
+ user_creatable_print_types();
+ return;
}
-
- obj = user_creatable_add_opts(opts, &err);
- qemu_opts_del(opts);
-
-end:
- hmp_handle_error(mon, err);
-
- if (obj) {
- object_unref(obj);
+ if (qdict_haskey(qdict, "help")) {
+ user_creatable_print_help_from_qdict(qdict);
+ return;
}
+ user_creatable_add_dict((QDict *)qdict, true, &err);
+ hmp_handle_error(mon, err);
}
void hmp_getfd(Monitor *mon, const QDict *qdict)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 34edc3d1d8..f7dcdf18e2 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -280,7 +280,7 @@ bool user_creatable_print_help(const char *type, QemuOpts
*opts)
return false;
}
-void user_creatable_print_help_from_qdict(QDict *args)
+void user_creatable_print_help_from_qdict(const QDict *args)
{
const char *type = qdict_get_try_str(args, "qom-type");
--
2.26.2
- [PATCH 09/28] keyval: introduce keyval_parse_into, (continued)
- [PATCH 09/28] keyval: introduce keyval_parse_into, Paolo Bonzini, 2020/12/02
- [PATCH 19/28] qemu-io: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 25/28] vl: rename local variable in configure_accelerators, Paolo Bonzini, 2020/12/02
- [PATCH 24/28] qom: export more functions for use with non-UserCreatable objects, Paolo Bonzini, 2020/12/02
- [PATCH 10/28] hmp: replace "O" parser with keyval, Paolo Bonzini, 2020/12/02
- [PATCH 14/28] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2020/12/02
- [PATCH 13/28] remove -writeconfig, Paolo Bonzini, 2020/12/02
- [PATCH 18/28] qom: do not modify QDict argument in user_creatable_add_dict, Paolo Bonzini, 2020/12/02
- [PATCH 28/28] vl: switch -accel parsing to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 27/28] qemu-option: remove now-dead code, Paolo Bonzini, 2020/12/02
- [PATCH 12/28] hmp: special case help options for object_add,
Paolo Bonzini <=
- [PATCH 22/28] qemu: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 21/28] qemu-img: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 23/28] storage-daemon: do not register the "object" group with QemuOpts, Paolo Bonzini, 2020/12/02
- [PATCH 15/28] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict, Paolo Bonzini, 2020/12/02
- [PATCH 16/28] qemu-config: parse configuration files to a QDict, Paolo Bonzini, 2020/12/02
- [PATCH 17/28] vl: plumb keyval-based options into -set and -readconfig, Paolo Bonzini, 2020/12/02
- [PATCH 20/28] qemu-nbd: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 26/28] vl: switch -M parsing to keyval, Paolo Bonzini, 2020/12/02