Blame SOURCES/kvm-iothread-fix-crash-with-invalid-properties.patch

383d26
From 6470ace7aae0d6e76e8ca8cc450085a502877250 Mon Sep 17 00:00:00 2001
383d26
From: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Date: Wed, 28 Nov 2018 16:04:27 +0100
383d26
Subject: [PATCH 17/34] iothread: fix crash with invalid properties
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Message-id: <20181128160427.7389-2-stefanha@redhat.com>
383d26
Patchwork-id: 83183
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/1] iothread: fix crash with invalid properties
383d26
Bugzilla: 1607768
383d26
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
383d26
RH-Acked-by: Peter Xu <peterx@redhat.com>
383d26
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
383d26
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
383d26
383d26
From: Marc-André Lureau <marcandre.lureau@redhat.com>
383d26
383d26
-object iothread,id=foo,? will crash qemu:
383d26
383d26
qemu-system-x86_64:qemu-thread-posix.c:128: qemu_cond_destroy: Assertion `cond->initialized' failed.
383d26
383d26
Use thread_id != -1 to check if iothread_complete() finished
383d26
successfully and the mutex/cond have been initialized.
383d26
383d26
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
383d26
Message-Id: <20180821100716.13803-1-marcandre.lureau@redhat.com>
383d26
Signed-off-by: Fam Zheng <famz@redhat.com>
383d26
(cherry picked from commit 14a2d11825ddc37d6547a80704ae6450e9e376c7)
383d26
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 iothread.c | 9 ++++++---
383d26
 1 file changed, 6 insertions(+), 3 deletions(-)
383d26
383d26
diff --git a/iothread.c b/iothread.c
383d26
index aff1281..2fb1cdf 100644
383d26
--- a/iothread.c
383d26
+++ b/iothread.c
383d26
@@ -110,6 +110,7 @@ static void iothread_instance_init(Object *obj)
383d26
     IOThread *iothread = IOTHREAD(obj);
383d26
 
383d26
     iothread->poll_max_ns = IOTHREAD_POLL_MAX_NS_DEFAULT;
383d26
+    iothread->thread_id = -1;
383d26
 }
383d26
 
383d26
 static void iothread_instance_finalize(Object *obj)
383d26
@@ -117,6 +118,11 @@ static void iothread_instance_finalize(Object *obj)
383d26
     IOThread *iothread = IOTHREAD(obj);
383d26
 
383d26
     iothread_stop(iothread);
383d26
+
383d26
+    if (iothread->thread_id != -1) {
383d26
+        qemu_cond_destroy(&iothread->init_done_cond);
383d26
+        qemu_mutex_destroy(&iothread->init_done_lock);
383d26
+    }
383d26
     /*
383d26
      * Before glib2 2.33.10, there is a glib2 bug that GSource context
383d26
      * pointer may not be cleared even if the context has already been
383d26
@@ -135,8 +141,6 @@ static void iothread_instance_finalize(Object *obj)
383d26
         g_main_context_unref(iothread->worker_context);
383d26
         iothread->worker_context = NULL;
383d26
     }
383d26
-    qemu_cond_destroy(&iothread->init_done_cond);
383d26
-    qemu_mutex_destroy(&iothread->init_done_lock);
383d26
 }
383d26
 
383d26
 static void iothread_complete(UserCreatable *obj, Error **errp)
383d26
@@ -147,7 +151,6 @@ static void iothread_complete(UserCreatable *obj, Error **errp)
383d26
 
383d26
     iothread->stopping = false;
383d26
     iothread->running = true;
383d26
-    iothread->thread_id = -1;
383d26
     iothread->ctx = aio_context_new(&local_error);
383d26
     if (!iothread->ctx) {
383d26
         error_propagate(errp, local_error);
383d26
-- 
383d26
1.8.3.1
383d26