[pve-devel] [PATCH v4 qemu-server 3/3] cleanup: use a local $override_targetsid variable

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Dec 20 09:55:12 CET 2018


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
New in v4:
  Using '//' for definedness instead of '||' or a ternary since we don't
  store the literal '1' in it anymore.

 PVE/QemuMigrate.pm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index b12034f..d142d29 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -234,7 +234,7 @@ sub prepare {
 	my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
 
 	# check if storage is available on both nodes
-	my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $sid;
+	my $targetsid = $self->{opts}->{targetstorage} // $sid;
 
 	my $scfg = PVE::Storage::storage_check_node($self->{storecfg}, $sid);
 	PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node});
@@ -269,6 +269,8 @@ sub sync_disks {
     # local volumes which have been copied
     $self->{volumes} = [];
 
+    my $override_targetsid = $self->{opts}->{targetstorage};
+
     eval {
 
 	# found local volumes and their origin
@@ -301,7 +303,7 @@ sub sync_disks {
 
 	    next if @{$dl->{$storeid}} == 0;
 
-	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $storeid;
+	    my $targetsid = $override_targetsid // $storeid;
 
 	    # check if storage is available on target node
 	    PVE::Storage::storage_check_node($self->{storecfg}, $targetsid, $self->{node});
@@ -340,7 +342,7 @@ sub sync_disks {
 
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 
-	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $sid;
+	    my $targetsid = $override_targetsid // $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}, $targetsid, $self->{node});
@@ -442,7 +444,7 @@ sub sync_disks {
 
 	foreach my $volid (keys %$local_volumes) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
-	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $sid;
+	    my $targetsid = $override_targetsid // $sid;
 	    if ($self->{running} && $local_volumes->{$volid}->{ref} eq 'config') {
 		push @{$self->{online_local_volumes}}, $volid;
 	    } else {
-- 
2.11.0





More information about the pve-devel mailing list