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 0E79B6C378 for ; Fri, 29 Jan 2021 16:12:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BBB8411243 for ; Fri, 29 Jan 2021 16:11:49 +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 1BFD0111FA 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 CE9214456E for ; Fri, 29 Jan 2021 16:11:46 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 29 Jan 2021 16:11:34 +0100 Message-Id: <20210129151143.10014-5-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 04/13] migration: split out config_update_local_disksizes from scan_local_volumes 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:12:20 -0000 Signed-off-by: Fabian Ebner --- No changes from v1 PVE/QemuMigrate.pm | 55 ++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index d0295f8..455581c 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -587,28 +587,6 @@ sub scan_local_volumes { 'PVE::QemuConfig', $self->{replication_jobcfg}, $start_time, $start_time, $logfunc); } - # sizes in config have to be accurate for remote node to correctly - # allocate disks - PVE::QemuConfig->foreach_volume($conf, sub { - my ($key, $drive) = @_; - return if $key eq 'efidisk0'; # skip efidisk, will be handled later - - my $volid = $drive->{file}; - return if !defined($local_volumes->{$volid}); # only update sizes for local volumes - - my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $local_volumes->{$volid}->{size}); - if (defined($updated)) { - $conf->{$key} = PVE::QemuServer::print_drive($updated); - $self->log('info', "drive '$key': $msg"); - } - }); - - # we want to set the efidisk size in the config to the size of the - # real OVMF_VARS.fd image, else we can create a too big image, which does not work - if (defined($conf->{efidisk0})) { - PVE::QemuServer::update_efidisk_size($conf); - } - foreach my $volid (sort keys %$local_volumes) { my $ref = $local_volumes->{$volid}->{ref}; if ($self->{running} && $ref eq 'config') { @@ -628,6 +606,33 @@ sub scan_local_volumes { die "Problem found while scanning volumes - $@" if $@; } +sub config_update_local_disksizes { + my ($self) = @_; + + my $conf = $self->{vmconf}; + my $local_volumes = $self->{local_volumes}; + + PVE::QemuConfig->foreach_volume($conf, sub { + my ($key, $drive) = @_; + return if $key eq 'efidisk0'; # skip efidisk, will be handled later + + my $volid = $drive->{file}; + return if !defined($local_volumes->{$volid}); # only update sizes for local volumes + + my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $local_volumes->{$volid}->{size}); + if (defined($updated)) { + $conf->{$key} = PVE::QemuServer::print_drive($updated); + $self->log('info', "drive '$key': $msg"); + } + }); + + # we want to set the efidisk size in the config to the size of the + # real OVMF_VARS.fd image, else we can create a too big image, which does not work + if (defined($conf->{efidisk0})) { + PVE::QemuServer::update_efidisk_size($conf); + } +} + sub filter_local_volumes { my ($self, $migration_mode) = @_; @@ -732,9 +737,11 @@ sub phase1 { $conf->{lock} = 'migrate'; PVE::QemuConfig->write_config($vmid, $conf); - # scan_local_volumes fixes disk sizes to match their actual size, write changes so - # target allocates correct volumes $self->scan_local_volumes($vmid); + + # fix disk sizes to match their actual size and write changes, + # so that the target allocates the correct volumes + $self->config_update_local_disksizes(); PVE::QemuConfig->write_config($vmid, $conf); $self->sync_offline_local_volumes(); -- 2.20.1