From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 51EC56C2FA for ; Fri, 29 Jan 2021 16:11:52 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1635C11285 for ; Fri, 29 Jan 2021 16:11:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id BE9CE1120B for ; Fri, 29 Jan 2021 16:11:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 86E8543A86 for ; Fri, 29 Jan 2021 16:11:47 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 29 Jan 2021 16:11:36 +0100 Message-Id: <20210129151143.10014-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210129151143.10014-1-f.ebner@proxmox.com> References: <20210129151143.10014-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemumigrate.pm] Subject: [pve-devel] [PATCH v2 qemu-server 06/13] migration: save targetstorage and bwlimit in local_volumes hash and re-use information X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2021 15:11:52 -0000 It is enough to call get_bandwith_limit once for each source_storage. Signed-off-by: Fabian Ebner --- Changes from v1: * avoid a long line PVE/QemuMigrate.pm | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 0522208..db68371 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -411,11 +411,19 @@ sub scan_local_volumes { if !$target_scfg->{content}->{images}; } + my $bwlimit = PVE::Storage::get_bandwidth_limit( + 'migration', + [$targetsid, $storeid], + $self->{opts}->{bwlimit}, + ); + PVE::Storage::foreach_volid($dl, sub { my ($volid, $sid, $volinfo) = @_; $local_volumes->{$volid}->{ref} = 'storage'; $local_volumes->{$volid}->{size} = $volinfo->{size}; + $local_volumes->{$volid}->{targetsid} = $targetsid; + $local_volumes->{$volid}->{bwlimit} = $bwlimit; # If with_snapshots is not set for storage migrate, it tries to use # a raw+size stream, but on-the-fly conversion from qcow2 to raw+size @@ -659,12 +667,9 @@ sub sync_offline_local_volumes { $self->log('info', "copying local disk images") if scalar(@volids); foreach my $volid (@volids) { - my ($sid, $volname) = PVE::Storage::parse_volume_id($volid); - my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid); - # use 'migration' limit for transfer to other node - my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', [$targetsid, $sid], $opts->{bwlimit}); - # JSONSchema and get_bandwidth_limit use kbps - storage_migrate bps - $bwlimit = $bwlimit * 1024 if defined($bwlimit); + my $targetsid = $local_volumes->{$volid}->{targetsid}; + my $bwlimit = $local_volumes->{$volid}->{bwlimit}; + $bwlimit = $bwlimit * 1024 if defined($bwlimit); # storage_migrate uses bps my $storage_migrate_opts = { 'ratelimit_bps' => $bwlimit, @@ -777,6 +782,7 @@ sub phase2 { my ($self, $vmid) = @_; my $conf = $self->{vmconf}; + my $local_volumes = $self->{local_volumes}; $self->log('info', "starting VM $vmid on remote node '$self->{node}'"); @@ -911,8 +917,6 @@ 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} = {}; @@ -930,10 +934,7 @@ sub phase2 { my $source_volid = $source_drive->{file}; my $target_volid = $target_drive->{file}; - my $source_sid = PVE::Storage::Plugin::parse_volume_id($source_volid); - my $target_sid = PVE::Storage::Plugin::parse_volume_id($target_volid); - - my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', [$source_sid, $target_sid], $opt_bwlimit); + my $bwlimit = $local_volumes->{$source_volid}->{bwlimit}; my $bitmap = $target->{bitmap}; $self->log('info', "$drive: start migration to $nbd_uri"); @@ -960,7 +961,7 @@ sub phase2 { # migrate speed can be set via bwlimit (datacenter.cfg and API) and via the # migrate_speed parameter in qm.conf - take the lower of the two. - my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', undef, $opt_bwlimit) // 0; + my $bwlimit = PVE::Storage::get_bandwidth_limit('migration', undef, $self->{opts}->{bwlimit}) // 0; my $migrate_speed = $conf->{migrate_speed} // 0; # migrate_speed is in MB/s, bwlimit in KB/s $migrate_speed *= 1024; -- 2.20.1