From nobody Mon May 6 07:46:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676047596; cv=none; d=zohomail.com; s=zohoarc; b=UTxYOo/dZ55QJJtvrKfPlcEK8yJOSTkI9musLVyH/Ea6kWqFiNPTk17H7OvK9IGJ5sRYjAKYtbbRBuOMF8wrC2gDDbnNABtf3HhEa5JnVmvFxGBsl/r9mjcVKoP1RFXytzD9vFBMH3rAR1g7i/3VQjQTwfZwPR9Rzr6N0b8JiOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676047596; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+dSXD46gv3Rzb4V/NQWB4HjJC/Ixm8l/kNFfoQSUPlA=; b=DAco/G7zWWHcKioKx06GjWLAMx/fVRRFK0fez4WprghsYiI9V1LQbLbX2CdCTYx7g+sKDDOPGQumfbWH1olW9Y0/C70EDL/5SWAZt+/VzzPYsOk/6Wf8SsVEhKZFbOJ8atQ8hi2Sa82YQ02xDnySNEcEyN+44+AGVeiSSqgO0F4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1676047596428244.2883696828651; Fri, 10 Feb 2023 08:46:36 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-257-UxZvKPMpOlmR0dl1lMc92g-1; Fri, 10 Feb 2023 11:46:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37D1F1019CBC; Fri, 10 Feb 2023 16:46:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AFB2C16023; Fri, 10 Feb 2023 16:46:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7945F1946594; Fri, 10 Feb 2023 16:46:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A1BA0194658F for ; Fri, 10 Feb 2023 16:46:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8D24C492B00; Fri, 10 Feb 2023 16:46:27 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED339492C3E for ; Fri, 10 Feb 2023 16:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676047595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+dSXD46gv3Rzb4V/NQWB4HjJC/Ixm8l/kNFfoQSUPlA=; b=YNmfimAo4e6eNOi++7M/yFRopFEpK8eyjkp3oDz2t18u+EEgZ4lZ0dre9FMQR84+rF1buX EG1cAGyYn1noM76xxVbCsS4XuIaaK1Ah1y0h/1amtRPxnhg2GmClVSH6PQtgPgpy3DxJ/W CFDdgHLe9BvT0MkI4RIdpvftcMh1teQ= X-MC-Unique: UxZvKPMpOlmR0dl1lMc92g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: blockjob: Handle 'pending' blockjob state only when we need it Date: Fri, 10 Feb 2023 17:46:25 +0100 Message-Id: <8210e0a1e61007c1279b81d24a63126e00d24d46.1676047585.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676047598495100001 Content-Type: text/plain; charset="utf-8" The 'pending' state needs to be handled by the blockjob code only when the snapshot code requests a block-commit without auto-finalization. If we always handle it we fail to properly remove the blockjob data for the 'blockdev-create' job as that also transitions trhough 'pending' but we'd never update it once it reaches 'concluded' as the code already thinks that the job has finished and is no longer watching it. Introduce a 'processPending' property into block job data and set it only when we know that we need to process 'pending'. Fixes: 90d9bc9d74a5157167548b26c00b1a016655e295 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2168769 Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_block.c | 1 + src/qemu/qemu_blockjob.c | 19 ++++++++++--------- src/qemu/qemu_blockjob.h | 4 ++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4c06565e0f..5e700eff99 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3373,6 +3373,7 @@ qemuBlockCommit(virDomainObj *vm, if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, baseSource, flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, + autofinalize, flags))) goto cleanup; diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index cb2d05d71d..a20cf1db62 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -274,6 +274,7 @@ qemuBlockJobDiskNewCommit(virDomainObj *vm, virStorageSource *top, virStorageSource *base, bool delete_imgs, + virTristateBool autofinalize, unsigned int jobflags) { g_autoptr(qemuBlockJobData) job =3D NULL; @@ -290,6 +291,7 @@ qemuBlockJobDiskNewCommit(virDomainObj *vm, job->data.commit.top =3D top; job->data.commit.base =3D base; job->data.commit.deleteCommittedImages =3D delete_imgs; + job->processPending =3D autofinalize =3D=3D VIR_TRISTATE_BOOL_NO; job->jobflags =3D jobflags; if (qemuBlockJobRegister(job, vm, disk, true) < 0) @@ -532,8 +534,6 @@ qemuBlockJobRefreshJobs(virDomainObj *vm) if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW || job->state =3D=3D QEMU_BLOCKJOB_STATE_RUNNING) job->newstate =3D newstate; - } else if (newstate =3D=3D QEMU_BLOCKJOB_STATE_PENDING) { - job->newstate =3D newstate; } /* don't update the job otherwise */ } @@ -1568,13 +1568,14 @@ qemuBlockJobEventProcess(virQEMUDriver *driver, case QEMU_BLOCKJOB_STATE_PENDING: /* Similarly as for 'ready' state we should handle it only when - * previous state was 'new' or 'running' as there are other cases - * when it can be emitted by QEMU. Currently we need this only when - * deleting non-active external snapshots. */ - if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW || - job->state =3D=3D QEMU_BLOCKJOB_STATE_RUNNING) { - job->state =3D job->newstate; - qemuDomainSaveStatus(vm); + * previous state was 'new' or 'running' and only if the blockjob = code + * is handling finalization of the job explicitly. */ + if (job->processPending) { + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW || + job->state =3D=3D QEMU_BLOCKJOB_STATE_RUNNING) { + job->state =3D job->newstate; + qemuDomainSaveStatus(vm); + } } job->newstate =3D -1; break; diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index e9b283da20..f1ac43b4c7 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -138,6 +138,9 @@ struct _qemuBlockJobData { int brokentype; /* the previous type of a broken blockjob qemuBlockJob= Type */ + bool processPending; /* process the 'pending' state of the job, if the= job + should not be auto-finalized */ + bool invalidData; /* the job data (except name) is not valid */ bool reconnected; /* internal field for tracking whether job is live a= fter reconnect to qemu */ }; @@ -175,6 +178,7 @@ qemuBlockJobDiskNewCommit(virDomainObj *vm, virStorageSource *top, virStorageSource *base, bool delete_imgs, + virTristateBool autofinalize, unsigned int jobflags); qemuBlockJobData * --=20 2.39.1