[pve-devel] [PATCH] Add qga freeze in vzdump in snapshot mode

Dietmar Maurer dietmar at proxmox.com
Tue Dec 9 10:33:19 CET 2014


comments inline:

>  PVE/VZDump/QemuServer.pm |   19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm index
> fd36c69..2c62de3 100644
> --- a/PVE/VZDump/QemuServer.pm
> +++ b/PVE/VZDump/QemuServer.pm
> @@ -286,8 +286,8 @@ sub archive {
>      my $resume_on_backup;
> 
>      my $skiplock = 1;
> -
> -    if (!PVE::QemuServer::check_running($vmid)) {
> +    my $vm_is_running = PVE::QemuServer::check_running($vmid);
> +    if (!$vm_is_running) {
>  	eval {
>  	    $self->loginfo("starting kvm to execute backup task");
>  	    PVE::QemuServer::vm_start($self->{storecfg}, $vmid, undef, @@ -
> 380,8 +380,23 @@ sub archive {
> 
>  	$qmpclient->queue_cmd($vmid, $add_fd_cb, 'getfd',
>  			      fd => $outfileno, fdname => "backup");
> +
> +	my $freeze_fs = 0;
> +
> +	if ( $self->{vmlist}->{$vmid}->{agent} == 1 && $vm_is_running ){

please use:

if ( $self->{vmlist}->{$vmid}->{agent} && $vm_is_running ) {

> +	    $freeze_fs = PVE::QemuServer::vm_mon_cmd($vmid,"guest-fsfreeze-
> freeze");
> +	    $self->loginfo("Can't freeze fs!")if ( defined($freeze_fs) &&
> $freeze_fs == 0 );
> +	}
> +

Please note that the result from qqa command is not trusted, so you need to parse
the result if you really want to use it.
Also, sometime guest-fsfreeze-freeze just returns an empty string ''.
Also, it can run into timeouts, and can raise other exceptions.
So please catch exceptions here.

>  	$qmpclient->queue_execute();
> 
> +	my $thaw_fs = 0;
> +	$thaw_fs= PVE::QemuServer::vm_mon_cmd($vmid,"guest-fsfreeze-
> thaw")
> +	    if ( $freeze_fs > 0 );
> +
> +	$self->loginfo("Error by trying thaw fs, you must unlock manually")
> +	    if ( $freeze_fs > 0 && 0 != $freeze_fs - $thaw_fs );
> +

Same here (exceptions, parse result).

I would simply ignore the result of those commands (to keep it simple).





More information about the pve-devel mailing list