[pve-devel] [PATCH v3 container 2/5] For clone+copy features, make sure a valid format for the target is supported

Fabian Ebner f.ebner at proxmox.com
Mon Mar 23 12:18:51 CET 2020


using the new option valid_target_formats. This is
necessary, because clone_image can result in a qcow2 image
being created (on directory based storages) which is not
valid for LXC.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/API2/LXC.pm   | 2 +-
 src/PVE/LXC/Config.pm | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index a5aa5fc..ddf417b 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1440,7 +1440,7 @@ __PACKAGE__->register_method({
 			    } else {
 				# not full means clone instead of copy
 				die "Linked clone feature for '$volid' is not available\n"
-				    if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, $running);
+				    if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, $running, {'valid_target_formats' => ['raw', 'subvol']});
 			    }
 
 			    $mountpoints->{$opt} = $mp;
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index e88ba0b..ea5b689 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -62,6 +62,11 @@ sub has_feature {
     my ($class, $feature, $conf, $storecfg, $snapname, $running, $backup_only) = @_;
     my $err;
 
+    my $opts;
+    if ($feature eq 'copy' || $feature eq 'clone') {
+	$opts = {'valid_target_formats' => ['raw', 'subvol']};
+    }
+
     $class->foreach_mountpoint($conf, sub {
 	my ($ms, $mountpoint) = @_;
 
@@ -71,7 +76,7 @@ sub has_feature {
 	$err = 1
 	    if !PVE::Storage::volume_has_feature($storecfg, $feature,
 						 $mountpoint->{volume},
-						 $snapname, $running);
+						 $snapname, $running, $opts);
     });
 
     return $err ? 0 : 1;
-- 
2.20.1





More information about the pve-devel mailing list