[pve-devel] [PATCH v2 qemu-server 1/2] add new helper to calculate timeout based on vm config

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


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
changed:
* squashed patch 1 & 3
* pass config hash
* adapated comment

 PVE/QemuServer.pm         |  4 ++--
 PVE/QemuServer/Helpers.pm | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2b68d81..e51ca62 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -41,7 +41,7 @@ use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_g

 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;
@@ -5399,7 +5399,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,
diff --git a/PVE/QemuServer/Helpers.pm b/PVE/QemuServer/Helpers.pm
index fcc9392..68325b7 100644
--- a/PVE/QemuServer/Helpers.pm
+++ b/PVE/QemuServer/Helpers.pm
@@ -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;
--
2.20.1




More information about the pve-devel mailing list