add timeout parameter to vm_start api endpoint

Signed-off-by: Tim Marx <t.marx@proxmox.com>
This commit is contained in:
Tim Marx 2020-01-14 14:30:37 +01:00 committed by Thomas Lamprecht
parent 2f18c84dc7
commit ef3f42930f
2 changed files with 12 additions and 5 deletions

View File

@ -1989,7 +1989,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 => {
@ -2003,6 +2009,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');
@ -2056,8 +2063,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;
};

View File

@ -5338,7 +5338,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);
@ -5541,7 +5541,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,