[pve-devel] [PATCH qemu-server 7/7] bwlimit: add parameter to API2 calls

Stoiko Ivanov s.ivanov at proxmox.com
Fri Mar 29 08:28:06 CET 2019


for migrate_vm, clone_vm and move_vm_disk

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

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 99e37d8..eb31a54 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2649,6 +2649,12 @@ __PACKAGE__->register_method({
 		description => "Target node. Only allowed if the original VM is on shared storage.",
 		optional => 1,
 	    }),
+	    bwlimit => {
+		description => "Override i/o bandwidth limit (in KiB/s).",
+		optional => 1,
+		type => 'integer',
+		minimum => '0',
+	    },
         },
     },
     returns => {
@@ -2834,16 +2840,20 @@ __PACKAGE__->register_method({
 
 		    PVE::Storage::activate_volumes($storecfg, $vollist, $snapname);
 
+		    my $bwlimit = extract_param($param, 'bwlimit');
+
 		    my $total_jobs = scalar(keys %{$drives});
 		    my $i = 1;
 
 		    foreach my $opt (keys %$drives) {
 			my $drive = $drives->{$opt};
+			my $src_sid = PVE::Storage::parse_volume_id($drive->{file});
 			my $skipcomplete = ($total_jobs != $i); # finish after last drive
 
+			my $clonelimit = PVE::Storage::get_bandwidth_limit('clone', [$src_sid, $storage], $bwlimit);
 			my $newdrive = PVE::QemuServer::clone_disk($storecfg, $vmid, $running, $opt, $drive, $snapname,
 								   $newid, $storage, $format, $fullclone->{$opt}, $newvollist,
-								   $jobs, $skipcomplete, $oldconf->{agent});
+								   $jobs, $skipcomplete, $oldconf->{agent}, $clonelimit);
 
 			$newconf->{$opt} = PVE::QemuServer::print_drive($vmid, $newdrive);
 
@@ -2949,6 +2959,12 @@ __PACKAGE__->register_method({
 		maxLength => 40,
 		optional => 1,
 	    },
+	    bwlimit => {
+		description => "Override i/o bandwidth limit (in KiB/s).",
+		optional => 1,
+		type => 'integer',
+		minimum => '0',
+	    },
 	},
     },
     returns => {
@@ -3026,8 +3042,10 @@ __PACKAGE__->register_method({
 		    warn "moving disk with snapshots, snapshots will not be moved!\n"
 			if $snapshotted;
 
+		    my $bwlimit = extract_param($param, 'bwlimit');
+		    my $movelimit = PVE::Storage::get_bandwidth_limit('move', [$oldstoreid, $storeid], $bwlimit);
 		    my $newdrive = PVE::QemuServer::clone_disk($storecfg, $vmid, $running, $disk, $drive, undef,
-							       $vmid, $storeid, $format, 1, $newvollist);
+							       $vmid, $storeid, $format, 1, $newvollist, undef, undef, undef, $movelimit);
 
 		    $conf->{$disk} = PVE::QemuServer::print_drive($vmid, $newdrive);
 
@@ -3124,6 +3142,12 @@ __PACKAGE__->register_method({
 		optional => 1,
 		completion => \&PVE::QemuServer::complete_storage,
             }),
+	    bwlimit => {
+		description => "Override i/o bandwidth limit (in KiB/s).",
+		optional => 1,
+		type => 'integer',
+		minimum => '0',
+	    },
 	},
     },
     returns => {
-- 
2.11.0




More information about the pve-devel mailing list