qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [RFC 4/7] iothread: command-line option
Date: Thu, 12 Dec 2013 14:19:41 +0100	[thread overview]
Message-ID: <1386854384-1992-5-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1386854384-1992-1-git-send-email-stefanha@redhat.com>

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 <stefanha@redhat.com>
---
 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
+@item -iothread id=id
+@findex -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

  parent reply	other threads:[~2013-12-12 13:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 13:19 [Qemu-devel] [RFC 0/7] dataplane: switch to N:M devices-per-thread model Stefan Hajnoczi
2013-12-12 13:19 ` [Qemu-devel] [RFC 1/7] rfifolock: add recursive FIFO lock Stefan Hajnoczi
2013-12-12 13:19 ` [Qemu-devel] [RFC 2/7] aio: add aio_context_acquire() and aio_context_release() Stefan Hajnoczi
2013-12-12 13:19 ` [Qemu-devel] [RFC 3/7] iothread: add I/O thread object Stefan Hajnoczi
2013-12-12 18:00   ` Michael Roth
2013-12-13  9:20     ` Stefan Hajnoczi
2013-12-12 13:19 ` Stefan Hajnoczi [this message]
2013-12-12 13:19 ` [Qemu-devel] [RFC 5/7] qdev: add get_pointer_and_free() for temporary strings Stefan Hajnoczi
2013-12-12 13:19 ` [Qemu-devel] [RFC 6/7] iothread: add "iothread" qdev property type Stefan Hajnoczi
2013-12-12 13:19 ` [Qemu-devel] [RFC 7/7] dataplane: replace internal thread with IOThread Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386854384-1992-5-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).