From nobody Fri Dec 27 12:12:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634321352180.55827222532605; Tue, 26 Nov 2024 07:18:41 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BE1B3C84; Tue, 26 Nov 2024 10:18:40 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 27D7A1C2A; Tue, 26 Nov 2024 10:17:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6472A18BF; Tue, 26 Nov 2024 10:17:09 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 62AB218F0 for ; Tue, 26 Nov 2024 10:16:55 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-k5uLpcuFM3uYN0-le5eZfg-1; Tue, 26 Nov 2024 10:16:52 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A7173196EC3B for ; Tue, 26 Nov 2024 15:16:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5BB61979041 for ; Tue, 26 Nov 2024 15:16:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732634215; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=xk1IrGnBEw1qDiS+HsstfrPiUj9FaQUSMYyO5J+6wF4=; b=CXkKbRgN281D8Zn6ktmHZNd592n8z7Hdq288I3UBMTXUJ4fugSCzDuaFLaW9Z3EjoMv1tn /PbXp5oyT7NSzir4C7oNLWhpjGAYn0AmRyhOtKn7kEJj3+6WmSkUF9ctLBDCMWLxpmQciU u8agbCCS1uDHn0EVd+lnb2MuHsqk3UI= X-MC-Unique: k5uLpcuFM3uYN0-le5eZfg-1 X-Mimecast-MFC-AGG-ID: k5uLpcuFM3uYN0-le5eZfg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 4/8] qemu: block: Ensure that is in appropriate state Date: Tue, 26 Nov 2024 16:16:15 +0100 Message-ID: <5fce28c19e492ee64eed32c218737d54254581ab.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QIhuEpqe06m2bcN6GidCBRTxNXVeYS-al4BQR-FQLoE_1732634212 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OU4N64C4G4ERVXSLJOZVFZIYPGFFUPRV X-Message-ID-Hash: OU4N64C4G4ERVXSLJOZVFZIYPGFFUPRV X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634322257019100 Content-Type: text/plain; charset="utf-8" In contrast to normal backing chain members where qemu does honour the 'auto-read-only' property the 'data-file' nodes are not automatically reopened by qemu. Libvirt now has the infrastructure to reopen them explicitly so use it for all transitions of the 'commit' block job. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 33 ++++++++++++++++++++++++++++++++- src/qemu/qemu_blockjob.c | 16 +++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index af317a1f1f..35dca8ee7b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3696,6 +3696,15 @@ qemuBlockCommit(virDomainObj *vm, false, false, false) < 0) goto cleanup; + if (baseSource->dataFileStore) { + if (qemuDomainStorageSourceAccessAllow(driver, vm, baseSource->dat= aFileStore, + false, false, false) < 0) + goto cleanup; + + if (qemuBlockReopenReadWrite(vm, baseSource->dataFileStore, asyncJ= ob) < 0) + goto cleanup; + } + if (top_parent && top_parent !=3D disk->src) { /* While top_parent is topmost image, we don't need to remember its * owner as it will be overwritten upon finishing the commit. Henc= e, @@ -3703,6 +3712,15 @@ qemuBlockCommit(virDomainObj *vm, if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, false, false, false) < 0) goto cleanup; + + if (top_parent->dataFileStore) { + if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent-= >dataFileStore, + false, false, false) < = 0) + goto cleanup; + + if (qemuBlockReopenReadWrite(vm, top_parent->dataFileStore, as= yncJob) < 0) + goto cleanup; + } } if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, @@ -3748,12 +3766,25 @@ qemuBlockCommit(virDomainObj *vm, if (rc < 0 && clean_access) { virErrorPtr orig_err; virErrorPreserveLast(&orig_err); + /* Revert access to read-only, if possible. */ + if (baseSource->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, baseSource->dat= aFileStore, + true, false, false); + qemuBlockReopenReadOnly(vm, baseSource->dataFileStore, asyncJo= b); + } qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, true, false, false); - if (top_parent && top_parent !=3D disk->src) + if (top_parent && top_parent !=3D disk->src) { + if (top_parent->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, top_parent-= >dataFileStore, + true, false, false); + + qemuBlockReopenReadWrite(vm, top_parent->dataFileStore, as= yncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, true, false, false); + } virErrorRestore(&orig_err); } diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c35321790e..4e77543fa8 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1064,11 +1064,25 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDriv= er *driver, return; /* revert access to images */ + if (job->data.commit.base->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.ba= se->dataFileStore, + true, false, false); + qemuBlockReopenReadOnly(vm, job->data.commit.base->dataFileStore, = asyncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.base, true, false, false); - if (job->data.commit.topparent !=3D job->disk->src) + + if (job->data.commit.topparent !=3D job->disk->src) { + if (job->data.commit.topparent->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commi= t.topparent->dataFileStore, + true, false, false); + + qemuBlockReopenReadWrite(vm, job->data.commit.topparent->dataF= ileStore, asyncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.to= pparent, true, false, true); + } + baseparent->backingStore =3D NULL; job->data.commit.topparent->backingStore =3D job->data.commit.base; --=20 2.47.0