[pve-devel] [PATCH qemu-server v2 5/8] bwlimit: add parameter for QemuMigrate::phase2

Stoiko Ivanov s.ivanov at proxmox.com
Mon Apr 1 11:31:02 CEST 2019


used for online local disks via qemu_drive_mirror

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PVE/QemuMigrate.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 55c9a7c..4b5813c 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -661,6 +661,8 @@ sub phase2 {
 
     my $start = time();
 
+    my $opt_bwlimit = $self->{opts}->{bwlimit};
+
     if (defined($self->{online_local_volumes})) {
 	$self->{storage_migration} = 1;
 	$self->{storage_migration_jobs} = {};
@@ -669,9 +671,14 @@ sub phase2 {
 	die "The number of local disks does not match between the source and the destination.\n"
 	    if (scalar(keys %{$self->{target_drive}}) != scalar @{$self->{online_local_volumes}});
 	foreach my $drive (keys %{$self->{target_drive}}){
-	    my $nbd_uri = $self->{target_drive}->{$drive}->{nbd_uri};
+	    my $target = $self->{target_drive}->{$drive};
+	    my $nbd_uri = $target->{nbd_uri};
+	    my $source_sid = PVE::Storage::Plugin::parse_volume_id($conf->{$drive});
+	    my $target_sid = PVE::Storage::Plugin::parse_volume_id($target->{volid});
+	    my $bwlimit = PVE::Storage::get_bandwidth_limit('migrate', [$source_sid, $target_sid], $opt_bwlimit);
+
 	    $self->log('info', "$drive: start migration to $nbd_uri");
-	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1);
+	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1, undef, $bwlimit);
 	}
     }
 
-- 
2.11.0





More information about the pve-devel mailing list