[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 18/25] qemu-nbd: use keyval for -object parsing
From: |
Paolo Bonzini |
Subject: |
[PATCH 18/25] qemu-nbd: use keyval for -object parsing |
Date: |
Mon, 18 Jan 2021 11:31:06 -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 12/25] qemu-config: add error propagation to qemu_config_parse, (continued)
- [PATCH 12/25] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2021/01/18
- [PATCH 13/25] qemu-option: support accept-any QemuOptsList in qemu_opts_absorb_qdict, Paolo Bonzini, 2021/01/18
- [PATCH 08/25] hmp: replace "O" parser with keyval, Paolo Bonzini, 2021/01/18
- [PATCH 17/25] qemu-io: use keyval for -object parsing, Paolo Bonzini, 2021/01/18
- [PATCH 20/25] qemu: use keyval for -object parsing, Paolo Bonzini, 2021/01/18
- [PATCH 21/25] storage-daemon: do not register the "object" group with QemuOpts, Paolo Bonzini, 2021/01/18
- [PATCH 25/25] vl: switch -accel parsing to keyval, Paolo Bonzini, 2021/01/18
- [PATCH 24/25] qemu-option: remove now-dead code, Paolo Bonzini, 2021/01/18
- [PATCH 18/25] qemu-nbd: use keyval for -object parsing,
Paolo Bonzini <=
- [PATCH 22/25] qom: export more functions for use with non-UserCreatable objects, Paolo Bonzini, 2021/01/18
- [PATCH 23/25] vl: switch -M parsing to keyval, Paolo Bonzini, 2021/01/18
- [PATCH 19/25] qemu-img: use keyval for -object parsing, Paolo Bonzini, 2021/01/18
- Re: [PATCH 00/25] qemu-option, keyval, vl: switch -object/-M/-accel to keyval parsing, no-reply, 2021/01/18