qemu-nbd: Use user_creatable_process_cmdline() for --object
This switches qemu-nbd from a QemuOpts-based parser for --object to user_creatable_process_cmdline() which uses a keyval parser and enforces the QAPI schema. Apart from being a cleanup, this makes non-scalar properties accessible. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
b3e79bc6f0
commit
fa40e43ca0
34
qemu-nbd.c
34
qemu-nbd.c
@ -401,24 +401,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,
|
static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, bool list,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -594,7 +576,6 @@ int main(int argc, char **argv)
|
|||||||
qcrypto_init(&error_fatal);
|
qcrypto_init(&error_fatal);
|
||||||
|
|
||||||
module_call_init(MODULE_INIT_QOM);
|
module_call_init(MODULE_INIT_QOM);
|
||||||
qemu_add_opts(&qemu_object_opts);
|
|
||||||
qemu_add_opts(&qemu_trace_opts);
|
qemu_add_opts(&qemu_trace_opts);
|
||||||
qemu_init_exec_dir(argv[0]);
|
qemu_init_exec_dir(argv[0]);
|
||||||
|
|
||||||
@ -747,14 +728,9 @@ int main(int argc, char **argv)
|
|||||||
case '?':
|
case '?':
|
||||||
error_report("Try `%s --help' for more information.", argv[0]);
|
error_report("Try `%s --help' for more information.", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
case QEMU_NBD_OPT_OBJECT: {
|
case QEMU_NBD_OPT_OBJECT:
|
||||||
QemuOpts *opts;
|
user_creatable_process_cmdline(optarg);
|
||||||
opts = qemu_opts_parse_noisily(&qemu_object_opts,
|
break;
|
||||||
optarg, true);
|
|
||||||
if (!opts) {
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case QEMU_NBD_OPT_TLSCREDS:
|
case QEMU_NBD_OPT_TLSCREDS:
|
||||||
tlscredsid = optarg;
|
tlscredsid = optarg;
|
||||||
break;
|
break;
|
||||||
@ -802,10 +778,6 @@ int main(int argc, char **argv)
|
|||||||
export_name = "";
|
export_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_opts_foreach(&qemu_object_opts,
|
|
||||||
user_creatable_add_opts_foreach,
|
|
||||||
qemu_nbd_object_print_help, &error_fatal);
|
|
||||||
|
|
||||||
if (!trace_init_backends()) {
|
if (!trace_init_backends()) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user