qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 4/7] iothread: command-line option


From: Stefan Hajnoczi
Subject: [Qemu-devel] [RFC 4/7] iothread: command-line option
Date: Thu, 12 Dec 2013 14:19:41 +0100

The -object option has several limitations that prevent it from fully
instantiating an IOThread.  Igor Mammedov and Paolo Bonzini are fixing
-object.

In the meantime, add a traditional -iothread command-line option that
takes an identifier and keeps a global list of IOThreads.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 include/sysemu/iothread.h |  1 +
 include/sysemu/sysemu.h   |  1 +
 iothread.c                | 37 +++++++++++++++++++++++++++++++++++++
 qemu-options.hx           |  8 ++++++++
 vl.c                      | 12 ++++++++++++
 5 files changed, 59 insertions(+)

diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index 8c49bd6..a4fcb61 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -24,6 +24,7 @@ typedef struct IOThread IOThread;
 #define IOTHREAD(obj) \
    OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
 
+int iothread_init(void);
 IOThread *iothread_find(const char *id);
 char *iothread_get_id(IOThread *iothread);
 AioContext *iothread_get_aio_context(IOThread *iothread);
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 495dae8..77117cf 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -202,5 +202,6 @@ extern QemuOptsList qemu_netdev_opts;
 extern QemuOptsList qemu_net_opts;
 extern QemuOptsList qemu_global_opts;
 extern QemuOptsList qemu_mon_opts;
+extern QemuOptsList qemu_iothread_opts;
 
 #endif
diff --git a/iothread.c b/iothread.c
index dbc6047..8b2c0ef 100644
--- a/iothread.c
+++ b/iothread.c
@@ -12,6 +12,9 @@
  */
 
 #include "qom/object.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/config-file.h"
+#include "qemu/option.h"
 #include "qemu/module.h"
 #include "qemu/thread.h"
 #include "block/aio.h"
@@ -113,3 +116,37 @@ AioContext *iothread_get_aio_context(IOThread *iothread)
 {
     return iothread->ctx;
 }
+
+QemuOptsList qemu_iothread_opts = {
+    .name = "iothread",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_iothread_opts.head),
+    .desc = {
+        {
+            .name = "id",
+            .type = QEMU_OPT_STRING,
+            .help = "iothread identifier",
+        },
+        { /* end of list */ }
+    },
+};
+
+static int iothread_init_opts(QemuOpts *opts, void *opaque)
+{
+    Object *obj;
+    const char *id;
+
+    id = qemu_opts_id(opts);
+    if (iothread_find(id)) {
+        return -EEXIST;
+    }
+    obj = object_new(TYPE_IOTHREAD);
+    object_property_add_child(container_get(object_get_root(), IOTHREADS_PATH),
+                              id, obj, NULL);
+    return 0;
+}
+
+int iothread_init(void)
+{
+    return qemu_opts_foreach(qemu_find_opts("iothread"),
+                             iothread_init_opts, NULL, 1);
+}
diff --git a/qemu-options.hx b/qemu-options.hx
index af34483..6e29da1 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3123,6 +3123,14 @@ STEXI
 prepend a timestamp to each log message.(default:on)
 ETEXI
 
+DEF("iothread", HAS_ARG, QEMU_OPTION_iothread,
+    "-iothread id=id\n", QEMU_ARCH_ALL)
+STEXI
address@hidden -iothread id=id
address@hidden -iothread
+Run an event loop thread that devices can be bound to.
+ETEXI
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
diff --git a/vl.c b/vl.c
index b0399de..55304dc 100644
--- a/vl.c
+++ b/vl.c
@@ -167,6 +167,7 @@ int main(int argc, char **argv)
 #include "sysemu/cpus.h"
 #include "sysemu/arch_init.h"
 #include "qemu/osdep.h"
+#include "sysemu/iothread.h"
 
 #include "ui/qemu-spice.h"
 #include "qapi/string-input-visitor.h"
@@ -2890,6 +2891,7 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_tpmdev_opts);
     qemu_add_opts(&qemu_realtime_opts);
     qemu_add_opts(&qemu_msg_opts);
+    qemu_add_opts(&qemu_iothread_opts);
 
     runstate_init();
 
@@ -3796,6 +3798,12 @@ int main(int argc, char **argv, char **envp)
                 }
                 configure_msg(opts);
                 break;
+            case QEMU_OPTION_iothread:
+                opts = qemu_opts_parse(qemu_find_opts("iothread"), optarg, 0);
+                if (!opts) {
+                    exit(1);
+                }
+                break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
             }
@@ -4102,6 +4110,10 @@ int main(int argc, char **argv, char **envp)
     qemu_init_cpu_loop();
     qemu_mutex_lock_iothread();
 
+    if (iothread_init() < 0) {
+        exit(1);
+    }
+
 #ifdef CONFIG_SPICE
     /* spice needs the timers to be initialized by this point */
     qemu_spice_init();
-- 
1.8.4.2




reply via email to

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