[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 02/18] qemu-storage-daemon: Add --object option
From: |
Kevin Wolf |
Subject: |
[RFC PATCH 02/18] qemu-storage-daemon: Add --object option |
Date: |
Thu, 17 Oct 2019 15:01:48 +0200 |
Add a command line option to create user-creatable QOM objects.
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-storage-daemon.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c
index a251dc255c..48d6af43a6 100644
--- a/qemu-storage-daemon.c
+++ b/qemu-storage-daemon.c
@@ -35,6 +35,8 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
+#include "qemu/option.h"
+#include "qom/object_interfaces.h"
#include "trace/control.h"
@@ -51,10 +53,26 @@ static void help(void)
" specify tracing options\n"
" -V, --version output version information and exit\n"
"\n"
+" --object <properties> define a QOM object such as 'secret' for\n"
+" passwords and/or encryption keys\n"
+"\n"
QEMU_HELP_BOTTOM "\n",
error_get_progname());
}
+enum {
+ OPTION_OBJECT = 256,
+};
+
+static QemuOptsList qemu_object_opts = {
+ .name = "object",
+ .implied_opt_name = "qom-type",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
+ .desc = {
+ { }
+ },
+};
+
static int process_options(int argc, char *argv[], Error **errp)
{
int c;
@@ -63,6 +81,7 @@ static int process_options(int argc, char *argv[], Error
**errp)
static const struct option long_options[] = {
{"help", no_argument, 0, 'h'},
+ {"object", required_argument, 0, OPTION_OBJECT},
{"version", no_argument, 0, 'V'},
{"trace", required_argument, NULL, 'T'},
{0, 0, 0, 0}
@@ -88,6 +107,22 @@ static int process_options(int argc, char *argv[], Error
**errp)
g_free(trace_file);
trace_file = trace_opt_parse(optarg);
break;
+ case OPTION_OBJECT:
+ {
+ QemuOpts *opts;
+ const char *type;
+
+ opts = qemu_opts_parse(&qemu_object_opts,
+ optarg, true, &error_fatal);
+ type = qemu_opt_get(opts, "qom-type");
+
+ if (user_creatable_print_help(type, opts)) {
+ exit(EXIT_SUCCESS);
+ }
+ user_creatable_add_opts(opts, &error_fatal);
+ qemu_opts_del(opts);
+ break;
+ }
}
}
if (optind != argc) {
--
2.20.1
- [RFC PATCH 00/18] Add qemu-storage-daemon, Kevin Wolf, 2019/10/17
- [RFC PATCH 01/18] qemu-storage-daemon: Add barebone tool, Kevin Wolf, 2019/10/17
- [RFC PATCH 02/18] qemu-storage-daemon: Add --object option,
Kevin Wolf <=
- [RFC PATCH 05/18] qemu-storage-daemon: Add --blockdev option, Kevin Wolf, 2019/10/17
- [RFC PATCH 03/18] stubs: Add arch_type, Kevin Wolf, 2019/10/17
- [RFC PATCH 04/18] stubs: Add blk_by_qdev_id(), Kevin Wolf, 2019/10/17
- [RFC PATCH 06/18] qemu-storage-daemon: Add --nbd-server option, Kevin Wolf, 2019/10/17
- [RFC PATCH 08/18] qemu-storage-daemon: Add --export option, Kevin Wolf, 2019/10/17
- [RFC PATCH 11/18] monitor: Move monitor option parsing to monitor/monitor.c, Kevin Wolf, 2019/10/17
- [RFC PATCH 10/18] qemu-storage-daemon: Add --chardev option, Kevin Wolf, 2019/10/17
- [RFC PATCH 12/18] stubs: Update monitor stubs for qemu-storage-daemon, Kevin Wolf, 2019/10/17
- [RFC PATCH 09/18] qemu-storage-daemon: Add main loop, Kevin Wolf, 2019/10/17
- [RFC PATCH 07/18] blockdev-nbd: Boxed argument type for nbd-server-add, Kevin Wolf, 2019/10/17