[pve-devel] [PATCH] live storage migration : fix check of target storage availability

Alexandre Derumier aderumier at odiso.com
Fri Apr 21 03:39:34 CEST 2017


if we define a different target storeid for remote node,
and that storage is not available on source node

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm   | 7 ++++++-
 PVE/QemuMigrate.pm | 6 ++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 24a5b67..19ba5be 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2820,7 +2820,12 @@ __PACKAGE__->register_method({
 	}
 
 	my $storecfg = PVE::Storage::config();
-	PVE::QemuServer::check_storage_availability($storecfg, $conf, $target);
+
+	if( $param->{targetstorage}) {
+	    PVE::Storage::storage_check_node($storecfg, $param->{targetstorage}, $target);
+        } else {
+	    PVE::QemuServer::check_storage_availability($storecfg, $conf, $target);
+	}
 
 	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
 
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 68ec69f..5caac15 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -255,8 +255,10 @@ sub sync_disks {
 
 	    next if @{$dl->{$storeid}} == 0;
 
+	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $storeid;
+
 	    # check if storage is available on target node
-	    PVE::Storage::storage_check_node($self->{storecfg}, $storeid, $self->{node});
+	    PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node});
 	    $sharedvm = 0; # there is a non-shared disk
 
 	    PVE::Storage::foreach_volid($dl, sub {
@@ -293,7 +295,7 @@ sub sync_disks {
 	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $sid;
 	    # 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});
+	    PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node});
 
 	    return if $scfg->{shared};
 
-- 
2.11.0




More information about the pve-devel mailing list