[pve-devel] [PATCH container 3/3] migrate: enforce that rootdir content type is available

Fabian Ebner f.ebner at proxmox.com
Fri Jun 18 12:59:32 CEST 2021


and use it for the vdisk_list call too. This avoids scanning (and picking up
volumes from!) storages that are not even configured to hold container images.

Also serves a bit as a preparation to enforce content type on guest startup,
because now migration failure happens early and not only when trying to start
the guest on the remote node.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/LXC/Migrate.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index 1e5cb1e..3cd895d 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -66,6 +66,8 @@ sub prepare {
 	my $scfg = PVE::Storage::storage_check_enabled($self->{storecfg}, $storage);
 	PVE::Storage::storage_check_enabled($self->{storecfg}, $storage, $self->{node});
 
+	die "content type 'rootdir' is not available on storage '$storage'\n"
+	    if !$scfg->{content}->{rootdir};
 
 	if ($scfg->{shared}) {
 	    # PVE::Storage::activate_storage checks this for non-shared storages
@@ -187,13 +189,16 @@ sub phase1 {
 	next if !PVE::Storage::storage_check_enabled($self->{storecfg}, $storeid, undef, 1);
 
 	# get list from PVE::Storage (for unreferenced volumes)
-	my $dl = PVE::Storage::vdisk_list($self->{storecfg}, $storeid, $vmid);
+	my $dl = PVE::Storage::vdisk_list($self->{storecfg}, $storeid, $vmid, undef, 'rootdir');
 
 	next if @{$dl->{$storeid}} == 0;
 
 	# check if storage is available on target node
 	PVE::Storage::storage_check_enabled($self->{storecfg}, $storeid, $self->{node});
 
+	die "content type 'rootdir' is not available on storage '$storeid'\n"
+	    if !$scfg->{content}->{rootdir};
+
 	PVE::Storage::foreach_volid($dl, sub {
 	    my ($volid, $sid, $volname) = @_;
 
-- 
2.30.2






More information about the pve-devel mailing list