From nobody Tue Sep 9 19:12:42 2025 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 1738595332783370.24715439195495; Mon, 3 Feb 2025 07:08:52 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8A4D118C8; Mon, 3 Feb 2025 09:55:01 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8B42C18B6; Mon, 3 Feb 2025 09:54:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 48378186B; Mon, 3 Feb 2025 09:54:40 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 8A65E185B for ; Mon, 3 Feb 2025 09:54:39 -0500 (EST) Received: from mx-prod-mc-04.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-636-hSciEfq7N8uSBbmN8_NTzQ-1; Mon, 03 Feb 2025 09:54:37 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 190F51955D63 for ; Mon, 3 Feb 2025 14:54:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.3]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 479EC18008D4 for ; Mon, 3 Feb 2025 14:54:36 +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=-0.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=1738594479; 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; bh=mbNeM3vk3n53+QQEMH0qzhgvEPtHPFbVVz05ARhqdAc=; b=O1EipjFPIsNox/7IgKbPWt16S/FIxANynysztgV354obhVbWUZKr301FdywvU1AvVTPHAQ GnSPPWHdhYAnats9PDW/64HAXUQYH6Qmd02/TaqnqtobBkVKyGMjNMQAJyy2UXvE6YP8lq Thk/eqk/eojORJ2zggNXxUIQjTRa7mM= X-MC-Unique: hSciEfq7N8uSBbmN8_NTzQ-1 X-Mimecast-MFC-AGG-ID: hSciEfq7N8uSBbmN8_NTzQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH] qemu: snapshot: Limit scope of checkpoint-snapshot interlock Date: Mon, 3 Feb 2025 15:54:34 +0100 Message-ID: <2f12b17c7cc2dff61a0d05b246aa07cc6cee29ce.1738594474.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: OZN0ZyTqr6IiRF3sG3RAdKP36tD99b2odA3M7lfEQJY_1738594477 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DZHMAAUZCJSBXUCHVRAQ5YRDFTOPXUP5 X-Message-ID-Hash: DZHMAAUZCJSBXUCHVRAQ5YRDFTOPXUP5 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: 1738595336234019100 Content-Type: text/plain; charset="utf-8" 'qemuDomainSupportsCheckpointsBlockjobs()' should really be used only with active VMs based on the scope of interlocking it does. This means that the inactive snapshot code path needs to do the interlocking based on what's supported: - external snapshot support was not implemented yet (bitmaps need to be propagated to the new overlay image) - internal snapshot support can be deferred to qemu Move the check inside qemuSnapshotPrepare() which has knowledge about the snapshot type and implement an explicit check for the inactive case. See: https://gitlab.com/libvirt/libvirt/-/issues/739 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7ce018b026..ecf8eb3cca 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -39,6 +39,7 @@ #include "domain_audit.h" #include "locking/domain_lock.h" #include "virdomainsnapshotobjlist.h" +#include "virdomaincheckpointobjlist.h" #include "virqemu.h" #include "storage_source.h" @@ -1067,6 +1068,23 @@ qemuSnapshotPrepare(virDomainObj *vm, } + /* Handle interlocking with 'checkpoints': + * - if the VM is online use qemuDomainSupportsCheckpointsBlockjobs + * - if the VM is offline disallow external snapshots as the support f= or + * propagating bitmaps into the would-be-created overlay is not yet = implemented + */ + if (!active) { + if (external && + virDomainListCheckpoints(vm->checkpoints, NULL, NULL, NULL, 0)= > 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("support for offline external snapshots while= checkpoint exists was not yet implemented")); + return -1; + } + } else { + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) + return -1; + } + /* Alter flags to let later users know what we learned. */ if (external && !active) *flags |=3D VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY; @@ -2134,9 +2152,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, NULL); - if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) - return NULL; - if (!vm->persistent && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot halt after transient domain snapshot")); --=20 2.48.1