From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158171097663423.636633055863058; Fri, 14 Feb 2020 12:09:36 -0800 (PST) Received: from localhost ([::1]:45104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hHK-0000h3-Uo for importer@patchew.org; Fri, 14 Feb 2020 15:09:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51862) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGM-0007KE-26 for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGL-0005KL-0l for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:33 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:49784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGK-0005Jl-Ti for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:32 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-ogWNrckxOhaHxW_zV6tdzQ-1; Fri, 14 Feb 2020 15:08:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40A8113E2; Fri, 14 Feb 2020 20:08:29 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 842E85C1C3; Fri, 14 Feb 2020 20:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vnZOS2oQ4H/J3ETSQGIB1Fm2xH6tBJ4x5xQUIco+SIc=; b=A99V4+UrHqWo3QBmizycXZpTSLvrY8TxzywSlT6PqlBkwtz7A4bjVZTO+lMo4tfEVhLsRh CEiuIDHLWlUM6VaaphHcdo+F0ihdP7v6r+3U/vrdlPrI941/YgzmbWRbbkaWj4ICN3Xiti JpsCN0nso4r/Jm0x9jSD12eeiNdqF98= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 1/7] qapi: Document meaning of 'ignore' BlockdevOnError for jobs Date: Fri, 14 Feb 2020 21:08:06 +0100 Message-Id: <20200214200812.28180-2-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: ogWNrckxOhaHxW_zV6tdzQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It is not obvious what 'ignore' actually means for block jobs: It could be continuing the job and returning success in the end despite the error (no block job does this). It could also mean continuing and returning failure in the end (this is what stream does). And it can mean retrying the failed request later (this is what backup, commit and mirror do). This (somewhat inconsistent) behaviour was introduced and described for stream and mirror in commit ae586d6158. backup and commit were introduced later and use the same model as mirror. Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- qapi/block-core.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index ef94a29686..395d205fa8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1164,7 +1164,10 @@ # for jobs, cancel the job # # @ignore: ignore the error, only report a QMP event (BLOCK_IO_ERROR -# or BLOCK_JOB_ERROR) +# or BLOCK_JOB_ERROR). The backup, mirror and commit block jobs r= etry +# the failing request later and may still complete successfully. = The +# stream block job continues to stream and will complete with an +# error. # # @enospc: same as @stop on ENOSPC, same as @report otherwise. # --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158171106433318.98522572169577; Fri, 14 Feb 2020 12:11:04 -0800 (PST) Received: from localhost ([::1]:45138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hIk-0003qD-Mt for importer@patchew.org; Fri, 14 Feb 2020 15:11:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51898) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGP-0007QU-9w for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGO-0005R7-BC for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:37 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32481 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGO-0005QV-7f for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-oj-uNuTfPsad8q9O5ZM01w-1; Fri, 14 Feb 2020 15:08:32 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1161E800D53; Fri, 14 Feb 2020 20:08:31 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A3125C1C3; Fri, 14 Feb 2020 20:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q+WJ9A0MdHS2JVaGI30bMN+WQVzGoxwouKYg1sBf3pI=; b=Mx28TSH9TvrWR7nv5SOQQAhM9LM3T9E8EaBZgqbwK/NhzCSg4t1s8lx2gi62kQJVTaZV9x rdN8B9URUVh50+UKCmJTEu1qxKQhyReO3Ppz5nw6I8eCL3gMtxgBDhZr7Kddp64tA6kCsZ AUYnR4E+jP57m3PwHITMbonHguIgg/0= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 2/7] commit: Remove unused bytes_written Date: Fri, 14 Feb 2020 21:08:07 +0100 Message-Id: <20200214200812.28180-3-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: oj-uNuTfPsad8q9O5ZM01w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The bytes_written variable is only ever written to, it serves no purpose. This has actually been the case since the commit job was first introduced in commit 747ff602636. Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- block/commit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/commit.c b/block/commit.c index 23c90b3b91..cce898a4f3 100644 --- a/block/commit.c +++ b/block/commit.c @@ -140,7 +140,6 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) int ret =3D 0; int64_t n =3D 0; /* bytes */ void *buf =3D NULL; - int bytes_written =3D 0; int64_t len, base_len; =20 ret =3D len =3D blk_getlength(s->top); @@ -180,7 +179,6 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) trace_commit_one_iteration(s, offset, n, ret); if (copy) { ret =3D commit_populate(s->top, s->base, offset, n, buf); - bytes_written +=3D n; } if (ret < 0) { BlockErrorAction action =3D --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158171117369256.14162529963562; Fri, 14 Feb 2020 12:12:53 -0800 (PST) Received: from localhost ([::1]:45190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hKW-0006qW-H9 for importer@patchew.org; Fri, 14 Feb 2020 15:12:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51929) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGR-0007Wa-8P for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGQ-0005UY-8A for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:39 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44191 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGQ-0005U3-48 for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-VU9e4SsjOQOSOfHS-QLFxQ-1; Fri, 14 Feb 2020 15:08:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4B03107ACC7; Fri, 14 Feb 2020 20:08:32 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A8765C1C3; Fri, 14 Feb 2020 20:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Dc4xDxLeU229aolKHiPPEcJW+xIohTddfln6Uvfj9w=; b=hHqfhU2Tg9F2SXYFmoYbJ9bf9usZgYkr1vv6pc3P/jJ825ZAAIRKgAiHXkOSLv+arCRjyO xR1iEgI+47UijP43h/cWT6n8199ZNViCdNzDQfsBuXLE3JreonQ+yxRHGhRxYO94ldzdxU e4mucLGOLbTkGzQkHe73fLu3RcqL+8s= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 3/7] commit: Fix argument order for block_job_error_action() Date: Fri, 14 Feb 2020 21:08:08 +0100 Message-Id: <20200214200812.28180-4-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: VU9e4SsjOQOSOfHS-QLFxQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The block_job_error_action() error call in the commit job gives the on_err and is_read arguments in the wrong order. Fix this. (Of course, hard-coded is_read =3D false is wrong, too, but that's a separate problem for a separate patch.) Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- block/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index cce898a4f3..8189f079d2 100644 --- a/block/commit.c +++ b/block/commit.c @@ -182,7 +182,7 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) } if (ret < 0) { BlockErrorAction action =3D - block_job_error_action(&s->common, false, s->on_error, -re= t); + block_job_error_action(&s->common, s->on_error, false, -re= t); if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { goto out; } else { --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581711064888867.8571924068002; Fri, 14 Feb 2020 12:11:04 -0800 (PST) Received: from localhost ([::1]:45140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hIl-0003u6-FL for importer@patchew.org; Fri, 14 Feb 2020 15:11:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51931) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGR-0007Wv-Br for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGQ-0005Uh-8i for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:39 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:40766 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGQ-0005Tx-3X for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-nnt9GtWROiSt9uWawC-G8A-1; Fri, 14 Feb 2020 15:08:35 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A46B1107ACC4; Fri, 14 Feb 2020 20:08:34 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AF735C1C3; Fri, 14 Feb 2020 20:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kw0Ovdv0zytep/i41pEvdOUY/wlGbwSrovoSBVCAo2s=; b=MED/4voz2WWRxnMvUC+TTjepo1hx34K39QNUvOkHOXYNwgUwHEPL5n+h3nQM51SS3qZmYX o+voNqB1NYhc0GRoK0zAxSmAO18KMv/l4wNa2hpdH44jI2LyNsu1RTxBKedISd31G+EZIM z57B96e+TgRJ6Zi3jUusMqHRhAg6rBo= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 4/7] commit: Inline commit_populate() Date: Fri, 14 Feb 2020 21:08:09 +0100 Message-Id: <20200214200812.28180-5-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: nnt9GtWROiSt9uWawC-G8A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" commit_populate() is a very short function and only called in a single place. Its return value doesn't tell us whether an error happened while reading or writing, which would be necessary for sending the right data in the BLOCK_JOB_ERROR QMP event. Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- block/commit.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/block/commit.c b/block/commit.c index 8189f079d2..2992a1012f 100644 --- a/block/commit.c +++ b/block/commit.c @@ -43,27 +43,6 @@ typedef struct CommitBlockJob { char *backing_file_str; } CommitBlockJob; =20 -static int coroutine_fn commit_populate(BlockBackend *bs, BlockBackend *ba= se, - int64_t offset, uint64_t bytes, - void *buf) -{ - int ret =3D 0; - - assert(bytes < SIZE_MAX); - - ret =3D blk_co_pread(bs, offset, bytes, buf, 0); - if (ret < 0) { - return ret; - } - - ret =3D blk_co_pwrite(base, offset, bytes, buf, 0); - if (ret < 0) { - return ret; - } - - return 0; -} - static int commit_prepare(Job *job) { CommitBlockJob *s =3D container_of(job, CommitBlockJob, common.job); @@ -178,7 +157,12 @@ static int coroutine_fn commit_run(Job *job, Error **e= rrp) copy =3D (ret =3D=3D 1); trace_commit_one_iteration(s, offset, n, ret); if (copy) { - ret =3D commit_populate(s->top, s->base, offset, n, buf); + assert(n < SIZE_MAX); + + ret =3D blk_co_pread(s->top, offset, n, buf, 0); + if (ret >=3D 0) { + ret =3D blk_co_pwrite(s->base, offset, n, buf, 0); + } } if (ret < 0) { BlockErrorAction action =3D --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581710985503751.4388237552247; Fri, 14 Feb 2020 12:09:45 -0800 (PST) Received: from localhost ([::1]:45106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hHU-0000wo-7p for importer@patchew.org; Fri, 14 Feb 2020 15:09:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51977) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGU-0007ci-5p for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGT-0005Y1-3X for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:42 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23064 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGT-0005XO-0G for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-25-WMq0NUqFM4mZ78wiA7Kqig-1; Fri, 14 Feb 2020 15:08:37 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 776BD8017CC; Fri, 14 Feb 2020 20:08:36 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE8075C1C3; Fri, 14 Feb 2020 20:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RJEiE9xI7aILw83dDnsZdVaUnSegYkhr1oQCmytCVto=; b=Hd1vBZfJ8UiHuy1VwHMb5K6YQJSS2urK/up+ZjLRhCRKEQsOytYhixUVAv6sGueOYeWISr 0FlN43DZTB5YUaBtCXUv6t182+LEb/iSeZHsdxmV41SRIh7sClIT+tK1RLLCgQjr57RPJ7 Ew+iSwDGlyKhIksM6yKmh8VLQKFSK5o= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 5/7] commit: Fix is_read for block_job_error_action() Date: Fri, 14 Feb 2020 21:08:10 +0100 Message-Id: <20200214200812.28180-6-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: WMq0NUqFM4mZ78wiA7Kqig-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" block_job_error_action() needs to know if reading from the top node or writing to the base node failed so that it can set the right 'operation' in the BLOCK_JOB_ERROR QMP event. Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- block/commit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index 2992a1012f..8e672799af 100644 --- a/block/commit.c +++ b/block/commit.c @@ -143,6 +143,7 @@ static int coroutine_fn commit_run(Job *job, Error **er= rp) =20 for (offset =3D 0; offset < len; offset +=3D n) { bool copy; + bool error_in_source =3D true; =20 /* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. @@ -162,11 +163,15 @@ static int coroutine_fn commit_run(Job *job, Error **= errp) ret =3D blk_co_pread(s->top, offset, n, buf, 0); if (ret >=3D 0) { ret =3D blk_co_pwrite(s->base, offset, n, buf, 0); + if (ret < 0) { + error_in_source =3D false; + } } } if (ret < 0) { BlockErrorAction action =3D - block_job_error_action(&s->common, s->on_error, false, -re= t); + block_job_error_action(&s->common, s->on_error, + error_in_source, -ret); if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { goto out; } else { --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581711252537374.3763291410322; Fri, 14 Feb 2020 12:14:12 -0800 (PST) Received: from localhost ([::1]:45208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hLn-0001E9-DR for importer@patchew.org; Fri, 14 Feb 2020 15:14:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52013) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGZ-0007ql-9w for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGX-0005fT-7V for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:47 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23581 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGX-0005dl-3M for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-4Zqu-HpXO5iT44iRVtPkjg-1; Fri, 14 Feb 2020 15:08:43 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BD7B108442A; Fri, 14 Feb 2020 20:08:38 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF5DF5C1C3; Fri, 14 Feb 2020 20:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710924; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G7fpPkW0Znm7Ual5KsYCLNoIphxRplpjPiS+1ZA2nF0=; b=BsJXeNzs0ZF2rFjT1tKYLjDaqvkGmKpOWzUn0fsUaop4IvfyI4xnxln0pb2NSRGyGpQLzf rROZ/EKIR5EzxwH1R/sxL6D5fy3m0Rw5sl57iWD79VQkfP9U92OHbtFSnIlPob5qB+K63h LdMRSo7pWao9LdBX0f+TtQDVAvm0i3I= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 6/7] commit: Expose on-error option in QMP Date: Fri, 14 Feb 2020 21:08:11 +0100 Message-Id: <20200214200812.28180-7-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: 4Zqu-HpXO5iT44iRVtPkjg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Now that the error handling in the common block job is fixed, we can expose the on-error option in QMP instead of hard-coding it as 'report' in qmp_block_commit(). This fulfills the promise that the old comment in that function made, even if a bit later than expected: "This will be part of the QMP command, if/when the BlockdevOnError change for blkmirror makes it in". Signed-off-by: Kevin Wolf Reviewed-by: J=C3=A1n Tomko --- qapi/block-core.json | 4 ++++ blockdev.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 395d205fa8..c69aece46e 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1659,6 +1659,9 @@ # # @speed: the maximum speed, in bytes per second # +# @on-error: the action to take on an error. 'ignore' means that the reque= st +# should be retried. (default: report; Since: 5.0) +# # @filter-node-name: the node name that should be assigned to the # filter driver that the commit job inserts into the gr= aph # above @top. If this option is not given, a node name = is @@ -1695,6 +1698,7 @@ 'data': { '*job-id': 'str', 'device': 'str', '*base-node': 'str', '*base': 'str', '*top-node': 'str', '*top': 'str', '*backing-file': 'str', '*speed': 'int', + '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } =20 diff --git a/blockdev.c b/blockdev.c index c6a727cca9..374189a426 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3471,6 +3471,7 @@ void qmp_block_commit(bool has_job_id, const char *jo= b_id, const char *device, bool has_top, const char *top, bool has_backing_file, const char *backing_file, bool has_speed, int64_t speed, + bool has_on_error, BlockdevOnError on_error, bool has_filter_node_name, const char *filter_node_n= ame, bool has_auto_finalize, bool auto_finalize, bool has_auto_dismiss, bool auto_dismiss, @@ -3481,15 +3482,14 @@ void qmp_block_commit(bool has_job_id, const char *= job_id, const char *device, BlockDriverState *base_bs, *top_bs; AioContext *aio_context; Error *local_err =3D NULL; - /* This will be part of the QMP command, if/when the - * BlockdevOnError change for blkmirror makes it in - */ - BlockdevOnError on_error =3D BLOCKDEV_ON_ERROR_REPORT; int job_flags =3D JOB_DEFAULT; =20 if (!has_speed) { speed =3D 0; } + if (!has_on_error) { + on_error =3D BLOCKDEV_ON_ERROR_REPORT; + } if (!has_filter_node_name) { filter_node_name =3D NULL; } --=20 2.20.1 From nobody Thu Nov 13 16:32:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158171107406746.51425952945067; Fri, 14 Feb 2020 12:11:14 -0800 (PST) Received: from localhost ([::1]:45154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hIu-0004CO-KD for importer@patchew.org; Fri, 14 Feb 2020 15:11:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52067) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2hGi-0008Gd-M6 for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2hGg-0005xQ-PB for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:56 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49444 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j2hGg-0005wd-Ko for qemu-devel@nongnu.org; Fri, 14 Feb 2020 15:08:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-Vj0VISqNPbCbXpGYBG-Aww-1; Fri, 14 Feb 2020 15:08:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 183EF13E2; Fri, 14 Feb 2020 20:08:40 +0000 (UTC) Received: from linux.fritz.box.com (unknown [10.36.118.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 927C05C1C3; Fri, 14 Feb 2020 20:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581710934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+WKpefP9BgROxoZoqUBH6uGP1/rI1g20cTiL0991K+g=; b=JYuJjXzFe0P8/VABVmT/wytEk5a0G0T5vloEm+QwaCjw/VvUMTwT1i9F6cjNfiLOJkp265 63hOe1QhLGUBMH2B73/TmkmYcfV7gZCGHhK9kfJXcFiSvGQp32UvJTBQNgLpRBDzRm7rD+ X9UzPMn+pv/bQaKogwY3a9jhDOMYOzQ= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 7/7] iotests: Test error handling policies with block-commit Date: Fri, 14 Feb 2020 21:08:12 +0100 Message-Id: <20200214200812.28180-8-kwolf@redhat.com> In-Reply-To: <20200214200812.28180-1-kwolf@redhat.com> References: <20200214200812.28180-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: Vj0VISqNPbCbXpGYBG-Aww-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This tests both read failure (from the top node) and write failure (to the base node) for on-error=3Dreport/stop/ignore. As block-commit actually starts two different types of block jobs (mirror.c for committing the active later, commit.c for intermediate layers), all tests are run for both cases. Signed-off-by: Kevin Wolf --- tests/qemu-iotests/040 | 283 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/040.out | 4 +- 2 files changed, 285 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 2e7ee0e84f..32c82b4ec6 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -430,6 +430,289 @@ class TestReopenOverlay(ImageCommitTestCase): def test_reopen_overlay(self): self.run_commit_test(self.img1, self.img0) =20 +class TestErrorHandling(iotests.QMPTestCase): + image_len =3D 2 * 1024 * 1024 + + def setUp(self): + iotests.create_image(backing_img, self.image_len) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=3D%s'= % backing_img, mid_img) + qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=3D%s'= % mid_img, test_img) + + qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x11 0 512k', mid_im= g) + qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x22 0 512k', test_i= mg) + + self.vm =3D iotests.VM() + self.vm.launch() + + self.blkdebug_file =3D iotests.file_path("blkdebug.conf") + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + os.remove(mid_img) + os.remove(backing_img) + + def blockdev_add(self, **kwargs): + result =3D self.vm.qmp('blockdev-add', **kwargs) + self.assert_qmp(result, 'return', {}) + + def add_block_nodes(self, base_debug=3DNone, mid_debug=3DNone, top_deb= ug=3DNone): + self.blockdev_add(node_name=3D'base-file', driver=3D'file', + filename=3Dbacking_img) + self.blockdev_add(node_name=3D'mid-file', driver=3D'file', + filename=3Dmid_img) + self.blockdev_add(node_name=3D'top-file', driver=3D'file', + filename=3Dtest_img) + + if base_debug: + self.blockdev_add(node_name=3D'base-dbg', driver=3D'blkdebug', + image=3D'base-file', inject_error=3Dbase_deb= ug) + if mid_debug: + self.blockdev_add(node_name=3D'mid-dbg', driver=3D'blkdebug', + image=3D'mid-file', inject_error=3Dmid_debug) + if top_debug: + self.blockdev_add(node_name=3D'top-dbg', driver=3D'blkdebug', + image=3D'top-file', inject_error=3Dtop_debug) + + self.blockdev_add(node_name=3D'base-fmt', driver=3D'raw', + file=3D('base-dbg' if base_debug else 'base-file= ')) + self.blockdev_add(node_name=3D'mid-fmt', driver=3Diotests.imgfmt, + file=3D('mid-dbg' if mid_debug else 'mid-file'), + backing=3D'base-fmt') + self.blockdev_add(node_name=3D'top-fmt', driver=3Diotests.imgfmt, + file=3D('top-dbg' if top_debug else 'top-file'), + backing=3D'mid-fmt') + + def run_job(self, expected_events, error_pauses_job=3DFalse): + match_device =3D {'data': {'device': 'job0'}} + events =3D [ + ('BLOCK_JOB_COMPLETED', match_device), + ('BLOCK_JOB_CANCELLED', match_device), + ('BLOCK_JOB_ERROR', match_device), + ('BLOCK_JOB_READY', match_device), + ] + + completed =3D False + log =3D [] + while not completed: + ev =3D self.vm.events_wait(events, timeout=3D5.0) + if ev['event'] =3D=3D 'BLOCK_JOB_COMPLETED': + completed =3D True + elif ev['event'] =3D=3D 'BLOCK_JOB_ERROR': + if error_pauses_job: + result =3D self.vm.qmp('block-job-resume', device=3D'j= ob0') + self.assert_qmp(result, 'return', {}) + elif ev['event'] =3D=3D 'BLOCK_JOB_READY': + result =3D self.vm.qmp('block-job-complete', device=3D'job= 0') + self.assert_qmp(result, 'return', {}) + else: + self.fail("Unexpected event: %s" % ev) + log.append(iotests.filter_qmp_event(ev)) + + self.maxDiff =3D None + self.assertEqual(expected_events, log) + + def event_error(self, op, action): + return { + 'event': 'BLOCK_JOB_ERROR', + 'data': {'action': action, 'device': 'job0', 'operation': op}, + 'timestamp': {'microseconds': 'USECS', 'seconds': 'SECS'} + } + + def event_ready(self): + return { + 'event': 'BLOCK_JOB_READY', + 'data': {'device': 'job0', + 'len': 524288, + 'offset': 524288, + 'speed': 0, + 'type': 'commit'}, + 'timestamp': {'microseconds': 'USECS', 'seconds': 'SECS'}, + } + + def event_completed(self, errmsg=3DNone, active=3DTrue): + max_len =3D 524288 if active else self.image_len + data =3D { + 'device': 'job0', + 'len': max_len, + 'offset': 0 if errmsg else max_len, + 'speed': 0, + 'type': 'commit' + } + if errmsg: + data['error'] =3D errmsg + + return { + 'event': 'BLOCK_JOB_COMPLETED', + 'data': data, + 'timestamp': {'microseconds': 'USECS', 'seconds': 'SECS'}, + } + + def blkdebug_event(self, event, is_raw=3DFalse): + if event: + return [{ + 'event': event, + 'sector': 512 if is_raw else 1024, + 'once': True, + }] + return None + + def prepare_and_start_job(self, on_error, active=3DTrue, + top_event=3DNone, mid_event=3DNone, base_eve= nt=3DNone): + + top_debug =3D self.blkdebug_event(top_event) + mid_debug =3D self.blkdebug_event(mid_event) + base_debug =3D self.blkdebug_event(base_event, True) + + self.add_block_nodes(top_debug=3Dtop_debug, mid_debug=3Dmid_debug, + base_debug=3Dbase_debug) + + result =3D self.vm.qmp('block-commit', job_id=3D'job0', device=3D'= top-fmt', + top_node=3D'top-fmt' if active else 'mid-fmt', + base_node=3D'mid-fmt' if active else 'base-fm= t', + on_error=3Don_error) + self.assert_qmp(result, 'return', {}) + + def testActiveReadErrorReport(self): + self.prepare_and_start_job('report', top_event=3D'read_aio') + self.run_job([ + self.event_error('read', 'report'), + self.event_completed('Input/output error') + ]) + + self.vm.shutdown() + self.assertFalse(iotests.compare_images(test_img, mid_img), + 'target image matches source after error') + + def testActiveReadErrorStop(self): + self.prepare_and_start_job('stop', top_event=3D'read_aio') + self.run_job([ + self.event_error('read', 'stop'), + self.event_ready(), + self.event_completed() + ], error_pauses_job=3DTrue) + + self.vm.shutdown() + self.assertTrue(iotests.compare_images(test_img, mid_img), + 'target image does not match source after commit') + + def testActiveReadErrorIgnore(self): + self.prepare_and_start_job('ignore', top_event=3D'read_aio') + self.run_job([ + self.event_error('read', 'ignore'), + self.event_ready(), + self.event_completed() + ]) + + # For commit, 'ignore' actually means retry, so this will succeed + self.vm.shutdown() + self.assertTrue(iotests.compare_images(test_img, mid_img), + 'target image does not match source after commit') + + def testActiveWriteErrorReport(self): + self.prepare_and_start_job('report', mid_event=3D'write_aio') + self.run_job([ + self.event_error('write', 'report'), + self.event_completed('Input/output error') + ]) + + self.vm.shutdown() + self.assertFalse(iotests.compare_images(test_img, mid_img), + 'target image matches source after error') + + def testActiveWriteErrorStop(self): + self.prepare_and_start_job('stop', mid_event=3D'write_aio') + self.run_job([ + self.event_error('write', 'stop'), + self.event_ready(), + self.event_completed() + ], error_pauses_job=3DTrue) + + self.vm.shutdown() + self.assertTrue(iotests.compare_images(test_img, mid_img), + 'target image does not match source after commit') + + def testActiveWriteErrorIgnore(self): + self.prepare_and_start_job('ignore', mid_event=3D'write_aio') + self.run_job([ + self.event_error('write', 'ignore'), + self.event_ready(), + self.event_completed() + ]) + + # For commit, 'ignore' actually means retry, so this will succeed + self.vm.shutdown() + self.assertTrue(iotests.compare_images(test_img, mid_img), + 'target image does not match source after commit') + + def testIntermediateReadErrorReport(self): + self.prepare_and_start_job('report', active=3DFalse, mid_event=3D'= read_aio') + self.run_job([ + self.event_error('read', 'report'), + self.event_completed('Input/output error', active=3DFalse) + ]) + + self.vm.shutdown() + self.assertFalse(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image matches source after error') + + def testIntermediateReadErrorStop(self): + self.prepare_and_start_job('stop', active=3DFalse, mid_event=3D're= ad_aio') + self.run_job([ + self.event_error('read', 'stop'), + self.event_completed(active=3DFalse) + ], error_pauses_job=3DTrue) + + self.vm.shutdown() + self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image does not match source after commit') + + def testIntermediateReadErrorIgnore(self): + self.prepare_and_start_job('ignore', active=3DFalse, mid_event=3D'= read_aio') + self.run_job([ + self.event_error('read', 'ignore'), + self.event_completed(active=3DFalse) + ]) + + # For commit, 'ignore' actually means retry, so this will succeed + self.vm.shutdown() + self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image does not match source after commit') + + def testIntermediateWriteErrorReport(self): + self.prepare_and_start_job('report', active=3DFalse, base_event=3D= 'write_aio') + self.run_job([ + self.event_error('write', 'report'), + self.event_completed('Input/output error', active=3DFalse) + ]) + + self.vm.shutdown() + self.assertFalse(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image matches source after error') + + def testIntermediateWriteErrorStop(self): + self.prepare_and_start_job('stop', active=3DFalse, base_event=3D'w= rite_aio') + self.run_job([ + self.event_error('write', 'stop'), + self.event_completed(active=3DFalse) + ], error_pauses_job=3DTrue) + + self.vm.shutdown() + self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image does not match source after commit') + + def testIntermediateWriteErrorIgnore(self): + self.prepare_and_start_job('ignore', active=3DFalse, base_event=3D= 'write_aio') + self.run_job([ + self.event_error('write', 'ignore'), + self.event_completed(active=3DFalse) + ]) + + # For commit, 'ignore' actually means retry, so this will succeed + self.vm.shutdown() + self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2= =3D'raw'), + 'target image does not match source after commit') + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed'], supported_protocols=3D['file']) diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index 220a5fa82c..6a917130b6 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -............................................... +........................................................... ---------------------------------------------------------------------- -Ran 47 tests +Ran 59 tests =20 OK --=20 2.20.1