Can `qm guest exec` return a non-zero exit code, if guest command fails?

carsb

New Member
Dec 10, 2024
7
2
3
Hello,
qm guest exec is a great way to manage a VM remotely and execute commands.
Now I was wondering, if it is already possible - or planned - to let qm guest exec fail with a non-zero exit code as well, if the guest VM command failed.

Currently this seems not the case:
Bash:
root@pve:~# qm guest exec 100 -- false
{
   "exitcode" : 1,
   "exited" : 1
}

root@pve:~# echo $?
0

https://linuxcommandlibrary.com/man/qm-guest-exec mentions --fail-on-error= , but this option isn't available in official docs and doesn't work:
Bash:
root@pve:~# qm guest exec 100 --fail-on-error=true -- false
Unknown option: fail-on-error
400 unable to parse option
qm guest exec <vmid> [<extra-args>] [OPTIONS]

I think, this feature would be a good addition to said command:
  • Checking for result becomes easier, if only interested in success or failure.
  • It benefits security, if remote command output does not need to be parsed (qm guest exec 100 -- false; echo "evil terminal output" &>/dev/null).

Thanks for any hints and kind regards
 
Last edited: