[pve-devel] [POC qemu-server 6/6] add usleep parameter to savevm_monitor
Fabian Ebner
f.ebner at proxmox.com
Thu Apr 8 12:33:16 CEST 2021
and potentially save a big part of a second
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
PVE/QemuServer.pm | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0287a80..a8caa35 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -22,7 +22,7 @@ use JSON;
use MIME::Base64;
use POSIX;
use Storable qw(dclone);
-use Time::HiRes qw(gettimeofday tv_interval);
+use Time::HiRes qw(gettimeofday tv_interval usleep);
use URI::Escape;
use UUID;
@@ -5622,14 +5622,16 @@ sub vm_reboot {
}
sub savevm_monitor {
- my ($vmid) = @_;
+ my ($vmid, $usleep) = @_;
+
+ $usleep //= 1000 * 1000;
for(;;) {
my $state = mon_cmd($vmid, "query-savevm");
if (!$state->{status}) {
die "savevm not active\n";
} elsif ($state->{status} eq 'active') {
- sleep(1);
+ usleep($usleep);
next;
} elsif ($state->{status} eq 'completed') {
print "State saved, quitting\n";
@@ -7769,7 +7771,7 @@ sub upgrade_qemu {
$print_elapsed->("setting migration caps");
mon_cmd($vmid, "savevm-start", statefile => $statefile);
$print_elapsed->("issuing savevm-start");
- savevm_monitor($vmid);
+ savevm_monitor($vmid, 10 * 1000);
$print_elapsed->("saving state");
};
if (my $err = $@) {
--
2.20.1
More information about the pve-devel
mailing list