From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id D0FA41FF15E
	for <inbox@lore.proxmox.com>; Tue, 22 Apr 2025 13:53:40 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 819A93AE71;
	Tue, 22 Apr 2025 13:52:34 +0200 (CEST)
To: pve-devel@lists.proxmox.com
Date: Tue, 22 Apr 2025 13:51:32 +0200
In-Reply-To: <20250422115141.808427-1-alexandre.derumier@groupe-cyllene.com>
References: <20250422115141.808427-1-alexandre.derumier@groupe-cyllene.com>
MIME-Version: 1.0
Message-ID: <mailman.37.1745322752.394.pve-devel@lists.proxmox.com>
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Post: <mailto:pve-devel@lists.proxmox.com>
From: Alexandre Derumier via pve-devel <pve-devel@lists.proxmox.com>
Precedence: list
Cc: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
X-Mailman-Version: 2.1.29
X-BeenThere: pve-devel@lists.proxmox.com
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
Subject: [pve-devel] [PATCH pve-storage 5/5] volume_has_feature: return
 storage|qemu_internal|qemu_external snapshot_type
Content-Type: multipart/mixed; boundary="===============7328846270735007914=="
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

--===============7328846270735007914==
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <root@formationkvm1.odiso.net>
X-Original-To: pve-devel@lists.proxmox.com
Delivered-To: pve-devel@lists.proxmox.com
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by lists.proxmox.com (Postfix) with ESMTPS id 2A21BC8CD2
	for <pve-devel@lists.proxmox.com>; Tue, 22 Apr 2025 13:52:30 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 1DBA03A7BB
	for <pve-devel@lists.proxmox.com>; Tue, 22 Apr 2025 13:51:58 +0200 (CEST)
Received: from bastiontest.odiso.net (unknown [IPv6:2a0a:1580:2000:6700::14])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by firstgate.proxmox.com (Proxmox) with ESMTPS
	for <pve-devel@lists.proxmox.com>; Tue, 22 Apr 2025 13:51:54 +0200 (CEST)
Received: from formationkvm1.odiso.net (unknown [10.11.201.57])
	by bastiontest.odiso.net (Postfix) with ESMTP id 87B84862E44;
	Tue, 22 Apr 2025 13:51:44 +0200 (CEST)
Received: by formationkvm1.odiso.net (Postfix, from userid 0)
	id 61C4A1115FBC; Tue, 22 Apr 2025 13:51:43 +0200 (CEST)
From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-storage 5/5] volume_has_feature: return storage|qemu_internal|qemu_external snapshot_type
Date: Tue, 22 Apr 2025 13:51:32 +0200
Message-Id: <20250422115141.808427-12-alexandre.derumier@groupe-cyllene.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250422115141.808427-1-alexandre.derumier@groupe-cyllene.com>
References: <20250422115141.808427-1-alexandre.derumier@groupe-cyllene.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
	AWL                     0.115 Adjusted score from AWL reputation of From: address
	BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
	DMARC_NONE                0.1 DMARC none policy
	HEADER_FROM_DIFFERENT_DOMAINS  0.001 From and EnvelopeFrom 2nd level mail domains are different
	KAM_DMARC_NONE           0.25 DKIM has Failed or SPF has failed on the message and the domain has no DMARC policy
	KAM_DMARC_STATUS         0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
	KAM_LAZY_DOMAIN_SECURITY      1 Sending domain does not have any anti-forgery methods
	RDNS_NONE               0.793 Delivered to internal network by a host with no rDNS
	SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
	SPF_NONE                0.001 SPF: sender does not publish an SPF Record

1: storage snapshot
2: qemu internal snapshot
3: qemu external snapshot

can be use be qemu-server to known the type of snapshot supported

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm |  6 +++---
 src/PVE/Storage/Plugin.pm    | 11 ++++++++---
 src/PVE/Storage/RBDPlugin.pm |  8 +++++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index b20fe98..710933f 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -863,8 +863,8 @@ sub volume_has_feature {
             current => { qcow2 => 1, raw => 1},
         },
         snapshot => {
-            current => { qcow2 => 1 },
-            snap => { qcow2 => 1 },
+            current => { qcow2 => 3 },
+            snap => { qcow2 => 3 },
         },
 #	fixme: add later ? (we need to handle basepath, volume activation,...)
 #	template => {
@@ -885,7 +885,7 @@ sub volume_has_feature {
     }else{
 	$key =  $isBase ? 'base' : 'current';
     }
-    return 1 if defined($features->{$feature}->{$key}->{$format});
+    return $features->{$feature}->{$key}->{$format} if defined($features->{$feature}->{$key}->{$format});
 
     return undef;
 }
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 0319ab2..a26af8a 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1409,10 +1409,15 @@ sub storage_can_replicate {
 sub volume_has_feature {
     my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running, $opts) = @_;
 
+    #1: only storage snapshot
+    #2: support internal snapshot
+    #3: support external snapshot
+    my $snapshot_type = $scfg->{snapext} ? 3 : 2;
+
     my $features = {
 	snapshot => {
-	    current => { qcow2 => 1 },
-	    snap => { qcow2 => 1 },
+	    current => { qcow2 => $snapshot_type },
+	    snap => { qcow2 => $snapshot_type },
 	},
 	clone => {
 	    base => { qcow2 => 1, raw => 1, vmdk => 1 },
@@ -1455,7 +1460,7 @@ sub volume_has_feature {
 	$key =  $isBase ? 'base' : 'current';
     }
 
-    return 1 if defined($features->{$feature}->{$key}->{$format});
+    return $features->{$feature}->{$key}->{$format} if defined($features->{$feature}->{$key}->{$format});
 
     return undef;
 }
diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index c78db00..c991f10 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -854,8 +854,10 @@ sub volume_snapshot_needs_fsfreeze {
 sub volume_has_feature {
     my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
 
-   my $features = {
-	snapshot => { current => 1, snap => 1},
+    my $snapshot_type = $scfg->{krbd} ? 1 : 2;
+
+    my $features = {
+	snapshot => { current => $snapshot_type, snap => $snapshot_type},
 	clone => { base => 1, snap => 1},
 	template => { current => 1},
 	copy => { base => 1, current => 1, snap => 1},
@@ -871,7 +873,7 @@ sub volume_has_feature {
     } else {
 	$key = $isBase ? 'base' : 'current';
     }
-    return 1 if $features->{$feature}->{$key};
+    return $features->{$feature}->{$key} if $features->{$feature}->{$key};
 
     return undef;
 }
-- 
2.39.5



--===============7328846270735007914==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

--===============7328846270735007914==--