From patchwork Mon Nov 12 07:06:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)\" via" X-Patchwork-Id: 10678235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3985F1759 for ; Mon, 12 Nov 2018 07:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2951E29FB6 for ; Mon, 12 Nov 2018 07:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CFC129FC1; Mon, 12 Nov 2018 07:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B165629FBC for ; Mon, 12 Nov 2018 07:08:41 +0000 (UTC) Received: from localhost ([::1]:45091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gM6Ku-0002WV-Sz for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Nov 2018 02:08:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gM6Jd-00085E-8R for qemu-devel@nongnu.org; Mon, 12 Nov 2018 02:07:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gM6JZ-0004DZ-Hl for qemu-devel@nongnu.org; Mon, 12 Nov 2018 02:07:18 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:35598) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1gM6JT-0003kE-8j; Mon, 12 Nov 2018 02:07:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1542006431; x=1573542431; h=from:to:cc:subject:date:message-id; bh=yqww3xNb6FSa6LAXrNWtVnzGsfxec677dt8cxPzb3WM=; b=UzM23vRR/AYIplkbNSuQYZmov+D0wYm/ldCTfaxWYn7ZrkBNIV96l5JV iatOroZ6ELlpvhQ1bP74xHptn8KJw6uPeSwRWpUSAYV9A2N1LRuvT6iTq bllCHrtYS91V5ipMXP4RhxaIOZXqvwMysL7LYQVSB+9hmmXVwdh4nEgUH 0=; X-IronPort-AV: E=Sophos;i="5.54,494,1534809600"; d="scan'208";a="764611644" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Nov 2018 07:07:07 +0000 Received: from ue4a4719f239757c4d2ec.ant.amazon.com (iad7-ws-svc-lb50-vlan3.amazon.com [10.0.93.214]) by email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id wAC774ZU030082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Nov 2018 07:07:05 GMT Received: from ue4a4719f239757c4d2ec.ant.amazon.com (localhost [127.0.0.1]) by ue4a4719f239757c4d2ec.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id wAC773JS030100; Sun, 11 Nov 2018 23:07:03 -0800 Received: (from marcolso@localhost) by ue4a4719f239757c4d2ec.ant.amazon.com (8.15.2/8.15.2/Submit) id wAC772dw030095; Sun, 11 Nov 2018 23:07:02 -0800 To: qemu-devel@nongnu.org Date: Sun, 11 Nov 2018 23:06:36 -0800 Message-Id: <1542006398-30037-1-git-send-email-marcolso@amazon.com> X-Mailer: git-send-email 2.7.4 Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 207.171.190.10 Subject: [Qemu-devel] [PATCH v3 1/3] blkdebug: fix one shot rule processing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Marc Olson via Qemu-devel From: "Gonglei (Arei)\" via" Reply-To: Marc Olson Cc: Kevin Wolf , Marc Olson , jsnow@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If 'once' is specified, the rule should execute just once, regardless if it is supposed to return an error or not. Take the example where you want the first IO to an LBA to succeed, but subsequent IOs to fail. You could either use state transitions, or create two rules, one with error = 0 and once set to true, and one with a non-zero error. Signed-off-by: Marc Olson Reviewed-by: John Snow Reviewed-by: Max Reitz --- block/blkdebug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 0759452..327049b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -488,7 +488,7 @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes) } } - if (!rule || !rule->options.inject.error) { + if (!rule) { return 0; } @@ -500,7 +500,7 @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes) remove_rule(rule); } - if (!immediately) { + if (error && !immediately) { aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_self()); qemu_coroutine_yield(); }