[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 20/28] qemu-nbd: use keyval for -object parsing
From: |
Paolo Bonzini |
Subject: |
[PATCH 20/28] qemu-nbd: use keyval for -object parsing |
Date: |
Wed, 2 Dec 2020 04:02:57 -0500 |
Enable creation of object with non-scalar properties.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-nbd.c | 42 +++++++++++++-----------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a7075c5419..b4bd21a21e 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -407,23 +407,6 @@ static QemuOptsList file_opts = {
},
};
-static QemuOptsList qemu_object_opts = {
- .name = "object",
- .implied_opt_name = "qom-type",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
- .desc = {
- { }
- },
-};
-
-static bool qemu_nbd_object_print_help(const char *type, QemuOpts *opts)
-{
- if (user_creatable_print_help(type, opts)) {
- exit(0);
- }
- return true;
-}
-
static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list,
Error **errp)
@@ -599,7 +582,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);
qemu_init_exec_dir(argv[0]);
@@ -752,14 +734,20 @@ int main(int argc, char **argv)
case '?':
error_report("Try `%s --help' for more information.", argv[0]);
exit(EXIT_FAILURE);
- case QEMU_NBD_OPT_OBJECT: {
- QemuOpts *opts;
- opts = qemu_opts_parse_noisily(&qemu_object_opts,
- optarg, true);
- if (!opts) {
- exit(EXIT_FAILURE);
+ case QEMU_NBD_OPT_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 QEMU_NBD_OPT_TLSCREDS:
tlscredsid = optarg;
break;
@@ -807,10 +795,6 @@ int main(int argc, char **argv)
export_name = "";
}
- qemu_opts_foreach(&qemu_object_opts,
- user_creatable_add_opts_foreach,
- qemu_nbd_object_print_help, &error_fatal);
-
if (!trace_init_backends()) {
exit(1);
}
--
2.26.2
- [PATCH 07/28] keyval: simplify keyval_parse_one, (continued)
- [PATCH 07/28] keyval: simplify keyval_parse_one, Paolo Bonzini, 2020/12/02
- [PATCH 09/28] keyval: introduce keyval_parse_into, Paolo Bonzini, 2020/12/02
- [PATCH 14/28] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2020/12/02
- [PATCH 08/28] tests: convert check-qom-proplist to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 28/28] vl: switch -accel parsing to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 24/28] qom: export more functions for use with non-UserCreatable objects, Paolo Bonzini, 2020/12/02
- [PATCH 21/28] qemu-img: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 10/28] hmp: replace "O" parser with keyval, Paolo Bonzini, 2020/12/02
- [PATCH 16/28] qemu-config: parse configuration files to a QDict, 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 20/28] qemu-nbd: use keyval for -object parsing,
Paolo Bonzini <=
- [PATCH 13/28] remove -writeconfig, Paolo Bonzini, 2020/12/02
- [PATCH 23/28] storage-daemon: do not register the "object" group with QemuOpts, 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 27/28] qemu-option: remove now-dead code, Paolo Bonzini, 2020/12/02
- [PATCH 17/28] vl: plumb keyval-based options into -set and -readconfig, Paolo Bonzini, 2020/12/02
- [PATCH 12/28] hmp: special case help options for object_add, Paolo Bonzini, 2020/12/02
- [PATCH 22/28] qemu: use keyval for -object parsing, Paolo Bonzini, 2020/12/02
- [PATCH 26/28] vl: switch -M parsing to keyval, Paolo Bonzini, 2020/12/02
- [PATCH 15/28] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict, Paolo Bonzini, 2020/12/02