From patchwork Fri Aug 15 17:06:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 380338 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 196D3140093 for ; Sat, 16 Aug 2014 03:08:04 +1000 (EST) Received: from localhost ([::1]:60595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKyw-0006OH-2B for incoming@patchwork.ozlabs.org; Fri, 15 Aug 2014 13:08:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKyD-0005CB-Im for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIKy7-0008IT-DX for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:07:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKy7-0008IP-5d for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:07:11 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7FH77nl024894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Aug 2014 13:07:08 -0400 Received: from localhost (ovpn-112-32.ams2.redhat.com [10.36.112.32]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7FH76rB001165; Fri, 15 Aug 2014 13:07:07 -0400 From: Stefan Hajnoczi To: Date: Fri, 15 Aug 2014 18:06:08 +0100 Message-Id: <1408122422-13935-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1408122422-13935-1-git-send-email-stefanha@redhat.com> References: <1408122422-13935-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , John Snow , Stefan Hajnoczi , Paolo Bonzini Subject: [Qemu-devel] [PULL 01/55] blkdebug: report errors on flush too X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: John Snow Signed-off-by: Stefan Hajnoczi --- block/blkdebug.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index f51407d..1586ed9 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -522,6 +522,25 @@ static BlockDriverAIOCB *blkdebug_aio_writev(BlockDriverState *bs, return bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors, cb, opaque); } +static BlockDriverAIOCB *blkdebug_aio_flush(BlockDriverState *bs, + BlockDriverCompletionFunc *cb, void *opaque) +{ + BDRVBlkdebugState *s = bs->opaque; + BlkdebugRule *rule = NULL; + + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { + if (rule->options.inject.sector == -1) { + break; + } + } + + if (rule && rule->options.inject.error) { + return inject_error(bs, cb, opaque, rule); + } + + return bdrv_aio_flush(bs->file, cb, opaque); +} + static void blkdebug_close(BlockDriverState *bs) { @@ -699,6 +718,7 @@ static BlockDriver bdrv_blkdebug = { .bdrv_aio_readv = blkdebug_aio_readv, .bdrv_aio_writev = blkdebug_aio_writev, + .bdrv_aio_flush = blkdebug_aio_flush, .bdrv_debug_event = blkdebug_debug_event, .bdrv_debug_breakpoint = blkdebug_debug_breakpoint,