From nobody Sun May 19 02:26:39 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1617970058; cv=none; d=zohomail.com; s=zohoarc; b=f5sv209jVf9cqwsYQY689nOr3u7T9xEOosZS2iEo7+1hbTnX6IkZAVcarYrglzcwB8csKKHRQqwDRSgQwFSJwEfkNVOtbawxvO4aXpBVGD8uZaeG+zv/Mei5r5cjOTiNJUKCFqksuxy8dbw+wTvgN7X51ez1i3WfO8gaY9AuVOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617970058; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FkZP2zq258xND6bWKPiyXr/bfL8VH+g2g0DWI6QgFA4=; b=ciqWBar15ZTFL32E7Iv0Rmdthu29Ukj9ho6DIksebi6h/d4Vcz76TkLiWSiVP9q7JUcANsMhXM6dLM24wi+3w1T7Rjgn1lOm5UiWOXXPg6I90o/odH3FhTmS0JFxaz8X0ei82t9bC399IcsQuw/bvEiCzfUAhImhUcHB4mRE0Rw= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617970058675328.9450617149506; Fri, 9 Apr 2021 05:07:38 -0700 (PDT) Received: from localhost ([::1]:35664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUpvF-0001Mp-V1 for importer@patchew.org; Fri, 09 Apr 2021 08:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsO-000811-F7 for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsF-0008CF-Mj for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:39 -0400 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-459-tJd3-XtOPLeQwOR22hC_3Q-1; Fri, 09 Apr 2021 08:04:27 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF7C08030B5; Fri, 9 Apr 2021 12:04:26 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A13719C71; Fri, 9 Apr 2021 12:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617969869; 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=FkZP2zq258xND6bWKPiyXr/bfL8VH+g2g0DWI6QgFA4=; b=fWmHzQhatw6vxrt3JPypHbZMkJytXFPe49V4KpWxOUNCvkU/9IeNjp26Z4/3AyvNgMs3gD RjQzbRO2jcjDgPwXc94KX41SSuvTWONvNOt1d0TwnYe979VtWWFvF8ZMLXiAqv7kCrmm4E zfwhBuA8mHbIqHV3kcHsAvHL3LLYmtw= X-MC-Unique: tJd3-XtOPLeQwOR22hC_3Q-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 1/4] mirror: Move open_backing_file to exit_common Date: Fri, 9 Apr 2021 14:04:18 +0200 Message-Id: <20210409120422.144040-2-mreitz@redhat.com> In-Reply-To: <20210409120422.144040-1-mreitz@redhat.com> References: <20210409120422.144040-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz 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 is a graph change and therefore should be done in job-finalize (which is what invokes mirror_exit_common()). Signed-off-by: Max Reitz --- block/mirror.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index d7e54c0ff7..f1f936bf1a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -689,6 +689,14 @@ static int mirror_exit_common(Job *job) ret =3D -EPERM; } } + } else if (!abort && s->backing_mode =3D=3D MIRROR_OPEN_BACKING_CHAIN)= { + assert(!bdrv_backing_chain_next(target_bs)); + ret =3D bdrv_open_backing_file(bdrv_skip_filters(target_bs), NULL, + "backing", &local_err); + if (ret < 0) { + error_report_err(local_err); + local_err =3D NULL; + } } =20 if (s->to_replace) { @@ -1107,9 +1115,6 @@ immediate_exit: static void mirror_complete(Job *job, Error **errp) { MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common.job); - BlockDriverState *target; - - target =3D blk_bs(s->target); =20 if (!s->synced) { error_setg(errp, "The active block job '%s' cannot be completed", @@ -1117,17 +1122,6 @@ static void mirror_complete(Job *job, Error **errp) return; } =20 - if (s->backing_mode =3D=3D MIRROR_OPEN_BACKING_CHAIN) { - int ret; - - assert(!bdrv_backing_chain_next(target)); - ret =3D bdrv_open_backing_file(bdrv_skip_filters(target), NULL, - "backing", errp); - if (ret < 0) { - return; - } - } - /* block all operations on to_replace bs */ if (s->replaces) { AioContext *replace_aio_context; --=20 2.29.2 From nobody Sun May 19 02:26:39 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1617970340; cv=none; d=zohomail.com; s=zohoarc; b=gK9J8jwwxRZ69RDCLHGCbwPlu7o/BYt3O0REXBEpIIglnRzQtcB/9pfkzIK6rIlg0NLv8GaxR2JiGXjDquG/dl6QTzuk3FXT/cDpcljvf1sEmB1hzjkMIilmsWDMB32+fW3/dHdQa+YFpgz6H5jjlBYWq6E6ByXT5qI7hfkDUq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617970340; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LAc7L9+YJ0ealn7uzjhYK9sm6EPpUm39QMeBeWZZmLI=; b=hYeI7aT3iB0MSbe83G4+tmacfFERpTJ52B5GjFo+MTdeLbFBXf07SqVzKg1c0V2JTKyYs4PJub5EvW1Gv57YzD3ByqYof3E6JBXAbeN023mr9H+ZAvFdBg4spoHF/jXtdLPXacH5eM5Jg6O6NV55FXeIXq5TsX5fIMrph1UbTJ8= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161797034018788.95430545166971; Fri, 9 Apr 2021 05:12:20 -0700 (PDT) Received: from localhost ([::1]:43634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUpzn-0004oD-7s for importer@patchew.org; Fri, 09 Apr 2021 08:12:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsO-000810-F9 for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsH-0008DO-1O for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:39 -0400 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-491-bZ4uwY5kMTK5NbaSkUPcvg-1; Fri, 09 Apr 2021 08:04:30 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4B368030B5; Fri, 9 Apr 2021 12:04:28 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 874992DAD0; Fri, 9 Apr 2021 12:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617969872; 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=LAc7L9+YJ0ealn7uzjhYK9sm6EPpUm39QMeBeWZZmLI=; b=UzoXO0rigOM9/X852USiEEfyBD2jIzOxviLnQ+eJoaWpQZ0Vo1iAw57uGie8U8pS7MZ3ew OGbpY4yrR55imoaRKSVcuayep1oeependyW0wOGFldej9ymCRdZdn49rwqpVCBx63w2SHR FsyQoCyjdt+FzoV3zZ+95VpZ4d/w+EE= X-MC-Unique: bZ4uwY5kMTK5NbaSkUPcvg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 2/4] mirror: Do not enter a paused job on completion Date: Fri, 9 Apr 2021 14:04:19 +0200 Message-Id: <20210409120422.144040-3-mreitz@redhat.com> In-Reply-To: <20210409120422.144040-1-mreitz@redhat.com> References: <20210409120422.144040-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Currently, it is impossible to complete jobs on standby (i.e. paused ready jobs), but actually the only thing in mirror_complete() that does not work quite well with a paused job is the job_enter() at the end. If we make it conditional, this function works just fine even if the mirror job is paused. So technically this is a no-op, but obviously the intention is to accept block-job-complete even for jobs on standby, which we need this patch for first. Signed-off-by: Max Reitz --- block/mirror.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index f1f936bf1a..5a71bd8bbc 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1148,7 +1148,11 @@ static void mirror_complete(Job *job, Error **errp) } =20 s->should_complete =3D true; - job_enter(job); + + /* If the job is paused, it will be re-entered when it is resumed */ + if (!job->paused) { + job_enter(job); + } } =20 static void coroutine_fn mirror_pause(Job *job) --=20 2.29.2 From nobody Sun May 19 02:26:39 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1617970517; cv=none; d=zohomail.com; s=zohoarc; b=m6luMCuaplDdx5yzjbv5MfocSq+csSuTjzYNrx1KHVSLi6njYENWFRD1GbEWS4e9sriG6Gw00dfBZ1eEwH/2grnUWAaDNBAuwWazYi8PmE2ZcmfuG+Z5LzL47cbZKG3GDLBtyR8OnX1anZgkY2cAC7BsM2SXE0iWdSr183zXlZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617970517; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dcJ4iKj56gsilCizTluXLSAk28HiI47nLspxmevo2Sw=; b=DHDi5wnfxDGcthegBP01qL7M+lE+5HnCSjAVaD7RJm64M8lYTDH/XrEPKHGJ0RQETYfABws+ws1a7sbkpIuT1nNegI7X8mBdQjQKOxCy/x3UJclEofqIWVMCEcvYhgZXcX6uHgK0DRhPXg4BjyaCABfm9JLQp6orDZpERkXPWoo= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617970517728656.7238134902777; Fri, 9 Apr 2021 05:15:17 -0700 (PDT) Received: from localhost ([::1]:48504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUq2e-0006rq-Ff for importer@patchew.org; Fri, 09 Apr 2021 08:15:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsR-00084R-Qo for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsL-0008Ej-JR for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:43 -0400 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-450-wGaQICmGMLaTBNUxDF42Mw-1; Fri, 09 Apr 2021 08:04:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AF7E8030A0; Fri, 9 Apr 2021 12:04:31 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B38E419C66; Fri, 9 Apr 2021 12:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617969875; 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=dcJ4iKj56gsilCizTluXLSAk28HiI47nLspxmevo2Sw=; b=A+/Xw2LTOCa3JVsms4ghDyVthmQXPMpCC8I63iV5aoMVk0M+F4KbdZ+NwkqctIXD0bfpbW XBsYSL5UyaYsl091BVItO1MZhNNoiued2blI2w174r1LrJj08simmE8pPYAwGIGsYmndnu cPBrhIbpUQcXMraXfqfmrt3ULawZeWc= X-MC-Unique: wGaQICmGMLaTBNUxDF42Mw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 3/4] job: Allow complete for jobs on standby Date: Fri, 9 Apr 2021 14:04:20 +0200 Message-Id: <20210409120422.144040-4-mreitz@redhat.com> In-Reply-To: <20210409120422.144040-1-mreitz@redhat.com> References: <20210409120422.144040-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz 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 only job that implements .complete is the mirror job, and it can handle completion requests just fine while the job is paused. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1945635 Signed-off-by: Max Reitz --- job.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/job.c b/job.c index 289edee143..4aff13d95a 100644 --- a/job.c +++ b/job.c @@ -56,7 +56,7 @@ bool JobVerbTable[JOB_VERB__MAX][JOB_STATUS__MAX] =3D { [JOB_VERB_PAUSE] =3D {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, [JOB_VERB_RESUME] =3D {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, [JOB_VERB_SET_SPEED] =3D {0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}, - [JOB_VERB_COMPLETE] =3D {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + [JOB_VERB_COMPLETE] =3D {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}, [JOB_VERB_FINALIZE] =3D {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, [JOB_VERB_DISMISS] =3D {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, }; @@ -991,7 +991,7 @@ void job_complete(Job *job, Error **errp) if (job_apply_verb(job, JOB_VERB_COMPLETE, errp)) { return; } - if (job->pause_count || job_is_cancelled(job) || !job->driver->complet= e) { + if (job_is_cancelled(job) || !job->driver->complete) { error_setg(errp, "The active block job '%s' cannot be completed", job->id); return; --=20 2.29.2 From nobody Sun May 19 02:26:39 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1617970114; cv=none; d=zohomail.com; s=zohoarc; b=PuDjA58ZaXA5Ew0IWRbatTlbDXJem1n76zoS2K9gtLA6eqBA7svBf3PXj3ewclRxY/l08RRGi+2lxyWfv/ZNGxY07CGv42yi5Yhr5o0EdIG09uAsooCmit/O2GBJQKbdYtDVnWGV0YGWjU2gRMCsMgHTWsDJHAJyhTCe9bgKL38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617970114; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1btMYzGXIGXUn8SpcmLoOJ91k5pXe5I8ELnO6r56N90=; b=kSIcD91poflgpfCUBvmU7G0KZ02MY74VQJR+irOBT0MGS1BbkPIbq5pe8lhNZ+xq0SOZMZ1cY8h/e8ZOcYFCzM7Djh6g5+J89+sF9yJlcSTz8Xmbg20uErOGB8gnJVHAKCDvtC0f8rJwVHrJXJoFzdVBJOvaYN8ZFw7QICHMTW0= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617970114386418.5407115940278; Fri, 9 Apr 2021 05:08:34 -0700 (PDT) Received: from localhost ([::1]:37044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUpw9-0001zm-HC for importer@patchew.org; Fri, 09 Apr 2021 08:08:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsQ-00083O-Tv for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsL-0008F3-N4 for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:42 -0400 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-471-YO3pFck4NXKUNyKmkoc6-g-1; Fri, 09 Apr 2021 08:04:34 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31BA28030A0; Fri, 9 Apr 2021 12:04:33 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C588260BE5; Fri, 9 Apr 2021 12:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617969876; 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=1btMYzGXIGXUn8SpcmLoOJ91k5pXe5I8ELnO6r56N90=; b=GcTwmlROaSCRuvZC764K2dhOHOBxnIlHchFOujppnAw2D22fNqZEQ/QcFuAavIdXNqxD7Y 8n5vGfff1H1QXkLfyfS5nbs3I8gNhgHRPxbhsr4tYeY+PS3XwE6WrnaRZiXRRX+uFX2JY2 dRW415uYoLhfSo1x5ol4rzHi33I7Hzs= X-MC-Unique: YO3pFck4NXKUNyKmkoc6-g-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 4/4] test-blockjob: Test job_wait_unpaused() Date: Fri, 9 Apr 2021 14:04:21 +0200 Message-Id: <20210409120422.144040-5-mreitz@redhat.com> In-Reply-To: <20210409120422.144040-1-mreitz@redhat.com> References: <20210409120422.144040-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Create a job that remains on STANDBY after a drained section, and see that invoking job_wait_unpaused() will get it unstuck. Signed-off-by: Max Reitz --- tests/unit/test-blockjob.c | 121 +++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index 7519847912..dcacfa6c7c 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -16,6 +16,7 @@ #include "block/blockjob_int.h" #include "sysemu/block-backend.h" #include "qapi/qmp/qdict.h" +#include "iothread.h" =20 static const BlockJobDriver test_block_job_driver =3D { .job_driver =3D { @@ -375,6 +376,125 @@ static void test_cancel_concluded(void) cancel_common(s); } =20 +/* (See test_yielding_driver for the job description) */ +typedef struct YieldingJob { + BlockJob common; + bool should_complete; +} YieldingJob; + +static void yielding_job_complete(Job *job, Error **errp) +{ + YieldingJob *s =3D container_of(job, YieldingJob, common.job); + s->should_complete =3D true; + job_enter(job); +} + +static int coroutine_fn yielding_job_run(Job *job, Error **errp) +{ + YieldingJob *s =3D container_of(job, YieldingJob, common.job); + + job_transition_to_ready(job); + + while (!s->should_complete) { + job_yield(job); + } + + return 0; +} + +/* + * This job transitions immediately to the READY state, and then + * yields until it is to complete. + */ +static const BlockJobDriver test_yielding_driver =3D { + .job_driver =3D { + .instance_size =3D sizeof(YieldingJob), + .free =3D block_job_free, + .user_resume =3D block_job_user_resume, + .run =3D yielding_job_run, + .complete =3D yielding_job_complete, + }, +}; + +/* + * Test that job_complete() works even on jobs that are in a paused + * state (i.e., STANDBY). + * + * To do this, run YieldingJob in an IO thread, get it into the READY + * state, then have a drained section. Before ending the section, + * acquire the context so the job will not be entered and will thus + * remain on STANDBY. + * + * job_complete() should still work without error. + * + * Note that on the QMP interface, it is impossible to lock an IO + * thread before a drained section ends. In practice, the + * bdrv_drain_all_end() and the aio_context_acquire() will be + * reversed. However, that makes for worse reproducibility here: + * Sometimes, the job would no longer be in STANDBY then but already + * be started. We cannot prevent that, because the IO thread runs + * concurrently. We can only prevent it by taking the lock before + * ending the drained section, so we do that. + * + * (You can reverse the order of operations and most of the time the + * test will pass, but sometimes the assert(status =3D=3D STANDBY) will + * fail.) + */ +static void test_complete_in_standby(void) +{ + BlockBackend *blk; + IOThread *iothread; + AioContext *ctx; + Job *job; + BlockJob *bjob; + + /* Create a test drive, move it to an IO thread */ + blk =3D create_blk(NULL); + iothread =3D iothread_new(); + + ctx =3D iothread_get_aio_context(iothread); + blk_set_aio_context(blk, ctx, &error_abort); + + /* Create our test job */ + bjob =3D mk_job(blk, "job", &test_yielding_driver, true, + JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS); + job =3D &bjob->job; + assert(job->status =3D=3D JOB_STATUS_CREATED); + + /* Wait for the job to become READY */ + job_start(job); + aio_context_acquire(ctx); + AIO_WAIT_WHILE(ctx, job->status !=3D JOB_STATUS_READY); + aio_context_release(ctx); + + /* Begin the drained section, pausing the job */ + bdrv_drain_all_begin(); + assert(job->status =3D=3D JOB_STATUS_STANDBY); + /* Lock the IO thread to prevent the job from being run */ + aio_context_acquire(ctx); + /* This will schedule the job to resume it */ + bdrv_drain_all_end(); + + /* But the job cannot run, so it will remain on standby */ + assert(job->status =3D=3D JOB_STATUS_STANDBY); + + /* Even though the job is on standby, this should work */ + job_complete(job, &error_abort); + + /* The test is done now, clean up. */ + job_finish_sync(job, NULL, &error_abort); + assert(job->status =3D=3D JOB_STATUS_PENDING); + + job_finalize(job, &error_abort); + assert(job->status =3D=3D JOB_STATUS_CONCLUDED); + + job_dismiss(&job, &error_abort); + + destroy_blk(blk); + aio_context_release(ctx); + iothread_join(iothread); +} + int main(int argc, char **argv) { qemu_init_main_loop(&error_abort); @@ -389,5 +509,6 @@ int main(int argc, char **argv) g_test_add_func("/blockjob/cancel/standby", test_cancel_standby); g_test_add_func("/blockjob/cancel/pending", test_cancel_pending); g_test_add_func("/blockjob/cancel/concluded", test_cancel_concluded); + g_test_add_func("/blockjob/complete_in_standby", test_complete_in_stan= dby); return g_test_run(); } --=20 2.29.2 From nobody Sun May 19 02:26:39 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1617970090; cv=none; d=zohomail.com; s=zohoarc; b=kZt8qE66hgqkK+GyR3X1Dp1oFgiOQIlHHSfT6tW/LOJqkwZbJzuhdpnJUvRSvOiO3r3cPo5ebjI9V3sC/FYawTcgECzh2yYsPuPWZBVX2SjfYRXsWrLnu9rV3K0GaTVb3FGH0Eq5YWgwxocV+UC8Z39SZzaJkMqy+PZ97n5RoP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617970090; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1srMCU2bYhO+BsWlK/xCgdMlVZmHB88CcU9bByF1iPo=; b=QWnH3i4NobQIOyZAf9HREB1QtwFBi1zsmQczdsBDF3yG54+8OTR//zbmW5nFvVmBhbSej8j3Ob0+abVCTJaTFmouuaaS41JQgfmYlxvfFVQclLaDMtJXAWDv5inFJoCcRp26qFErxWaxmqWTZVq71vcBUhry7Co76Xp8qShYRmw= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617970090015821.0963397695878; Fri, 9 Apr 2021 05:08:10 -0700 (PDT) Received: from localhost ([::1]:36658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUpvl-0001of-3P for importer@patchew.org; Fri, 09 Apr 2021 08:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsS-000873-OE for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUpsO-0008H9-SM for qemu-devel@nongnu.org; Fri, 09 Apr 2021 08:04:44 -0400 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-96-mzFZdOegNa6256xBo88UXA-1; Fri, 09 Apr 2021 08:04:36 -0400 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 6F82E107ACCA; Fri, 9 Apr 2021 12:04:35 +0000 (UTC) Received: from localhost (ovpn-114-67.ams2.redhat.com [10.36.114.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C9C25C1A1; Fri, 9 Apr 2021 12:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617969880; 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=1srMCU2bYhO+BsWlK/xCgdMlVZmHB88CcU9bByF1iPo=; b=e48pTYTrkMSwv75g1H8j9RuU3Nco7BBoJdBW46cU2p23v5dAGay0UPsIaEkKBG0C5cNbg8 mFZFM5HY2WgypkiAMveNdNFEt3YUxRtcRaaZYVgOmG+/qIv18MVFFwgt5P8gBEP6jkFYsk EukAaR8li6Otoa6mfW5/H+teAVtL0Bo= X-MC-Unique: mzFZdOegNa6256xBo88UXA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 5/4] iotests: Test completion immediately after drain Date: Fri, 9 Apr 2021 14:04:22 +0200 Message-Id: <20210409120422.144040-6-mreitz@redhat.com> In-Reply-To: <20210409120422.144040-1-mreitz@redhat.com> References: <20210409120422.144040-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Kevin Wolf , Vladimir Sementsov-Ogievskiy , John Snow , qemu-devel@nongnu.org, Max Reitz 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" Test what happens when you have multiple busy block jobs, drain all (via an empty transaction), and immediately issue a block-job-complete on one of the jobs. Sometimes it will still be in STANDBY, in which case block-job-complete used to fail. It should not. Signed-off-by: Max Reitz --- .../tests/mirror-complete-after-drain | 89 +++++++++++++++++++ .../tests/mirror-complete-after-drain.out | 14 +++ 2 files changed, 103 insertions(+) create mode 100755 tests/qemu-iotests/tests/mirror-complete-after-drain create mode 100644 tests/qemu-iotests/tests/mirror-complete-after-drain.out diff --git a/tests/qemu-iotests/tests/mirror-complete-after-drain b/tests/q= emu-iotests/tests/mirror-complete-after-drain new file mode 100755 index 0000000000..b096ffbcb4 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-complete-after-drain @@ -0,0 +1,89 @@ +#!/usr/bin/env python3 +# group: rw +# +# Tests for block-job-complete immediately after a drain +# +# Copyright (c) 2021 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import iotests + +iotests.script_initialize(supported_fmts=3D['raw']) + +DISK_JOBS =3D 4 +NULL_JOBS =3D 1 + + +# We cannot auto-generate these in a loop because the files are +# deleted when their scope ends +src_imgs =3D iotests.file_path('src0', 'src1', 'src2', 'src3') +dst_imgs =3D iotests.file_path('dst0', 'dst1', 'dst2', 'dst3') + +assert len(src_imgs) =3D=3D DISK_JOBS +assert len(dst_imgs) =3D=3D DISK_JOBS + + +for i in range(DISK_JOBS): + ret =3D iotests.qemu_img('create', '-f', iotests.imgfmt, src_imgs[i], = '128M') + assert ret =3D=3D 0 + + ret =3D iotests.qemu_img('create', '-f', iotests.imgfmt, dst_imgs[i], = '128M') + assert ret =3D=3D 0 + +with iotests.VM() as vm: + vm.add_object('iothread,id=3Diothr0') + vm.add_device('virtio-scsi,iothread=3Diothr0') + + for i in range(DISK_JOBS): + vm.add_blockdev(f'file,node-name=3Dsource-disk-{i},' + f'filename=3D{src_imgs[i]}') + + vm.add_blockdev(f'file,node-name=3Dtarget-disk-{i},' + f'filename=3D{dst_imgs[i]}') + + vm.add_device(f'scsi-hd,id=3Ddevice-disk-{i},drive=3Dsource-disk-{= i}') + + for i in range(NULL_JOBS): + vm.add_blockdev(f'null-co,node-name=3Dsource-null-{i},read-zeroes= =3Don') + vm.add_blockdev(f'null-co,node-name=3Dtarget-null-{i},read-zeroes= =3Don') + vm.add_device(f'scsi-hd,id=3Ddevice-null-{i},drive=3Dsource-null-{= i}') + + vm.launch() + + for i in range(DISK_JOBS): + vm.qmp_log('blockdev-mirror', + job_id=3Df'mirror-disk-{i}', + device=3Df'source-disk-{i}', + target=3Df'target-disk-{i}', + sync=3D'full', + granularity=3D1048576, + buf_size=3D(16 * 1048576)) + + for i in range(NULL_JOBS): + vm.qmp_log('blockdev-mirror', + job_id=3Df'mirror-null-{i}', + device=3Df'source-null-{i}', + target=3Df'target-null-{i}', + sync=3D'full') + + for i in range(DISK_JOBS + NULL_JOBS): + vm.event_wait('BLOCK_JOB_READY') + + for i in range(DISK_JOBS): + vm.hmp(f'qemu-io -d device-disk-{i} "write 0 128M"') + + vm.qmp_log('transaction', actions=3D[]) + vm.qmp_log('block-job-complete', device=3D'mirror-null-0') diff --git a/tests/qemu-iotests/tests/mirror-complete-after-drain.out b/tes= ts/qemu-iotests/tests/mirror-complete-after-drain.out new file mode 100644 index 0000000000..4d9d0529fe --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-complete-after-drain.out @@ -0,0 +1,14 @@ +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-0", "granularity": 1048576, "job-id": "mirror-disk-0", "syn= c": "full", "target": "target-disk-0"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-1", "granularity": 1048576, "job-id": "mirror-disk-1", "syn= c": "full", "target": "target-disk-1"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-2", "granularity": 1048576, "job-id": "mirror-disk-2", "syn= c": "full", "target": "target-disk-2"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"buf-size": 16777216, "device= ": "source-disk-3", "granularity": 1048576, "job-id": "mirror-disk-3", "syn= c": "full", "target": "target-disk-3"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"device": "source-null-0", "j= ob-id": "mirror-null-0", "sync": "full", "target": "target-null-0"}} +{"return": {}} +{"execute": "transaction", "arguments": {"actions": []}} +{"return": {}} +{"execute": "block-job-complete", "arguments": {"device": "mirror-null-0"}} +{"return": {}} --=20 2.29.2