From nobody Wed Mar 12 13:01:31 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 1740566062596214.69815433581846; Wed, 26 Feb 2025 02:34:22 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 511AD11A6; Wed, 26 Feb 2025 05:34:21 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9E3D51083; Wed, 26 Feb 2025 05:34:01 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 644CFE7A; Wed, 26 Feb 2025 05:33:58 -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 BE267D65 for ; Wed, 26 Feb 2025 05:33:57 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-VrM78TFTOCKeyIAEtZVIWQ-1; Wed, 26 Feb 2025 05:33:55 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 20B411800997 for ; Wed, 26 Feb 2025 10:33:55 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.98]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 581E51800980 for ; Wed, 26 Feb 2025 10:33:54 +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.8 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=1740566037; 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=3E3rEnljlCeQGSFrOAIJWUWPD2UXL/9wxIDIpUKA4AU=; b=A+jly2YFE7adCOWLxxmUXMgEqBJaeYcdAOG6PuaYtNkFpC9agbz+sV37sa4leNntUAlWGY En6XLGCCsgT9wLPngtivl8PbWE5+dSEsjm3djkmYbMH1yUARWusrPla12kjPyCbaI/rgKY ngwRJSr2s0GTjc9kT+ZUnuH9+3s3CDA= X-MC-Unique: VrM78TFTOCKeyIAEtZVIWQ-1 X-Mimecast-MFC-AGG-ID: VrM78TFTOCKeyIAEtZVIWQ_1740566035 From: Pavel Hrdina To: devel@lists.libvirt.org Subject: [libvirt PATCH] qemu: snapshot: error out early when reverting snapshot for VM with non-file disk Date: Wed, 26 Feb 2025 11:33:52 +0100 Message-ID: <0cfdb8f4c0d12fd0c26644927eda2f87b1920f76.1740565988.git.phrdina@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: e1Sq3oXVJQuuDtF1JFuAyPE_mX8CwqAI18eHpSX9omw_1740566035 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JKM7ZKZZ6X6OILO5A7NA5X26IMEYRQBT X-Message-ID-Hash: JKM7ZKZZ6X6OILO5A7NA5X26IMEYRQBT X-MailFrom: phrdina@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: 1740566065147019100 Content-Type: text/plain; charset="utf-8"; x-default="true" Before this patch the code would start the revert process by destroying the VM and preparing to revert where it would fail with following error: error: unsupported configuration: source for disk 'sdb' is not a regula= r file; refusing to generate external snapshot name and leaving user with offline VM even if it was running. Make the check before we start the revert process to not destroy VMs. Resolves: https://issues.redhat.com/browse/RHEL-30971 Resolves: https://issues.redhat.com/browse/RHEL-79928 Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f7d6272907..c5f70f5b10 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2205,6 +2205,8 @@ qemuSnapshotRevertValidate(virDomainObj *vm, virDomainSnapshotDef *snapdef, unsigned int flags) { + size_t i; + if (!vm->persistent && snapdef->state !=3D VIR_DOMAIN_SNAPSHOT_RUNNING && snapdef->state !=3D VIR_DOMAIN_SNAPSHOT_PAUSED && @@ -2232,6 +2234,17 @@ qemuSnapshotRevertValidate(virDomainObj *vm, } } =20 + for (i =3D 0; i < snap->def->dom->ndisks; i++) { + virDomainDiskDef *disk =3D snap->def->dom->disks[i]; + + if (disk->src->type !=3D VIR_STORAGE_TYPE_FILE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("source disk for '%1$s' is not a regural file= , reverting to snapshot is not supported"), + disk->dst); + return -1; + } + } + return 0; } =20 --=20 2.48.1