From nobody Mon Apr 29 08:36:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494599946398253.6014027394715; Fri, 12 May 2017 07:39:06 -0700 (PDT) Received: from localhost ([::1]:54057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Bih-0005cW-W0 for importer@patchew.org; Fri, 12 May 2017 10:39:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BhA-0004XI-BM for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9Bh8-0004iD-HV for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32964) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9Bh8-0004hC-7z for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35FB0804E2; Fri, 12 May 2017 14:37:25 +0000 (UTC) Received: from localhost (ovpn-116-191.ams2.redhat.com [10.36.116.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 674FA7D52D; Fri, 12 May 2017 14:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 35FB0804E2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 35FB0804E2 From: Stefan Hajnoczi To: Date: Fri, 12 May 2017 10:37:15 -0400 Message-Id: <20170512143717.30391-2-stefanha@redhat.com> In-Reply-To: <20170512143717.30391-1-stefanha@redhat.com> References: <20170512143717.30391-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 12 May 2017 14:37:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 1/3] coroutine: remove GThread implementation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The GThread implementation is not functional enough to actually run QEMU reliably. While it was potentially useful for debugging, we have a scripts/qemugdb/coroutine.py to enable tracing of ucontext coroutines in GDB, so that removes the only reason for GThread to exist. Signed-off-by: Daniel P. Berrange Acked-by: Alex Benn=C3=A9e Signed-off-by: Stefan Hajnoczi --- configure | 19 ++--- util/coroutine-gthread.c | 198 -------------------------------------------= ---- .travis.yml | 5 +- 3 files changed, 6 insertions(+), 216 deletions(-) delete mode 100644 util/coroutine-gthread.c diff --git a/configure b/configure index 7c020c0..39e727e 100755 --- a/configure +++ b/configure @@ -1334,7 +1334,7 @@ Advanced options (experts only): --oss-lib path to OSS library --cpu=3DCPU Build for host CPU [$cpu] --with-coroutine=3DBACKEND coroutine backend. Supported options: - gthread, ucontext, sigaltstack, windows + ucontext, sigaltstack, windows --enable-gcov enable test coverage analysis with gcov --gcov=3DGCOV use specified gcov [$gcov_tool] --disable-blobs disable installing provided firmware blobs @@ -4418,10 +4418,8 @@ fi # check and set a backend for coroutine =20 # We prefer ucontext, but it's not always possible. The fallback -# is sigcontext. gthread is not selectable except explicitly, because -# it is not functional enough to run QEMU proper. (It is occasionally -# useful for debugging purposes.) On Windows the only valid backend -# is the Windows-specific one. +# is sigcontext. On Windows the only valid backend is the Windows +# specific one. =20 ucontext_works=3Dno if test "$darwin" !=3D "yes"; then @@ -4460,7 +4458,7 @@ else feature_not_found "ucontext" fi ;; - gthread|sigaltstack) + sigaltstack) if test "$mingw32" =3D "yes"; then error_exit "only the 'windows' coroutine backend is valid for Window= s" fi @@ -4472,14 +4470,7 @@ else fi =20 if test "$coroutine_pool" =3D ""; then - if test "$coroutine" =3D "gthread"; then - coroutine_pool=3Dno - else - coroutine_pool=3Dyes - fi -fi -if test "$coroutine" =3D "gthread" -a "$coroutine_pool" =3D "yes"; then - error_exit "'gthread' coroutine backend does not support pool (use --dis= able-coroutine-pool)" + coroutine_pool=3Dyes fi =20 if test "$debug_stack_usage" =3D "yes"; then diff --git a/util/coroutine-gthread.c b/util/coroutine-gthread.c deleted file mode 100644 index 62bfb40..0000000 --- a/util/coroutine-gthread.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * GThread coroutine initialization code - * - * Copyright (C) 2006 Anthony Liguori - * Copyright (C) 2011 Aneesh Kumar K.V - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.0 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "qemu/osdep.h" -#include "qemu-common.h" -#include "qemu/coroutine_int.h" - -typedef struct { - Coroutine base; - GThread *thread; - bool runnable; - bool free_on_thread_exit; - CoroutineAction action; -} CoroutineGThread; - -static CompatGMutex coroutine_lock; -static CompatGCond coroutine_cond; - -/* GLib 2.31 and beyond deprecated various parts of the thread API, - * but the new interfaces are not available in older GLib versions - * so we have to cope with both. - */ -#if GLIB_CHECK_VERSION(2, 31, 0) -/* Awkwardly, the GPrivate API doesn't provide a way to update the - * GDestroyNotify handler for the coroutine key dynamically. So instead - * we track whether or not the CoroutineGThread should be freed on - * thread exit / coroutine key update using the free_on_thread_exit - * field. - */ -static void coroutine_destroy_notify(gpointer data) -{ - CoroutineGThread *co =3D data; - if (co && co->free_on_thread_exit) { - g_free(co); - } -} - -static GPrivate coroutine_key =3D G_PRIVATE_INIT(coroutine_destroy_notify); - -static inline CoroutineGThread *get_coroutine_key(void) -{ - return g_private_get(&coroutine_key); -} - -static inline void set_coroutine_key(CoroutineGThread *co, - bool free_on_thread_exit) -{ - /* Unlike g_static_private_set() this does not call the GDestroyNotify - * if the previous value of the key was NULL. Fortunately we only need - * the GDestroyNotify in the non-NULL key case. - */ - co->free_on_thread_exit =3D free_on_thread_exit; - g_private_replace(&coroutine_key, co); -} - -static inline GThread *create_thread(GThreadFunc func, gpointer data) -{ - return g_thread_new("coroutine", func, data); -} - -#else - -/* Handle older GLib versions */ - -static GStaticPrivate coroutine_key =3D G_STATIC_PRIVATE_INIT; - -static inline CoroutineGThread *get_coroutine_key(void) -{ - return g_static_private_get(&coroutine_key); -} - -static inline void set_coroutine_key(CoroutineGThread *co, - bool free_on_thread_exit) -{ - g_static_private_set(&coroutine_key, co, - free_on_thread_exit ? (GDestroyNotify)g_free : NU= LL); -} - -static inline GThread *create_thread(GThreadFunc func, gpointer data) -{ - return g_thread_create_full(func, data, 0, TRUE, TRUE, - G_THREAD_PRIORITY_NORMAL, NULL); -} - -#endif - - -static void __attribute__((constructor)) coroutine_init(void) -{ -#if !GLIB_CHECK_VERSION(2, 31, 0) - if (!g_thread_supported()) { - g_thread_init(NULL); - } -#endif -} - -static void coroutine_wait_runnable_locked(CoroutineGThread *co) -{ - while (!co->runnable) { - g_cond_wait(&coroutine_cond, &coroutine_lock); - } -} - -static void coroutine_wait_runnable(CoroutineGThread *co) -{ - g_mutex_lock(&coroutine_lock); - coroutine_wait_runnable_locked(co); - g_mutex_unlock(&coroutine_lock); -} - -static gpointer coroutine_thread(gpointer opaque) -{ - CoroutineGThread *co =3D opaque; - - set_coroutine_key(co, false); - coroutine_wait_runnable(co); - co->base.entry(co->base.entry_arg); - qemu_coroutine_switch(&co->base, co->base.caller, COROUTINE_TERMINATE); - return NULL; -} - -Coroutine *qemu_coroutine_new(void) -{ - CoroutineGThread *co; - - co =3D g_malloc0(sizeof(*co)); - co->thread =3D create_thread(coroutine_thread, co); - if (!co->thread) { - g_free(co); - return NULL; - } - return &co->base; -} - -void qemu_coroutine_delete(Coroutine *co_) -{ - CoroutineGThread *co =3D DO_UPCAST(CoroutineGThread, base, co_); - - g_thread_join(co->thread); - g_free(co); -} - -CoroutineAction qemu_coroutine_switch(Coroutine *from_, - Coroutine *to_, - CoroutineAction action) -{ - CoroutineGThread *from =3D DO_UPCAST(CoroutineGThread, base, from_); - CoroutineGThread *to =3D DO_UPCAST(CoroutineGThread, base, to_); - - g_mutex_lock(&coroutine_lock); - from->runnable =3D false; - from->action =3D action; - to->runnable =3D true; - to->action =3D action; - g_cond_broadcast(&coroutine_cond); - - if (action !=3D COROUTINE_TERMINATE) { - coroutine_wait_runnable_locked(from); - } - g_mutex_unlock(&coroutine_lock); - return from->action; -} - -Coroutine *qemu_coroutine_self(void) -{ - CoroutineGThread *co =3D get_coroutine_key(); - if (!co) { - co =3D g_malloc0(sizeof(*co)); - co->runnable =3D true; - set_coroutine_key(co, true); - } - - return &co->base; -} - -bool qemu_in_coroutine(void) -{ - CoroutineGThread *co =3D get_coroutine_key(); - - return co && co->base.caller; -} diff --git a/.travis.yml b/.travis.yml index 9008a79..27a2d9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,9 +86,6 @@ matrix: - env: CONFIG=3D"--enable-trace-backends=3Dust" TEST_CMD=3D"" compiler: gcc - - env: CONFIG=3D"--with-coroutine=3Dgthread" - TEST_CMD=3D"" - compiler: gcc - env: CONFIG=3D"" os: osx compiler: clang @@ -191,7 +188,7 @@ matrix: compiler: none env: - COMPILER_NAME=3Dgcc CXX=3Dg++-5 CC=3Dgcc-5 - - CONFIG=3D"--cc=3Dgcc-5 --cxx=3Dg++-5 --disable-pie --disable-lin= ux-user --with-coroutine=3Dgthread" + - CONFIG=3D"--cc=3Dgcc-5 --cxx=3Dg++-5 --disable-pie --disable-lin= ux-user" - TEST_CMD=3D"" before_script: - ./configure ${CONFIG} --extra-cflags=3D"-g3 -O0 -fsanitize=3Dthr= ead -fuse-ld=3Dgold" || cat config.log --=20 2.9.3 From nobody Mon Apr 29 08:36:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494600051812335.7837182575515; Fri, 12 May 2017 07:40:51 -0700 (PDT) Received: from localhost ([::1]:54068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BkQ-00071C-5O for importer@patchew.org; Fri, 12 May 2017 10:40:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BhB-0004bg-Fb for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9BhA-0004jm-Mg for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9BhA-0004jY-GK for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7105480E7C; Fri, 12 May 2017 14:37:27 +0000 (UTC) Received: from localhost (ovpn-116-191.ams2.redhat.com [10.36.116.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA3327F384; Fri, 12 May 2017 14:37:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7105480E7C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7105480E7C From: Stefan Hajnoczi To: Date: Fri, 12 May 2017 10:37:16 -0400 Message-Id: <20170512143717.30391-3-stefanha@redhat.com> In-Reply-To: <20170512143717.30391-1-stefanha@redhat.com> References: <20170512143717.30391-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 12 May 2017 14:37:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 2/3] block: Simplify BDRV_BLOCK_RAW recursion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Since we are already in coroutine context during the body of bdrv_co_get_block_status(), we can shave off a few layers of wrappers when recursing to query the protocol when a format driver returned BDRV_BLOCK_RAW. Note that we are already using the correct recursion later on in the same function, when probing whether the protocol layer is sparse in order to find out if we can add BDRV_BLOCK_ZERO to an existing BDRV_BLOCK_DATA|BDRV_BLOCK_OFFSET_VALID. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Fam Zheng Message-id: 20170504173745.27414-1-eblake@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 40bd94f..fdd7485 100644 --- a/block/io.c +++ b/block/io.c @@ -1784,8 +1784,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(= BlockDriverState *bs, =20 if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID); - ret =3D bdrv_get_block_status(*file, ret >> BDRV_SECTOR_BITS, - *pnum, pnum, file); + ret =3D bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, + *pnum, pnum, file); goto out; } =20 --=20 2.9.3 From nobody Mon Apr 29 08:36:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494599953308714.1753156415907; Fri, 12 May 2017 07:39:13 -0700 (PDT) Received: from localhost ([::1]:54058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9Bio-0005gg-W2 for importer@patchew.org; Fri, 12 May 2017 10:39:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BhI-0004jk-FO for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9BhF-0004n4-D7 for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60197) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9BhF-0004mS-6l for qemu-devel@nongnu.org; Fri, 12 May 2017 10:37:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2815480C16; Fri, 12 May 2017 14:37:32 +0000 (UTC) Received: from localhost (ovpn-116-191.ams2.redhat.com [10.36.116.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE6B88B756; Fri, 12 May 2017 14:37:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2815480C16 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2815480C16 From: Stefan Hajnoczi To: Date: Fri, 12 May 2017 10:37:17 -0400 Message-Id: <20170512143717.30391-4-stefanha@redhat.com> In-Reply-To: <20170512143717.30391-1-stefanha@redhat.com> References: <20170512143717.30391-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 12 May 2017 14:37:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 3/3] aio: add missing aio_notify() to aio_enable_external() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The main loop uses aio_disable_external()/aio_enable_external() to temporarily disable processing of external AioContext clients like device emulation. This allows monitor commands to quiesce I/O and prevent the guest from submitting new requests while a monitor command is in progress. The aio_enable_external() API is currently broken when an IOThread is in aio_poll() waiting for fd activity when the main loop re-enables external clients. Incrementing ctx->external_disable_cnt does not wake the IOThread from ppoll(2) so fd processing remains suspended and leads to unresponsive emulated devices. This patch adds an aio_notify() call to aio_enable_external() so the IOThread is kicked out of ppoll(2) and will re-arm the file descriptors. The bug can be reproduced as follows: $ qemu -M accel=3Dkvm -m 1024 \ -object iothread,id=3Diothread0 \ -device virtio-scsi-pci,iothread=3Diothread0,id=3Dvirtio-scsi-pci0= \ -drive if=3Dnone,id=3Ddrive0,aio=3Dnative,cache=3Dnone,format=3Dra= w,file=3Dtest.img \ -device scsi-hd,id=3Dscsi-hd0,drive=3Ddrive0 \ -qmp tcp::5555,server,nowait $ scripts/qmp/qmp-shell localhost:5555 (qemu) blockdev-snapshot-sync device=3Ddrive0 snapshot-file=3Dsn1.qcow2 mode=3Dabsolute-paths format=3Dqcow2 After blockdev-snapshot-sync completes the SCSI disk will be unresponsive. This leads to request timeouts inside the guest. Reported-by: Qianqian Zhu Reviewed-by: Fam Zheng Signed-off-by: Stefan Hajnoczi Message-id: 20170508180705.20609-1-stefanha@redhat.com Suggested-by: Fam Zheng Signed-off-by: Stefan Hajnoczi --- include/block/aio.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index 406e323..e9aeeae 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -454,8 +454,14 @@ static inline void aio_disable_external(AioContext *ct= x) */ static inline void aio_enable_external(AioContext *ctx) { - assert(ctx->external_disable_cnt > 0); - atomic_dec(&ctx->external_disable_cnt); + int old; + + old =3D atomic_fetch_dec(&ctx->external_disable_cnt); + assert(old > 0); + if (old =3D=3D 1) { + /* Kick event loop so it re-arms file descriptors */ + aio_notify(ctx); + } } =20 /** --=20 2.9.3