[pve-devel] [PATCH] migrate: syncdisk : avoid scanning shared storage

Alexandre Derumier aderumier at odiso.com
Fri Jul 13 15:12:41 CEST 2012


Currently we get list from PVE::Storage (for unused volumes), from all storage.
If something goes wrong with the network on host and thenwe can't communicate with a network shared storage(sheepdog,rbd,..),
the vdisk_list die (timeout) and we cannot migrate the vm on another kvm host.(online or offline).

We don't need to scan shared storage, as they are no disk to sync.

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index b0059c3..f5e7c1b 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -177,19 +177,21 @@ sub sync_disks {
 	my $volhash = {};
 	my $cdromhash = {};
 
-	# get list from PVE::Storage (for unused volumes)
-	my $dl = PVE::Storage::vdisk_list($self->{storecfg}, undef, $vmid);
-	PVE::Storage::foreach_volid($dl, sub {
-	    my ($volid, $sid, $volname) = @_;
-
-	    # check if storage is available on both nodes
-	    my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $sid);
-	    PVE::Storage::storage_check_node($self->{storecfg}, $sid, $self->{node});
-
-	    return if $scfg->{shared};
-
-	    $volhash->{$volid} = 1;
-	});
+        my $ids = $self->{storecfg}->{ids};
+        foreach my $storeid (keys %$ids) {
+            next if $ids->{$storeid}->{shared};
+            # get list from PVE::Storage (for unused volumes)
+            my $dl = PVE::Storage::vdisk_list($self->{storecfg}, $storeid, $vmid);
+            PVE::Storage::foreach_volid($dl, sub {
+                my ($volid, $sid, $volname) = @_;
+
+                # check if storage is available on both nodes
+                my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $sid);
+                PVE::Storage::storage_check_node($self->{storecfg}, $sid, $self->{node});
+
+                $volhash->{$volid} = 1;
+            });
+        }
 
 	# and add used,owned/non-shared disks (just to be sure we have all)
 
-- 
1.7.2.5




More information about the pve-devel mailing list