[pve-devel] [PATCH qemu-server 2/4] savevm: periodically print progress

Stefan Reiter s.reiter at proxmox.com
Thu Feb 4 13:52:22 CET 2021


Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 PVE/QemuConfig.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 3f4605f..37db347 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -14,6 +14,7 @@ use PVE::QemuServer;
 use PVE::QemuServer::Machine;
 use PVE::Storage;
 use PVE::Tools;
+use PVE::CLIFormatter;
 
 use base qw(PVE::AbstractConfig);
 
@@ -280,14 +281,26 @@ sub __snapshot_create_vol_snapshots_hook {
 		PVE::Storage::activate_volumes($storecfg, [$snap->{vmstate}]);
 
 		mon_cmd($vmid, "savevm-start", statefile => $path);
+		print "saving VM state and RAM\n";
+		my $start = time();
+		my $state = sub {
+		    my ($bytes) = @_;
+		    my $b = PVE::CLIFormatter::render_bytes($bytes);
+		    my $t = PVE::CLIFormatter::render_duration(time() - $start);
+		    return "$b in $t";
+		};
 		for(;;) {
 		    my $stat = mon_cmd($vmid, "query-savevm");
 		    if (!$stat->{status}) {
 			die "savevm not active\n";
 		    } elsif ($stat->{status} eq 'active') {
 			sleep(1);
+			my $s = $state->($stat->{bytes});
+			print "progress: $s\n";
 			next;
 		    } elsif ($stat->{status} eq 'completed') {
+			my $s = $state->($stat->{bytes});
+			print "saved $s\n";
 			last;
 		    } else {
 			die "query-savevm returned status '$stat->{status}'\n";
-- 
2.20.1






More information about the pve-devel mailing list