[pve-devel] [PATCH v5 guest-common 1/3] migrate: add get_bwlimit helper
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Feb 9 14:07:34 CET 2022
given a source and target storage query either locally or both locally
and remotely and merge the result.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Notes:
new in v5, replaces merge_bwlimits previously in PVE::QemuMigrate
src/PVE/AbstractMigrate.pm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/PVE/AbstractMigrate.pm b/src/PVE/AbstractMigrate.pm
index a20b213..d90e5b7 100644
--- a/src/PVE/AbstractMigrate.pm
+++ b/src/PVE/AbstractMigrate.pm
@@ -342,4 +342,30 @@ sub switch_replication_job_target {
}
}
+# merges local limit '$bwlimit' and a possible remote limit
+sub get_bwlimit {
+ my ($self, $source, $target) = @_;
+
+ my $local_sids = $self->{opts}->{remote} ? [$source] : [$source, $target];
+
+ my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', $local_sids, $self->{opts}->{bwlimit});
+
+ if ($self->{opts}->{remote}) {
+ my $bwlimit_opts = {
+ operation => 'migration',
+ storages => [$target],
+ bwlimit => $self->{opts}->{bwlimit},
+ };
+ my $remote_bwlimit = PVE::Tunnel::write_tunnel($self->{tunnel}, 10, 'bwlimit', $bwlimit_opts);
+ if ($remote_bwlimit && $remote_bwlimit->{bwlimit}) {
+ $remote_bwlimit = $remote_bwlimit->{bwlimit};
+
+ $bwlimit = $remote_bwlimit
+ if (!$bwlimit || $bwlimit > $remote_bwlimit);
+ }
+ }
+
+ return $bwlimit;
+}
+
1;
--
2.30.2
More information about the pve-devel
mailing list