Blame SOURCES/kvm-iothread-Make-iothread_stop-idempotent.patch

9bac43
From aad2de527db618942ce1f5cad0d9c2e29ec42f2e Mon Sep 17 00:00:00 2001
9bac43
From: Eduardo Habkost <ehabkost@redhat.com>
9bac43
Date: Thu, 19 Oct 2017 01:34:50 +0200
9bac43
Subject: [PATCH 61/69] iothread: Make iothread_stop() idempotent
9bac43
9bac43
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
9bac43
Message-id: <20171019013453.21449-2-ehabkost@redhat.com>
9bac43
Patchwork-id: 77367
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 1/4] iothread: Make iothread_stop() idempotent
9bac43
Bugzilla: 1460848
9bac43
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9bac43
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
9bac43
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
9bac43
Currently, iothread_stop_all() makes all iothread objects unsafe
9bac43
to be destroyed, because qemu_thread_join() ends up being called
9bac43
twice.
9bac43
9bac43
To fix this, make iothread_stop() idempotent by checking
9bac43
thread->stopped.
9bac43
9bac43
Fixes the following crash:
9bac43
9bac43
  qemu-system-x86_64 -object iothread,id=iothread0 -monitor stdio -display none
9bac43
  QEMU 2.10.50 monitor - type 'help' for more information
9bac43
  (qemu) quit
9bac43
  qemu: qemu_thread_join: No such process
9bac43
  Aborted (core dumped)
9bac43
9bac43
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
9bac43
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
9bac43
Message-Id: <20170926130028.12471-1-ehabkost@redhat.com>
9bac43
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
(cherry picked from commit 65072c157e466db2785748a929e775703b20eefe)
9bac43
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 iothread.c | 2 +-
9bac43
 1 file changed, 1 insertion(+), 1 deletion(-)
9bac43
9bac43
diff --git a/iothread.c b/iothread.c
9bac43
index beeb870..d67bdd4 100644
9bac43
--- a/iothread.c
9bac43
+++ b/iothread.c
9bac43
@@ -68,7 +68,7 @@ static int iothread_stop(Object *object, void *opaque)
9bac43
     IOThread *iothread;
9bac43
 
9bac43
     iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
9bac43
-    if (!iothread || !iothread->ctx) {
9bac43
+    if (!iothread || !iothread->ctx || iothread->stopping) {
9bac43
         return 0;
9bac43
     }
9bac43
     iothread->stopping = true;
9bac43
-- 
9bac43
1.8.3.1
9bac43