From patchwork Fri Jun 23 16:21:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 780077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wvNzK41vdz9s8P for ; Sat, 24 Jun 2017 02:23:09 +1000 (AEST) Received: from localhost ([::1]:36211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dORMR-0000fi-4F for incoming@patchwork.ozlabs.org; Fri, 23 Jun 2017 12:23:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dORLY-0000Jq-4u for qemu-devel@nongnu.org; Fri, 23 Jun 2017 12:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dORLX-0007RS-B4 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 12:22:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56746) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dORLV-0007Pt-9V; Fri, 23 Jun 2017 12:22:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 541B4C0587EB; Fri, 23 Jun 2017 16:22:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 541B4C0587EB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kwolf@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 541B4C0587EB Received: from noname.redhat.com (ovpn-117-196.ams2.redhat.com [10.36.117.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CCF56EC75; Fri, 23 Jun 2017 16:22:07 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 23 Jun 2017 18:21:02 +0200 Message-Id: <1498234919-27316-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1498234919-27316-1-git-send-email-kwolf@redhat.com> References: <1498234919-27316-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 23 Jun 2017 16:22:08 +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 04/61] block: count bdrv_co_rw_vmstate() requests 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: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Call bdrv_inc/dec_in_flight() for vmstate reads/writes. This seems unnecessary at first glance because vmstate reads/writes are done synchronously while the guest is stopped. But we need the bdrv_wakeup() in bdrv_dec_in_flight() so the main loop sees request completion. Besides, it's cleaner to count vmstate reads/writes like ordinary read/write requests. The bdrv_wakeup() partially fixes a 'savevm' hang with -object iothread. Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- block/io.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/block/io.c b/block/io.c index 91611ff..684ea46 100644 --- a/block/io.c +++ b/block/io.c @@ -1980,17 +1980,24 @@ bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) { BlockDriver *drv = bs->drv; + int ret = -ENOTSUP; + + bdrv_inc_in_flight(bs); if (!drv) { - return -ENOMEDIUM; + ret = -ENOMEDIUM; } else if (drv->bdrv_load_vmstate) { - return is_read ? drv->bdrv_load_vmstate(bs, qiov, pos) - : drv->bdrv_save_vmstate(bs, qiov, pos); + if (is_read) { + ret = drv->bdrv_load_vmstate(bs, qiov, pos); + } else { + ret = drv->bdrv_save_vmstate(bs, qiov, pos); + } } else if (bs->file) { - return bdrv_co_rw_vmstate(bs->file->bs, qiov, pos, is_read); + ret = bdrv_co_rw_vmstate(bs->file->bs, qiov, pos, is_read); } - return -ENOTSUP; + bdrv_dec_in_flight(bs); + return ret; } static void coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque)