[pve-devel] [PATCH qemu-server 1/4] cleanup: whitespaces & style

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jan 5 10:09:26 CET 2017


---
 PVE/API2/Qemu.pm   |  7 +++----
 PVE/QemuMigrate.pm | 16 ++++++++--------
 PVE/QemuServer.pm  | 12 ++----------
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 0bae424..e48bf6d 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2464,15 +2464,14 @@ __PACKAGE__->register_method({
 
 		    my $total_jobs = scalar(keys %{$drives});
 		    my $i = 1;
-		    my $skipcomplete = 1;
 
 		    foreach my $opt (keys %$drives) {
-
 			my $drive = $drives->{$opt};
-			$skipcomplete = undef if $total_jobs == $i; #finish after last drive
+			my $skipcomplete = ($total_jobs != $i); # finish after last drive
 
 			my $newdrive = PVE::QemuServer::clone_disk($storecfg, $vmid, $running, $opt, $drive, $snapname,
-								   $newid, $storage, $format, $fullclone->{$opt}, $newvollist, $jobs, $skipcomplete, $oldconf->{agent});
+								   $newid, $storage, $format, $fullclone->{$opt}, $newvollist,
+								   $jobs, $skipcomplete, $oldconf->{agent});
 
 			$newconf->{$opt} = PVE::QemuServer::print_drive($vmid, $newdrive);
 
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index e099a42..ed1bef6 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -596,10 +596,12 @@ sub phase2 {
 	$self->{storage_migration_jobs} = {};
 	$self->log('info', "starting storage migration");
 
-	die "the number of destination local disk is not equal to number of source local disk" if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
+	die "the number of destination local disk is not equal to number of source local disk"
+	    if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
 	foreach my $drive (keys %{$self->{target_drive}}){
-	    $self->log('info', "$drive: start migration to to $self->{target_drive}->{$drive}->{nbd_uri}");
-	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $self->{target_drive}->{$drive}->{nbd_uri}, $vmid, undef, $self->{storage_migration_jobs}, 1);
+	    my $nbd_uri = $self->{target_drive}->{$drive}->{nbd_uri};
+	    $self->log('info', "$drive: start migration to to $nbd_uri");
+	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1);
 	}
     }
 
@@ -802,7 +804,7 @@ sub phase2_cleanup {
     }
 
     # cleanup ressources on target host
-    if ( $self->{storage_migration} ) {
+    if ($self->{storage_migration}) {
 
 	eval { PVE::QemuServer::qemu_blockjobs_cancel($vmid, $self->{storage_migration_jobs}) };
 	if (my $err = $@) {
@@ -857,15 +859,14 @@ sub phase3_cleanup {
     return if $self->{phase2errors};
 
     if ($self->{storage_migration}) {
-
-	eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); }; #finish block-job
+	# finish block-job
+	eval { PVE::QemuServer::qemu_drive_mirror_monitor($vmid, undef, $self->{storage_migration_jobs}); };
 
 	if (my $err = $@) {
 	    eval { PVE::QemuServer::qemu_blockjobs_cancel($vmid, $self->{storage_migration_jobs}) };
 	    eval { PVE::QemuMigrate::cleanup_remotedisks($self) };
 	    die "Failed to completed storage migration\n";
 	} else {
-
 	    foreach my $target_drive (keys %{$self->{target_drive}}) {
 		my $drive = PVE::QemuServer::parse_drive($target_drive, $self->{target_drive}->{$target_drive}->{volid});
 		$conf->{$target_drive} = PVE::QemuServer::print_drive($vmid, $drive);
@@ -897,7 +898,6 @@ sub phase3_cleanup {
     }
 
     eval {
-
 	my $timer = 0;
 	if (PVE::QemuServer::vga_conf_has_spice($conf->{vga}) && $self->{running}) {
 	    $self->log('info', "Waiting for spice server migration");
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 6d8943c..0b866cd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4472,8 +4472,7 @@ sub vm_start {
 
 	my $local_volumes = {};
 
-	if( $targetstorage ){
-
+	if ($targetstorage) {
 	    foreach_drive($conf, sub {
 		my ($ds, $drive) = @_;
 
@@ -4658,7 +4657,6 @@ sub vm_start {
 
 	#start nbd server for storage migration
 	if ($targetstorage) {
-
 	    my $nodename = PVE::INotify::nodename();
 	    my $migrate_network_addr = PVE::Cluster::get_local_migration_ip($migration_network);
 	    my $localip = $migrate_network_addr ? $migrate_network_addr : PVE::Cluster::remote_node_ip($nodename, 1);
@@ -4678,7 +4676,6 @@ sub vm_start {
 	}
 
 	if ($migratedfrom) {
-
 	    eval {
 		set_migration_caps($vmid);
 	    };
@@ -4693,7 +4690,6 @@ sub vm_start {
 	    }
 
 	} else {
-
 	    if (!$statefile && (!defined($conf->{balloon}) || $conf->{balloon})) {
 		vm_mon_cmd_nocheck($vmid, "balloon", value => $conf->{balloon}*1024*1024)
 		    if $conf->{balloon};
@@ -5915,7 +5911,7 @@ sub qemu_drive_mirror {
     my $format;
     $jobs->{"drive-$drive"} = {};
 
-    if($dst_volid =~ /^nbd:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+):exportname=(\S+)/) {
+    if ($dst_volid =~ /^nbd:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+):exportname=(\S+)/) {
 	my $server = $1;
 	my $port = $2;
 	my $exportname = $3;
@@ -5932,7 +5928,6 @@ sub qemu_drive_mirror {
 	    exec(@$cmd);
 	    exit(-1);
 	} else {
-
 	    $jobs->{"drive-$drive"}->{pid} = $pid;
 
 	    my $timeout = 0;
@@ -5944,7 +5939,6 @@ sub qemu_drive_mirror {
 	    }
 	}
     } else {
-
 	my $storecfg = PVE::Storage::config();
 	my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid);
 
@@ -5969,7 +5963,6 @@ sub qemu_drive_mirror {
 	die "mirroring error: $err";
     }
 
-
     qemu_drive_mirror_monitor ($vmid, $vmiddst, $jobs, $skipcomplete, $qga);
 }
 
@@ -5977,7 +5970,6 @@ sub qemu_drive_mirror_monitor {
     my ($vmid, $vmiddst, $jobs, $skipcomplete, $qga) = @_;
 
     eval {
-
 	my $err_complete = 0;
 
 	while (1) {
-- 
2.1.4





More information about the pve-devel mailing list