Table of Contents
Guest Agent
Proxmox vm's use the QEMU guest agent. The official documentation from Proxmox can be found here: https://pve.proxmox.com/wiki/Qemu-guest-agent
Proxmox VE VM Config
- Open the Proxmox VE UI
- Open the vm
- Options
- QEMU Guest Agent
- Check: Use QEMU Guest Agent
- Power off the vm and start it again
If this option is set, a new virtual serial device is shown to the vm, which will be accessed by the agent which will be installed in the guest os.
To set this option via cli use the following command:
qm set VMID --agent 1
Execute Command
Enable
Per default the qemu-guest-agent doesn't allow command execution. You will see the following error message, if you try it:
root@mypve:~# qm guest exec 101 /bin/ls Agent error: The command guest-exec has been disabled for this instance
CentOS / RHEL
Open the config file.
vi /etc/sysconfig/qemu-ga
Search for the blacklist line.
BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status
Remove guest-exec (and guest-exec-status for async exec calls).
BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush
Restart the agent.
systemctl restart qemu-guest-agent
Use
qm guest exec <vmid> <command> <arg1> <arg2> ...
root@mypve:~# qm guest exec 101 /bin/ls -- "-la" "/etc/hosts" { "exitcode" : 0, "exited" : 1, "out-data" : "-rw-r--r--. 1 root root 158 Sep 10 2018 /etc/hosts\n" }
Installation on Windows
- Download the latest VirtIO ISO (Fedora VirtIO Archive)
- Mount the ISO to the vm
- Open the device manager
- Search the device “PCI Simple Communications Controller”
- Install the driver for this device from the mounted ISO
- Start the Guest Agent installer from the mounted ISO (“X:\guest-agent\qemu-ga-x86_64.msi”)
- Reboot the vm
Installation on Linux
For Debian/Ubuntu based systems:
apt install qemu-guest-agent
For RedHat based systems:
yum install qemu-guest-agent
Start the service:
systemctl start qemu-guest-agent
Troubleshooting
Timed out waiting for device
Starting the systemd unit file takes a long time and fails. You see the following errors in the journal:
Apr 10 18:14:39 pmg systemd[1]: dev-virtio\x2dports-org.qemu.guest_agent.0.device: Job dev-virtio\x2dports-org.qemu.guest_agent.0.device/start ti Apr 10 18:14:39 pmg systemd[1]: Timed out waiting for device /dev/virtio-ports/org.qemu.guest_agent.0.
You probably forgot to enable the QEMU Guest Agent setting in the vm settings.
Agent on Windows is started but doesn't work
If the QEMU Guest Agent service is startet but in the vm overview you see “QEMU Guest Agent not running” then you probably forgot to enable the QEMU Guest Agent setting in the vm settings.