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