[pve-devel] [RFC qemu-server] If a VM is offline, catch the netcat timeout with a user friendly message

Dietmar Maurer dietmar at proxmox.com
Mon Jan 9 14:52:51 CET 2017


nc6 simply suppress errors for some reason, test with:

# nc6 -l -p 8000 -w 10 -e "asdasdfadf"

Maybe it is better to use socat?

socat TCP-listen:8000 exec:asdasdfadf,nofork

where 'asdasdfadf' is a non existing command ...


> On November 30, 2016 at 10:19 AM Emmanuel Kasper <e.kasper at proxmox.com> wrote:
> 
> 
> This error message replaces the error:
> TASK ERROR: command '/bin/nc6 -l -p 5900 -w 10 -e '/usr/bin/ssh -T -o
> BatchMode=yes 192.168.16.75 /usr/sbin/qm vncproxy 401 2>/dev/null'' failed:
> exit code 1
> as seen in the task list.
> 
> It is not currently possible to test if a VM is running or not for the whole
> cluster
> wide, so we just improve the error message.
> ---
>  PVE/API2/Qemu.pm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 902f028..ce83482 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -1411,8 +1411,8 @@ __PACKAGE__->register_method({
>  		# also redirect stderr (else we get RFB protocol errors)
>  		$cmd = ['/bin/nc6', '-l', '-p', $port, '-w', $timeout, '-e', "$qmstr
> 2>/dev/null"];
>  	    }
> -
> -	    PVE::Tools::run_command($cmd);
> +	    # catch netcat timeout when the VM is not running
> +	    PVE::Tools::run_command($cmd, errmsg => "Is VM $vmid running ? Unable to
> open a console");
>  
>  	    return;
>  	};
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list