[pve-devel] [PATCH v2 storage 1/4] volume_has_feature: be aware that qcow2 does not work for lxc

Fabian Ebner f.ebner at proxmox.com
Thu Mar 19 13:37:33 CET 2020


Relevant for the 'clone' feature, because Plugin.pm's clone_image
always produces qcow2. Also fixed style for neighboring if/else block.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

Previous discussion: https://pve.proxmox.com/pipermail/pve-devel/2020-March/042472.html

Changes from v1:
    * As Fabian G. pointed out, templates are not impossible
      on directory based storages, but linked cloning (currently)
      is. So fix the storage backend and get rid of the wrong checks.

This solution doesn't need an API change. It does need
PVE::Cluster which is used by list_images already.

 PVE/Storage/Plugin.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 2232261..8baa410 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -844,13 +844,19 @@ sub volume_has_feature {
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
 	$class->parse_volname($volname);
 
+    my $vmlist = PVE::Cluster::get_vmlist();
+    my $vminfo = $vmlist->{ids}->{$vmid};
+
     my $key = undef;
-    if($snapname){
-        $key = 'snap';
-    }else{
-        $key =  $isBase ? 'base' : 'current';
+    if ($snapname) {
+	$key = 'snap';
+    } else {
+	$key = $isBase ? 'base' : 'current';
     }
 
+    # clone_images produces a qcow2 image
+    return 0 if defined($vminfo) && $vminfo->{type} eq 'lxc' && $feature eq 'clone';
+
     return 1 if defined($features->{$feature}->{$key}->{$format});
 
     return undef;
-- 
2.20.1





More information about the pve-devel mailing list