Managing Guests (VMs and CTs) #
Executing Commands in VMs with qemu-guest-agent
#
qemu-guest-agent provides useful information about the guest system to the host OS (e.g., Proxmox VE), such as guest’s IP addresses, etc.
Additionally, when we use the Promox web UI to gracefully reboot or power down the VMs, it is also handled by the running agent.
The VM management CLI provides a convenient command to run some general-purpose commands in the guests:
qm guest cmd <vmid> COMMAND
For example
qm guest cmd 100 ping
Here’s the list of available commands in Proxmox VE 8:
fsfreeze-freeze
fsfreeze-status
fsfreeze-thaw
fstrim
get-fsinfo
get-host-name
get-memory-block-info
get-memor
y-blocks
get-osinfo
get-time
get-timezone
get-users
get-vcpus
info
network-get-interfaces
ping
shutdown
suspend-disk
suspend-hybrid
suspend-ra
We can also run other commands not listed above with the following syntax:
qm guest exec $VMID -- COMMAND
Example: Free Up Memory (drop_caches in VMs)
#
Note After dropping caches, the linux kernel would have to load additional libraries requested by the processes from the storage, which results in the increased latency in some system calls. Therefore, dropping caches of VM running latency-sensitive payloads is not recommended.
With Proxmox VE, when running VMs that do not utilize their RAM near-max capacity during normal operation, we can allocate more combined RAM to the VMs than the total intalled memory on the host. However, over time, guest system kernels load different libraries and keep them pre-cached in the memory, increasing the total RAM utilization.
Sometimes it can be useful to to increase available RAM on the host system by dropping caches in the guest VMs. And we can use the guest agent to achieve this by running this command from the Proxmox VE terminal:
qm guest exec $VMID -- sh -c 'echo 3 > /proc/sys/vm/drop_caches'