[pve-devel] [PATCH qemu-server] check if ga runs before a fsfreeze-freeze/thaw

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Nov 10 09:55:22 CET 2017


On 11/10/2017 09:47 AM, Dominik Csapak wrote:
> since the guest-fsfreeze-freeze command has a timeout of 1 hour,
> we want to check if the guest-agent even runs before executing that,
> or else we wait 1 hour and then continue
> 

Would be nice to get a warning in the (task) log if QGA is configured
but it's not running, IMO. So the user sees that he forgot to setup
QGA entirely or it seems that it does not runs anymore in the VM.
Looks good, besides that.

> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/QemuServer.pm        |  5 +++--
>  PVE/VZDump/QemuServer.pm | 10 ++++++++--
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 2e822f3..7104ba2 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -6079,7 +6079,8 @@ sub qemu_drive_mirror_monitor {
>  		last if $skipcomplete; #do the complete later
>  
>  		if ($vmiddst && $vmiddst != $vmid) {
> -		    if ($qga) {
> +		    my $agent_running = $qga && qga_check_running($vmid);
> +		    if ($agent_running) {
>  			print "freeze filesystem\n";
>  			eval { PVE::QemuServer::vm_mon_cmd($vmid, "guest-fsfreeze-freeze"); };
>  		    } else {
> @@ -6090,7 +6091,7 @@ sub qemu_drive_mirror_monitor {
>  		    # if we clone a disk for a new target vm, we don't switch the disk
>  		    PVE::QemuServer::qemu_blockjobs_cancel($vmid, $jobs);
>  
> -		    if ($qga) {
> +		    if ($agent_running) {
>  			print "unfreeze filesystem\n";
>  			eval { PVE::QemuServer::vm_mon_cmd($vmid, "guest-fsfreeze-thaw"); };
>  		    } else {
> diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
> index 65ca09d..a630829 100644
> --- a/PVE/VZDump/QemuServer.pm
> +++ b/PVE/VZDump/QemuServer.pm
> @@ -404,7 +404,13 @@ sub archive {
>  	$qmpclient->queue_cmd($vmid, $add_fd_cb, 'getfd',
>  			      fd => $outfileno, fdname => "backup");
>  
> -	if ($self->{vmlist}->{$vmid}->{agent} && $vm_is_running){
> +	my $agent_running = 0;
> +
> +	if ($self->{vmlist}->{$vmid}->{agent} && $vm_is_running) {
> +	    $agent_running = PVE::QemuServer::qga_check_running($vmid);
> +	}
> +
> +	if ($agent_running){
>  	    eval { PVE::QemuServer::vm_mon_cmd($vmid, "guest-fsfreeze-freeze"); };
>  	    if (my $err = $@) {
>  		$self->logerr($err);
> @@ -413,7 +419,7 @@ sub archive {
>  
>  	$qmpclient->queue_execute();
>  
> -	if ($self->{vmlist}->{$vmid}->{agent} && $vm_is_running ){
> +	if ($agent_running){
>  	    eval { PVE::QemuServer::vm_mon_cmd($vmid, "guest-fsfreeze-thaw"); };
>  	    if (my $err = $@) {
>  		$self->logerr($err);
> 





More information about the pve-devel mailing list