[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/12] qemu-io: use keyval for -object parsing
From: |
Paolo Bonzini |
Subject: |
[PATCH 06/12] qemu-io: use keyval for -object parsing |
Date: |
Wed, 11 Nov 2020 09:25:31 -0500 |
Enable creation of object with non-scalar properties.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-io.c | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index ac88d8bd40..306086f767 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -477,23 +477,6 @@ enum {
OPTION_IMAGE_OPTS = 257,
};
-static QemuOptsList qemu_object_opts = {
- .name = "object",
- .implied_opt_name = "qom-type",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
- .desc = {
- { }
- },
-};
-
-static bool qemu_io_object_print_help(const char *type, QemuOpts *opts)
-{
- if (user_creatable_print_help(type, opts)) {
- exit(0);
- }
- return true;
-}
-
static QemuOptsList file_opts = {
.name = "file",
.implied_opt_name = "file",
@@ -550,7 +533,6 @@ int main(int argc, char **argv)
qcrypto_init(&error_fatal);
module_call_init(MODULE_INIT_QOM);
- qemu_add_opts(&qemu_object_opts);
qemu_add_opts(&qemu_trace_opts);
bdrv_init();
@@ -612,14 +594,20 @@ int main(int argc, char **argv)
case 'U':
force_share = true;
break;
- case OPTION_OBJECT: {
- QemuOpts *qopts;
- qopts = qemu_opts_parse_noisily(&qemu_object_opts,
- optarg, true);
- if (!qopts) {
- exit(1);
+ case OPTION_OBJECT:
+ {
+ QDict *args;
+ bool help;
+
+ args = keyval_parse(optarg, "qom-type", &help, &error_fatal);
+ if (help) {
+ user_creatable_print_help_from_qdict(args);
+ exit(EXIT_SUCCESS);
+ }
+ user_creatable_add_dict(args, true, &error_fatal);
+ qobject_unref(args);
+ break;
}
- } break;
case OPTION_IMAGE_OPTS:
imageOpts = true;
break;
@@ -644,10 +632,6 @@ int main(int argc, char **argv)
exit(1);
}
- qemu_opts_foreach(&qemu_object_opts,
- user_creatable_add_opts_foreach,
- qemu_io_object_print_help, &error_fatal);
-
if (!trace_init_backends()) {
exit(1);
}
--
2.26.2
- [PATCH 02/12] keyval: introduce keyval_parse_into, (continued)
- [PATCH 02/12] keyval: introduce keyval_parse_into, Paolo Bonzini, 2020/11/11
- [PATCH 07/12] qemu-nbd: use keyval for -object parsing, Paolo Bonzini, 2020/11/11
- [PATCH 05/12] hmp: special case help options for object_add, Paolo Bonzini, 2020/11/11
- [PATCH 03/12] hmp: replace "O" parser with keyval, Paolo Bonzini, 2020/11/11
- [PATCH 11/12] qemu-config: parse configuration files to a QDict, Paolo Bonzini, 2020/11/11
- [PATCH 09/12] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2020/11/11
- [PATCH 10/12] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict, Paolo Bonzini, 2020/11/11
- [PATCH 08/12] qemu-img: use keyval for -object parsing, Paolo Bonzini, 2020/11/11
- [PATCH 12/12] qemu: use keyval for -object parsing, Paolo Bonzini, 2020/11/11
- [PATCH 01/12] tests: convert check-qom-proplist to keyval, Paolo Bonzini, 2020/11/11
- [PATCH 06/12] qemu-io: use keyval for -object parsing,
Paolo Bonzini <=
- Re: [RFC PATCH 00/12] Remove QemuOpts usage for HMP, -object and -readconfig, Kevin Wolf, 2020/11/13