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 'no-write-config' flag to safeguard against accidentally
writing out the temporarily modified config.

Suggested-by: Fabian Grünbichler <f.gruenbich...@proxmox.com>
Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 PVE/QemuServer.pm | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 808c0e1c..837b8916 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3396,6 +3396,7 @@ sub config_to_command {
            scsihw => $conf->{scsihw}, # so that the scsi disks are correctly 
added
            bios => $conf->{bios}, # so efidisk gets included if it exists
            name => $conf->{name}, # so it's correct in the process list
+           'no-write-config' => 1, # make sure to not write this configuration
        };
 
        # copy all disks over
@@ -4017,7 +4018,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 +5614,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 {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to