migration: split out config_update_local_disksizes from scan_local_volumes

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2021-01-29 16:11:34 +01:00 committed by Thomas Lamprecht
parent 62a4c963b8
commit 3276a43470

View File

@ -587,8 +587,31 @@ sub scan_local_volumes {
'PVE::QemuConfig', $self->{replication_jobcfg}, $start_time, $start_time, $logfunc); 'PVE::QemuConfig', $self->{replication_jobcfg}, $start_time, $start_time, $logfunc);
} }
# sizes in config have to be accurate for remote node to correctly foreach my $volid (sort keys %$local_volumes) {
# allocate disks my $ref = $local_volumes->{$volid}->{ref};
if ($self->{running} && $ref eq 'config') {
push @{$self->{online_local_volumes}}, $volid;
} elsif ($ref eq 'generated') {
die "can't live migrate VM with local cloudinit disk. use a shared storage instead\n" if $self->{running};
# skip all generated volumes but queue them for deletion in phase3_cleanup
push @{$self->{volumes}}, $volid;
next;
} else {
next if $self->{replicated_volumes}->{$volid};
push @{$self->{volumes}}, $volid;
$local_volumes->{$volid}->{migration_mode} = 'offline';
}
}
};
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 { PVE::QemuConfig->foreach_volume($conf, sub {
my ($key, $drive) = @_; my ($key, $drive) = @_;
return if $key eq 'efidisk0'; # skip efidisk, will be handled later return if $key eq 'efidisk0'; # skip efidisk, will be handled later
@ -608,24 +631,6 @@ sub scan_local_volumes {
if (defined($conf->{efidisk0})) { if (defined($conf->{efidisk0})) {
PVE::QemuServer::update_efidisk_size($conf); 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') {
push @{$self->{online_local_volumes}}, $volid;
} elsif ($ref eq 'generated') {
die "can't live migrate VM with local cloudinit disk. use a shared storage instead\n" if $self->{running};
# skip all generated volumes but queue them for deletion in phase3_cleanup
push @{$self->{volumes}}, $volid;
next;
} else {
next if $self->{replicated_volumes}->{$volid};
push @{$self->{volumes}}, $volid;
$local_volumes->{$volid}->{migration_mode} = 'offline';
}
}
};
die "Problem found while scanning volumes - $@" if $@;
} }
sub filter_local_volumes { sub filter_local_volumes {
@ -732,9 +737,11 @@ sub phase1 {
$conf->{lock} = 'migrate'; $conf->{lock} = 'migrate';
PVE::QemuConfig->write_config($vmid, $conf); 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); $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); PVE::QemuConfig->write_config($vmid, $conf);
$self->sync_offline_local_volumes(); $self->sync_offline_local_volumes();