qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]