From nobody Sun Feb 8 16:05:48 2026 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=1672919259; cv=none; d=zohomail.com; s=zohoarc; b=haDCtlBfyE5vzT64aW91687ee3/Se5NatYdAZfvqFQ+T8bLLDDUzgJFZ8k+/iwDPpFilZATYaYMXlLHnUgoszL2WcB9u7Rqjr5mT6Qde2nQHNRAdeUwM5NMAlTHPQtm3eD8nrHYXabo+xUAnEDNaHolLU4p5H8M+F0U3cbvWhX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672919259; h=Content-Type:Content-Transfer-Encoding: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=voxZaO4p2SorRku4ISyaoq3ApiTi/rB9G+NM5BEW9NY=; b=k+OOLu/qcdTSqSocuV3jNEvI9cA0EUWcIGDehINDu8+3SxRgRUM7iy6EPWdIr011nqVjokceL8asuXZZ1Xe21nMDM5im5nqhkVy47aHTVz/l1Lo8C7gr6tygUMMkFczg8UtJfkS9FO14JyBiVC2E9GXkURVJpQQdhNluP1hFQSI= 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 1672919259823833.8662399434031; Thu, 5 Jan 2023 03:47:39 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-cuc01V33NF2nS2FM8kwzfg-1; Thu, 05 Jan 2023 06:47:37 -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 BD310280413E; Thu, 5 Jan 2023 11:47:32 +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 A7C8FC15BA0; Thu, 5 Jan 2023 11:47:32 +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 9B1CB1946A73; Thu, 5 Jan 2023 11:47:32 +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 3762E1946A72 for ; Thu, 5 Jan 2023 11:47:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 215C649BB6A; Thu, 5 Jan 2023 11:47:31 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-38.brq.redhat.com [10.40.194.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4070492D8B for ; Thu, 5 Jan 2023 11:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672919258; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=voxZaO4p2SorRku4ISyaoq3ApiTi/rB9G+NM5BEW9NY=; b=e4cU9eaFtPL/eowPUpUeOJHWcgTCLY1XoEk59B2Pqq90T9XG52OS7vh1qwy6ezW4DJ7HPX UIMbehPDldWely/0ddh4bM19Cy4IRNeYWeK1o5vjp+m2sfvhCxMQmSGdQ8TSzLfY9kPQHK lpb/vzWYROxb+9kwrafv16w0H6/X38w= X-MC-Unique: cuc01V33NF2nS2FM8kwzfg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 22/31] qemu_snapshot: error out when deleting internal snapshot on non-active disk Date: Thu, 5 Jan 2023 12:46:58 +0100 Message-Id: <1a12d0ca37925ceb17b540bd4b6b28ae77fb68bc.1672918676.git.phrdina@redhat.com> In-Reply-To: References: 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: 1672919260983100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Deleting internal snapshot when the currently active disk image is different than where the internal snapshot was taken doesn't work correctly. This applies to a running VM only as we are using QMP command and talking to the QEMU process that is using different disk. This works correctly when the VM is shut of as in this case we spawn qemu-img process to delete the snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d7da317e22..31e7087081 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2492,9 +2492,31 @@ qemuSnapshotCountExternalInternal(void *payload, =20 =20 static int -qemuSnapshotDeleteValidate(virDomainMomentObj *snap, +qemuSnapshotDeleteValidate(virDomainObj *vm, + virDomainMomentObj *snap, unsigned int flags) { + if (!virDomainSnapshotIsExternal(snap) && + virDomainObjIsActive(vm)) { + ssize_t i; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + virDomainDiskDef *vmdisk =3D NULL; + virDomainDiskDef *disk =3D NULL; + + vmdisk =3D qemuDomainDiskByName(vm->def, snapDisk->name); + disk =3D qemuDomainDiskByName(snapdef->parent.dom, snapDisk->n= ame); + + if (!virStorageSourceIsSameLocation(vmdisk->src, disk->src)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("disk image '%s' for internal snapshot '%= s' is not the same as disk image currently used by VM"), + snapDisk->name, snap->def->name); + return -1; + } + } + } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { @@ -2548,7 +2570,7 @@ qemuSnapshotDelete(virDomainObj *vm, goto endjob; =20 if (!metadata_only) { - if (qemuSnapshotDeleteValidate(snap, flags) < 0) + if (qemuSnapshotDeleteValidate(vm, snap, flags) < 0) goto endjob; } =20 --=20 2.39.0