]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer/Helpers.pm
add new helper to calculate timeout based on vm config
[qemu-server.git] / PVE / QemuServer / Helpers.pm
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;