Blame SOURCES/kvm-iothread-add-iothread_by_id-API.patch

4a2fec
From 84bd8f0e4da949579b20ea0879c8b44404ef2604 Mon Sep 17 00:00:00 2001
4a2fec
From: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Date: Fri, 22 Dec 2017 11:08:54 +0100
4a2fec
Subject: [PATCH 36/42] iothread: add iothread_by_id() API
4a2fec
4a2fec
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-id: <20171222110900.24813-15-stefanha@redhat.com>
4a2fec
Patchwork-id: 78498
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 14/20] iothread: add iothread_by_id() API
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
Encapsulate IOThread QOM object lookup so that callers don't need to
4a2fec
know how and where IOThread objects live.
4a2fec
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
Message-id: 20171206144550.22295-8-stefanha@redhat.com
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
(cherry picked from commit fbcc6923b00c2b468a7470fec7863f0403a65736)
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 include/sysemu/iothread.h | 1 +
4a2fec
 iothread.c                | 7 +++++++
4a2fec
 2 files changed, 8 insertions(+)
4a2fec
4a2fec
diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
4a2fec
index 110329b..55de171 100644
4a2fec
--- a/include/sysemu/iothread.h
4a2fec
+++ b/include/sysemu/iothread.h
4a2fec
@@ -42,6 +42,7 @@ typedef struct {
4a2fec
    OBJECT_CHECK(IOThread, obj, TYPE_IOTHREAD)
4a2fec
 
4a2fec
 char *iothread_get_id(IOThread *iothread);
4a2fec
+IOThread *iothread_by_id(const char *id);
4a2fec
 AioContext *iothread_get_aio_context(IOThread *iothread);
4a2fec
 void iothread_stop_all(void);
4a2fec
 GMainContext *iothread_get_g_main_context(IOThread *iothread);
4a2fec
diff --git a/iothread.c b/iothread.c
4a2fec
index 27a4288..e7b93e0 100644
4a2fec
--- a/iothread.c
4a2fec
+++ b/iothread.c
4a2fec
@@ -380,3 +380,10 @@ void iothread_destroy(IOThread *iothread)
4a2fec
 {
4a2fec
     object_unparent(OBJECT(iothread));
4a2fec
 }
4a2fec
+
4a2fec
+/* Lookup IOThread by its id.  Only finds user-created objects, not internal
4a2fec
+ * iothread_create() objects. */
4a2fec
+IOThread *iothread_by_id(const char *id)
4a2fec
+{
4a2fec
+    return IOTHREAD(object_resolve_path_type(id, TYPE_IOTHREAD, NULL));
4a2fec
+}
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec