[pve-devel] [PATCH v2 qemu-server 2/2] add timeout parameter to vm_start api endpoint

Tim Marx t.marx at proxmox.com
Tue Jan 14 14:30:37 CET 2020


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
changes:
* squashed patch 2 & 4

 PVE/API2/Qemu.pm  | 13 ++++++++++---
 PVE/QemuServer.pm |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 5bae513..2dee3f1 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1993,7 +1993,13 @@ __PACKAGE__->register_method({
 		description => "Target storage for the migration. (Can be '1' to use the same storage id as on the source node.)",
 		type => 'string',
 		optional => 1
-	    }
+	    },
+	    timeout => {
+		description => "Wait maximal timeout seconds.",
+		type => 'integer',
+		minimum => 0,
+		optional => 1,
+	    },
 	},
     },
     returns => {
@@ -2007,6 +2013,7 @@ __PACKAGE__->register_method({

 	my $node = extract_param($param, 'node');
 	my $vmid = extract_param($param, 'vmid');
+	my $timeout = extract_param($param, 'timeout');

 	my $machine = extract_param($param, 'machine');

@@ -2060,8 +2067,8 @@ __PACKAGE__->register_method({

 		syslog('info', "start VM $vmid: $upid\n");

-		PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom, undef,
-					  $machine, $spice_ticket, $migration_network, $migration_type, $targetstorage);
+		PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom, undef, $machine,
+					  $spice_ticket, $migration_network, $migration_type, $targetstorage, $timeout);
 		return;
 	    };

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index e51ca62..822be6d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5196,7 +5196,7 @@ sub vmconfig_update_disk {

 sub vm_start {
     my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused,
-	$forcemachine, $spice_ticket, $migration_network, $migration_type, $targetstorage) = @_;
+	$forcemachine, $spice_ticket, $migration_network, $migration_type, $targetstorage, $timeout) = @_;

     PVE::QemuConfig->lock_config($vmid, sub {
 	my $conf = PVE::QemuConfig->load_config($vmid, $migratedfrom);
@@ -5399,7 +5399,7 @@ sub vm_start {
 	my $cpuunits = defined($conf->{cpuunits}) ? $conf->{cpuunits}
 	                                          : $defaults->{cpuunits};

-	my $start_timeout = config_aware_timeout($conf, $is_suspended);
+	my $start_timeout = $timeout // config_aware_timeout($conf, $is_suspended);
 	my %run_params = (
 	    timeout => $statefile ? undef : $start_timeout,
 	    umask => 0077,
--
2.20.1




More information about the pve-devel mailing list