[pve-devel] [PATCH qemu-server] qm agent : check if qga service is running

Alexandre DERUMIER aderumier at odiso.com
Wed May 30 08:04:05 CEST 2018


>>check running uses the ping command, so maybe we should exempt it here and always 
>>to it - may not make sense to check with ping if we can do ping, or what do you mean? 

We need to check if qga is running with a small timeout (guest-ping) before doing another command with a bigger timeout (like freeze-fs / 1h timeout).
The only wait to test is to send a command to qga (can be a ping or another command) or retreive qmp event but we don't have the framework to do it currently.



>>So I actually get: 
>>
>># pvesh create nodes/dev5/qemu/12312321/agent/fstrim 
>>Qemu Guest Agent is not running - VM 12312321 qmp command 'guest-ping' failed - got timeout 
>>Qemu Guest Agent is not running 
>>
>>We could add a $silent parameter to qga_check_running to avoid that. 

maybe could we simply change the warn in

sub qga_check_running {
    my ($vmid) = @_;

   eval { vm_mon_cmd($vmid, "guest-ping", timeout => 3); };
    if ($@) {
        warn "Qemu Guest Agent is not running - $@";
        return 0;
    }
    return 1;
}


-> warn "Qemu Guest Agent is not running";



and in Agent.pm,

return if !PVE::QemuServer::qga_check_running($vmid); 

?




----- Mail original -----
De: "Thomas Lamprecht" <t.lamprecht at proxmox.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>, "aderumier" <aderumier at odiso.com>
Envoyé: Mercredi 30 Mai 2018 07:49:00
Objet: Re: [pve-devel] [PATCH qemu-server] qm agent : check if qga service is running

I'll agree with the patches intent, two notes inline 

On 5/28/18 5:36 PM, Alexandre Derumier wrote: 
> --- 
> PVE/API2/Qemu/Agent.pm | 1 + 
> 1 file changed, 1 insertion(+) 
> 
> diff --git a/PVE/API2/Qemu/Agent.pm b/PVE/API2/Qemu/Agent.pm 
> index 9af5d5f..fbc8105 100644 
> --- a/PVE/API2/Qemu/Agent.pm 
> +++ b/PVE/API2/Qemu/Agent.pm 
> @@ -174,6 +174,7 @@ sub register_command { 
> 
> die "No Qemu Guest Agent\n" if !defined($conf->{agent}); 
> die "VM $vmid is not running\n" if !PVE::QemuServer::check_running($vmid); 
> + die "Qemu Guest Agent is not running\n" if !PVE::QemuServer::qga_check_running($vmid); 

check running uses the ping command, so maybe we should exempt it here and always 
to it - may not make sense to check with ping if we can do ping, or what do you mean? 

Further, qga_check_running always does a: warn "Qemu Guest Agent is not running - $@"; 

So I actually get: 

# pvesh create nodes/dev5/qemu/12312321/agent/fstrim 
Qemu Guest Agent is not running - VM 12312321 qmp command 'guest-ping' failed - got timeout 
Qemu Guest Agent is not running 

We could add a $silent parameter to qga_check_running to avoid that. 

> 
> my $cmd = $param->{command} // $command; 
> my $res = PVE::QemuServer::vm_mon_cmd($vmid, "guest-$cmd"); 
> 



More information about the pve-devel mailing list