From nobody Thu Apr 16 02:31:10 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=1692005812; cv=none; d=zohomail.com; s=zohoarc; b=gyt3ZF73ZUgFOi6+vAPWLFzAhFWEXKS5c1KjqvINSTra/HetQsr4A7jNV12CyBFpBjzyShJE5n3BPh7hRuHokCGQKVLKfuqS1eWJSvfpl57b77oh2SuNVBqG2y/aErJBhv2QWxTIqx2DZH+QdGpp8DGv/AOgRdfbmX+P0N0Kvh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692005812; 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=sPy6biOB3CUTfiGkUREcvnd+78DqvHP8GGhslXWmot8=; b=UvDUU/Nv55799Mk3aWVp2oxZjEB2HqrX2md6jbbE05MNooCLRhzLyGkEVEpnnErAiQ8w07E7ZfOmMa11Bm4+9hpgZ6Nl9F0r0FfSEScl5PdMN7AXS9Br2MQA8xjg97C+G4hvhnUnF+z0ZL/tO2WakQcK9uDsgMc6UvG1nSZ7BT4= 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 1692005812453300.02149329886674; Mon, 14 Aug 2023 02:36:52 -0700 (PDT) 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-161-P3UjIfFOM9i8aRQVkqARCQ-1; Mon, 14 Aug 2023 05:36:47 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F41CB823D75; Mon, 14 Aug 2023 09:36:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E288F401E6A; Mon, 14 Aug 2023 09:36:44 +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 D8A7519465B3; Mon, 14 Aug 2023 09:36:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 915231946597 for ; Mon, 14 Aug 2023 09:36:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8549140C2074; Mon, 14 Aug 2023 09:36:21 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.226.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2805440C2073 for ; Mon, 14 Aug 2023 09:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692005811; 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=sPy6biOB3CUTfiGkUREcvnd+78DqvHP8GGhslXWmot8=; b=ezIREmxNc+2oSBTbD0DuhMkc/37SvafeW27GptaUNGOXcy3xvdCgcyQ3x67bSt4nb71ndG XK6XiIcZ42S1RnJsYzIPPO0Hc0iu5PGJ/WatbZD3J1OGgnINne+TdESfc4t+pbx37nyPB2 eIybH2TceprEq2MO7YGhRJ1jLGspxyA= X-MC-Unique: P3UjIfFOM9i8aRQVkqARCQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 05/25] virDomainSnapshotAlignDisks: Allow overriding user-configured snapshot default Date: Mon, 14 Aug 2023 11:35:57 +0200 Message-ID: <5598d91b29bd944a369a6f43eda52812a6626415.1692005543.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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.10 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: 1692005814516100005 Content-Type: text/plain; charset="utf-8"; x-default="true" This new option will be used by external snapshot revert code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/snapshot_conf.c | 15 ++++++++++++--- src/conf/snapshot_conf.h | 3 ++- src/qemu/qemu_snapshot.c | 2 +- src/test/test_driver.c | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 8ecf311a17..67cec34920 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -581,6 +581,8 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def, * @default_snapshot: snapshot location to assign to disks which don't hav= e any * @uniform_internal_snapshot: Require that for an internal snapshot all d= isks * take part in the internal snapshot + * @force_default_location: Always use @default_snapshot even if domain def + * has different default value * * Align snapdef->disks to domain definition, filling in any missing disks= or * snapshot state defaults given by the domain, with a fallback to @@ -598,6 +600,10 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnaps= hotDef *def, * in the internal snapshot. This is for hypervisors where granularity of = an * internal snapshot can't be controlled. * + * When @force_default_location is true we will always use @default_snapsh= ot + * even if domain definition has different default set. This is required to + * create new snapshot definition when reverting external snapshots. + * * Convert paths to disk targets for uniformity. * * On error -1 is returned and a libvirt error is reported. @@ -606,7 +612,8 @@ int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, - bool uniform_internal_snapshot) + bool uniform_internal_snapshot, + bool force_default_location) { virDomainDef *domdef =3D snapdef->parent.dom; g_autoptr(GHashTable) map =3D virHashNew(NULL); @@ -714,7 +721,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapd= ef, /* Don't snapshot empty drives */ if (virStorageSourceIsEmpty(domdef->disks[i]->src)) snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; - else + else if (!force_default_location) snapdisk->snapshot =3D domdef->disks[i]->snapshot; =20 snapdisk->src->type =3D VIR_STORAGE_TYPE_FILE; @@ -970,8 +977,10 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, virDomainSnapshotDefIsExternal(snapdef)) align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; =20 - if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, = true) < 0) + if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, + true, false) < 0) { return -1; + } =20 return 0; } diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index ab76af604a..14254d1c86 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -126,7 +126,8 @@ char *virDomainSnapshotDefFormat(const char *uuidstr, int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot, virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, - bool uniform_internal_snapshot); + bool uniform_internal_snapshot, + bool force_default_location); =20 bool virDomainSnapshotDefIsExternal(virDomainSnapshotDef *def); bool virDomainSnapshotIsExternal(virDomainMomentObj *snap); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 91de8b0c31..844b02d427 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1585,7 +1585,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, else def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } - if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) < 0) + if (virDomainSnapshotAlignDisks(def, NULL, align_location, true, false= ) < 0) return -1; =20 return 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4b8e02c684..905be3853b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8724,7 +8724,7 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } =20 - return virDomainSnapshotAlignDisks(def, NULL, align_location, true); + return virDomainSnapshotAlignDisks(def, NULL, align_location, true, fa= lse); } =20 =20 --=20 2.41.0