]> git.proxmox.com Git - qemu-server.git/commitdiff
add new helper to calculate timeout based on vm config
authorTim Marx <t.marx@proxmox.com>
Tue, 14 Jan 2020 13:30:36 +0000 (14:30 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Jan 2020 16:36:16 +0000 (17:36 +0100)
Signed-off-by: Tim Marx <t.marx@proxmox.com>
PVE/QemuServer.pm
PVE/QemuServer/Helpers.pm

index 5835e9af9e74a9e080502f8ec7f4c9e150b5ea42..0f8fe96a45d45a084910cf3cf0ffd77d3b5174fd 100644 (file)
@@ -41,7 +41,7 @@ use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline file_
 
 use PVE::QMPClient;
 use PVE::QemuConfig;
-use PVE::QemuServer::Helpers qw(min_version);
+use PVE::QemuServer::Helpers qw(min_version config_aware_timeout);
 use PVE::QemuServer::Cloudinit;
 use PVE::QemuServer::Machine;
 use PVE::QemuServer::Memory;
@@ -5541,7 +5541,7 @@ sub vm_start {
        my $cpuunits = defined($conf->{cpuunits}) ? $conf->{cpuunits}
                                                  : $defaults->{cpuunits};
 
-       my $start_timeout = ($conf->{hugepages} || $is_suspended) ? 300 : 30;
+       my $start_timeout = config_aware_timeout($conf, $is_suspended);
        my %run_params = (
            timeout => $statefile ? undef : $start_timeout,
            umask => 0077,
index fcc939228339987b90f19511c38eb7b4fc122679..68325b78c7ac760d0d30b4b63a3c6a9c72d5abb2 100644 (file)
@@ -11,6 +11,7 @@ use PVE::ProcFSTools;
 use base 'Exporter';
 our @EXPORT_OK = qw(
 min_version
+config_aware_timeout
 );
 
 my $nodename = PVE::INotify::nodename();
@@ -139,4 +140,25 @@ sub version_cmp {
     return 0;
 }
 
+sub config_aware_timeout {
+    my ($config, $is_suspended) = @_;
+    my $memory = $config->{memory};
+    my $timeout = 30;
+
+    # Based on user reported startup time for vm with 512GiB @ 4-5 minutes
+    if (defined($memory) && $memory > 30720) {
+       $timeout = int($memory/1024);
+    }
+
+    if ($is_suspended && $timeout < 300) {
+       $timeout = 300;
+    }
+
+    if ($config->{hugepages} && $timeout < 150) {
+       $timeout = 150;
+    }
+
+    return $timeout;
+}
+
 1;