]> git.proxmox.com Git - qemu-server.git/commitdiff
bwlimit: add parameter for QemuMigrate::phase2
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 1 Apr 2019 09:31:02 +0000 (11:31 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 2 Apr 2019 09:00:28 +0000 (11:00 +0200)
used for online local disks via qemu_drive_mirror

Add TODO comment for offline disks, as clone_disk calls `qemu-img
convert`, which does not have a bandwidth limit parameter.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
PVE/QemuMigrate.pm
PVE/QemuServer.pm

index 55c9a7c652df61833951f0612815be111a3efe47..4b5813c3c678b995c7bab5e22cb67e4971763400 100644 (file)
@@ -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);
        }
     }
 
index f9b0f58cd0cc36a489e581fc37ec4c4b90fd58ec..ba14579977e6fbb76a8dcac2e331fbba8786bf5b 100644 (file)
@@ -6940,6 +6940,7 @@ sub clone_disk {
 
        my $sparseinit = PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $newvolid);
        if (!$running || $snapname) {
+           # TODO: handle bwlimits
            qemu_img_convert($drive->{file}, $newvolid, $size, $snapname, $sparseinit);
        } else {