all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Stefan Reiter <s.reiter@proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 2/4] savevm: periodically print progress
Date: Fri, 5 Feb 2021 14:21:00 +0100	[thread overview]
Message-ID: <77fc57a6-3a83-56f1-4695-81f1eaf2aa82@proxmox.com> (raw)
In-Reply-To: <20210204125224.25059-2-s.reiter@proxmox.com>

much thanks in general for following up on my request, this irked
me since almost ever.

a few nits inline.

On 04.02.21 13:52, Stefan Reiter wrote:
> Signed-off-by: Stefan Reiter <s.reiter@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();

The SaveVMInfo struct returned by 'query-savevm' would have a 'total-time' field,
why not use that?

> +		my $state = sub {

over general helper name

> +		    my ($bytes) = @_;
> +		    my $b = PVE::CLIFormatter::render_bytes($bytes);
> +		    my $t = PVE::CLIFormatter::render_duration(time() - $start);
> +		    return "$b in $t";

could return a ($b, $t) tuple here, just an idea, this is totally fine to
with the current usage.

> +		};
>  		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";

I'd drop the "progress", IMO just noise.

>  			next;
>  		    } elsif ($stat->{status} eq 'completed') {
> +			my $s = $state->($stat->{bytes});


> +			print "saved $s\n";

I'd explicitly out put that we're done:

"completed, saved $s\n";

>  			last;
>  		    } else {
>  			die "query-savevm returned status '$stat->{status}'\n";
> 





  reply	other threads:[~2021-02-05 13:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 12:52 [pve-devel] [PATCH qemu-server 1/4] vzdump: use renderers from Tools instead of duplicating code Stefan Reiter
2021-02-04 12:52 ` [pve-devel] [PATCH qemu-server 2/4] savevm: periodically print progress Stefan Reiter
2021-02-05 13:21   ` Thomas Lamprecht [this message]
2021-02-04 12:52 ` [pve-devel] [PATCH qemu-server 3/4] savevm: show information about drives during snapshot Stefan Reiter
2021-02-04 13:51   ` [pve-devel] [PATCH v2 " Stefan Reiter
2021-02-04 12:52 ` [pve-devel] [PATCH manager 4/4] ui: snapshot: show task viewer for progress log Stefan Reiter
2021-02-05  8:42   ` Fabian Ebner
2021-02-05 13:05 ` [pve-devel] [PATCH qemu-server 1/4] vzdump: use renderers from Tools instead of duplicating code Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77fc57a6-3a83-56f1-4695-81f1eaf2aa82@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=s.reiter@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal