[pve-devel] [PATCH qemu-server 13/22] vm start: move config_to_command() call further down

Fiona Ebner f.ebner at proxmox.com
Thu Jun 12 16:02:44 CEST 2025


For command line generation of '-blockdev', it will be necessary to
activate the VM's volumes before calling config_to_command() and thus
also deactivate in an error scenario. Avoid the need to put more code
than necessary into the resulting eval.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 PVE/QemuServer.pm | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 25ba709d..dfd4351b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5625,18 +5625,6 @@ sub vm_start_nolock {
 	print "Resuming suspended VM\n";
     }
 
-    # 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;
     if (
 	($statefile && $statefile eq 'tcp' && $migration_type eq 'insecure')
@@ -5654,16 +5642,28 @@ sub vm_start_nolock {
 	($state_cmdline, $res->{migrate}, $statefile_is_a_volume) =
 	    PVE::QemuServer::StateFile::statefile_cmdline_option(
 		$storecfg, $vmid, $statefile, $migrate_opts, $migration_ip);
-	push @$vollist, $statefile if $statefile_is_a_volume;
     } elsif ($params->{paused}) {
 	$state_cmdline = ['-S'];
     }
 
-    push $cmd->@*, $state_cmdline->@*;
-
     my $memory = get_current_memory($conf->{memory});
     my $start_timeout = $params->{timeout} // config_aware_timeout($conf, $memory, $resume);
 
+    # 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'},
+    );
+
+    push $cmd->@*, $state_cmdline->@*;
+    push @$vollist, $statefile if $statefile_is_a_volume;
+
     my $pci_reserve_list = [];
     for my $device (values $pci_devices->%*) {
 	next if $device->{mdev}; # we don't reserve for mdev devices
-- 
2.39.5





More information about the pve-devel mailing list