From nobody Fri Apr 19 22:05:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1678282325; cv=none; d=zohomail.com; s=zohoarc; b=lMfD2h+kzqqY8m4YUbwlIlRK+YfLWPo3jRxBSksf2Pi3Syy5D95d9EBhhQBqvjES8N+oBvY3u9LiK5e/JUmpg5NLmziyaxAMzovsp2nNtrnorg3vvUuNU3LuWBNmjWyDz/3RFiUiM94tOCAynHue0bMc4Uwmu1hQ4aW7+X1BLmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678282325; 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=PzURMT8SMKR3OoO0UR4Oe2EAlZXmOxl8tkaYJPIz2+w=; b=jzKqLO7rrXXA242nIGb4u1RH8S1ZTa4GZjvqJ9cAOiZl7Z27iOcXMiWlolRv3KQbtvuxkOgR8LokrGYjR/yvj+vXGWq6nnRb3eXWOFFm1NcOkn4jsWgMNMAaSdDhBkKZZUOHk3f6OSN9hdp36MO3u6lfZVCLUdYdPLzzg4x3ij8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1678282325379405.98415000929106; Wed, 8 Mar 2023 05:32:05 -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-404-0TKaMmNeNAalk6Pk7IiK5w-1; Wed, 08 Mar 2023 08:31:59 -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 00614802D2F; Wed, 8 Mar 2023 13:31:57 +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 DFC72C15BAD; Wed, 8 Mar 2023 13:31:56 +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 AF4A619465B2; Wed, 8 Mar 2023 13:31:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 943541946A41 for ; Wed, 8 Mar 2023 13:29:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 894772166B2A; Wed, 8 Mar 2023 13:29:25 +0000 (UTC) Received: from antique-laptop.redhat.com (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161212166B26 for ; Wed, 8 Mar 2023 13:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678282324; 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=PzURMT8SMKR3OoO0UR4Oe2EAlZXmOxl8tkaYJPIz2+w=; b=Dp1c00G+zbP8WUrZTaZeHpuJwEPuVo+7OTHQc73WGbVkdO7lSFKrFiorMsrkHcjq4KehV0 TtQLrZ9QKKZs3nRI/xA1dKro5bJX4ms8KGfifwKgD/vC7xuQXlI3TV8gypHguBadgwP2LV UTxTOzvV3ADmnkWzGfq5CeIhlz2VqNo= X-MC-Unique: 0TKaMmNeNAalk6Pk7IiK5w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu_snapshot: fix external snapshot deletion for non-active snapshots Date: Wed, 8 Mar 2023 14:29:21 +0100 Message-Id: <1c36326ac9d9eadb94cc59033e984f7ad980feac.1678282122.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1678282326469100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For shutoff VMs we don't have the storage source backing chain populated so it will fail this check and error out. Move it to part that is done only when VM is running. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7207b5879a..7aa4195f04 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2331,18 +2331,6 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, if (!data->domDisk) return -1; =20 - data->diskSrc =3D virStorageSourceChainLookupBySource(data->domDis= k->src, - data->snapDisk= ->src, - &data->prevDis= kSrc); - if (!data->diskSrc) - return -1; - - if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk-= >src)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("VM disk source and snapshot disk source are = not the same")); - return -1; - } - data->parentDomDisk =3D virDomainDiskByTarget(snapdef->parent.dom, data->snapDisk->name); if (!data->parentDomDisk) { @@ -2353,6 +2341,18 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, } =20 if (virDomainObjIsActive(vm)) { + data->diskSrc =3D virStorageSourceChainLookupBySource(data->do= mDisk->src, + data->snap= Disk->src, + &data->pre= vDiskSrc); + if (!data->diskSrc) + return -1; + + if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapD= isk->src)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("VM disk source and snapshot disk source = are not the same")); + return -1; + } + data->parentDiskSrc =3D data->diskSrc->backingStore; if (!virStorageSourceIsBacking(data->parentDiskSrc)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", --=20 2.39.2