Blame SOURCES/kvm-iothread-provide-helpers-for-internal-use.patch

4a2fec
From a709d66bc6e7b3559fbd8502c6f94b76b6a899d1 Mon Sep 17 00:00:00 2001
4a2fec
From: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Date: Fri, 22 Dec 2017 11:08:45 +0100
4a2fec
Subject: [PATCH 27/42] iothread: provide helpers for internal use
4a2fec
4a2fec
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-id: <20171222110900.24813-6-stefanha@redhat.com>
4a2fec
Patchwork-id: 78487
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 05/20] iothread: provide helpers for internal use
4a2fec
Bugzilla: 1519721
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: Peter Xu <peterx@redhat.com>
4a2fec
4a2fec
IOThread is a general framework that contains IO loop environment and a
4a2fec
real thread behind.  It's also good to be used internally inside qemu.
4a2fec
Provide some helpers for it to create iothreads to be used internally.
4a2fec
4a2fec
Put all the internal used iothreads into the internal object container.
4a2fec
4a2fec
Reviewed-by: Fam Zheng <famz@redhat.com>
4a2fec
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Peter Xu <peterx@redhat.com>
4a2fec
Message-id: 20170928025958.1420-3-peterx@redhat.com
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
(cherry picked from commit 0173e21b617d3de1fcfa917e329bb9194ab332a4)
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 include/sysemu/iothread.h |  8 ++++++++
4a2fec
 iothread.c                | 16 ++++++++++++++++
4a2fec
 2 files changed, 24 insertions(+)
4a2fec
4a2fec
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
4a2fec
index d2985b3..b07663f 100644
4a2fec
--- a/include/sysemu/iothread.h
4a2fec
+++ b/include/sysemu/iothread.h
4a2fec
@@ -46,4 +46,12 @@ AioContext *iothread_get_aio_context(IOThread *iothread);
4a2fec
 void iothread_stop_all(void);
4a2fec
 GMainContext *iothread_get_g_main_context(IOThread *iothread);
4a2fec
 
4a2fec
+/*
4a2fec
+ * Helpers used to allocate iothreads for internal use.  These
4a2fec
+ * iothreads will not be seen by monitor clients when query using
4a2fec
+ * "query-iothreads".
4a2fec
+ */
4a2fec
+IOThread *iothread_create(const char *id, Error **errp);
4a2fec
+void iothread_destroy(IOThread *iothread);
4a2fec
+
4a2fec
 #endif /* IOTHREAD_H */
4a2fec
diff --git a/iothread.c b/iothread.c
4a2fec
index 59d0850..0672a91 100644
4a2fec
--- a/iothread.c
4a2fec
+++ b/iothread.c
4a2fec
@@ -354,3 +354,19 @@ GMainContext *iothread_get_g_main_context(IOThread *iothread)
4a2fec
 
4a2fec
     return iothread->worker_context;
4a2fec
 }
4a2fec
+
4a2fec
+IOThread *iothread_create(const char *id, Error **errp)
4a2fec
+{
4a2fec
+    Object *obj;
4a2fec
+
4a2fec
+    obj = object_new_with_props(TYPE_IOTHREAD,
4a2fec
+                                object_get_internal_root(),
4a2fec
+                                id, errp, NULL);
4a2fec
+
4a2fec
+    return IOTHREAD(obj);
4a2fec
+}
4a2fec
+
4a2fec
+void iothread_destroy(IOThread *iothread)
4a2fec
+{
4a2fec
+    object_unparent(OBJECT(iothread));
4a2fec
+}
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec