fix #6007: template backup: use minimized configuration for handling the full vm start

Previously, the template's configuration was used as-is for the rest
of handling the VM start even if config_to_command() uses a minimized
configuration to build the command. This can lead to issues with a
network device with the 'link_down' flag set, because the network
device will not be present, but the start handling will still issue a
QMP command for it, leading to a failed backup operation.

Use the minimized configuration for the whole start-up handling to
avoid such issues.

Use the special QemuConfig::NoWrite class to safeguard against
accidentally writing out the temporarily modified config.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2025-02-12 12:04:27 +01:00 committed by Fabian Grünbichler
parent 1afbefb2d0
commit a52f3dd3b0

View File

@ -49,6 +49,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for
use PVE::QMPClient;
use PVE::QemuConfig;
use PVE::QemuConfig::NoWrite;
use PVE::QemuServer::Helpers qw(config_aware_timeout min_version kvm_user_version windows_version);
use PVE::QemuServer::Cloudinit;
use PVE::QemuServer::CGroup;
@ -3397,6 +3398,7 @@ sub config_to_command {
bios => $conf->{bios}, # so efidisk gets included if it exists
name => $conf->{name}, # so it's correct in the process list
};
$newconf = PVE::QemuConfig::NoWrite->new($newconf);
# copy all disks over
for my $device (PVE::QemuServer::Drive::valid_drive_names()) {
@ -4017,7 +4019,7 @@ sub config_to_command {
push @$cmd, @$aa;
}
return wantarray ? ($cmd, $vollist, $spice_port, $pci_devices) : $cmd;
return wantarray ? ($cmd, $vollist, $spice_port, $pci_devices, $conf) : $cmd;
}
sub check_rng_source {
@ -5613,8 +5615,17 @@ sub vm_start_nolock {
print "Resuming suspended VM\n";
}
my ($cmd, $vollist, $spice_port, $pci_devices) = config_to_command($storecfg, $vmid,
$conf, $defaults, $forcemachine, $forcecpu, $params->{'live-restore-backing'});
# Note that for certain cases like templates, the configuration is minimized, so need to ensure
# the rest of the function here uses the same configuration that was used to build the command
(my $cmd, my $vollist, my $spice_port, my $pci_devices, $conf) = config_to_command(
$storecfg,
$vmid,
$conf,
$defaults,
$forcemachine,
$forcecpu,
$params->{'live-restore-backing'},
);
my $migration_ip;
my $get_migration_ip = sub {