Return a list of available commands that can be issued through QGA Get information about the assigned virtual CPUs Get all users currently logged into the guest OS Check the guest’s message log for ‘guest-fstrim called’.ĭisplays various OS information like the distribution, kernel version and architecture Note: Since running a full fstrim takes quite a while, it’s not uncommon that the command seemingly fails with ‘qmp command ‘guest-fstrim’ failed – got timeout’. The VM has to be configured with the discard option or running with SSD emulation enabeld and the guest’s filesystem needs to be TRIM aware. Issue the TRIM command to the VM’s block device(s). Thawing a frozen filesystem returns control to the guest operating system Query fsfreeze-status, returns ‘frozen’ or ‘thawed’ Send the fsfreeze-freeze command to the guest, locks the file system on the guest machine Just like the qm guest exec command, the output will be JSON formatted. I compiled a list of valid commands below. In order to use this feature, use the following command: qm guest cmd $yourVMID $Command Those commands are more focused on maintenance and less on interaction with the guest operating system. Instead, with cmd we call various QGA commands on a lower level. Now, we are not executing commands within the guest operating system itself. Get additional VM information and perform low-level tasks You can check the state of the process by using the qm guest exec-status $yourVMID $PID command. Long-running tasks can be sent to the background using the -synchronous=0 parameter. Please be aware that all commands are executed with root privileges. Afterwards, it will return the exit code as well as the contents of stdout and stderr in JSON format. Qm exec will pass the command to the VM, execute it and wait for the command to finish or break with an exit code. The command we are looking for is qm guest exec (again using VMID 100 as an example): qm guest exec 100 - ping -c 3 Side note: This is a friendly reminder that you really want to care about the security of your host system. Therefore, we can pass any command to the guest. Run arbitrary commands in your VMĪs you might have noticed, we have full access to the guest operating system using the QEMU Guest Agent (or QGA for short). If the user was previously locked with passwd -l, the user will be automatically unlocked. As the command suggests, it can be used to set user passwords in your VM, even if there’s no direct access to it anymore.Īs an example, the following command resets the password for the user root on VMID 100: qm guest passwd 100 rootĪfter invoking this command, qm will interactively tell you how to set a new user password for the account in question. This is where qm guest passwd comes in handy. I knew the VM was performing some maintenance tasks in the background which do not like sudden interruptions, so I needed some sort of backdoor. The obvious solution would be to shut down the VM, boot a rescue environment or live distribution, mount the disk and fix the configuration there. Due to a configuration error on my end, I locked myself out of a VM running on my Proxmox host, so I was not able to SSH into it anymore. Especially on VMs, this might not even be exactly helpful regarding security, but this is some sort of personal preference. Usually, I tend to lock all local user accounts in order to make (virtual) console access impossible. I basically learned about qm by accident. Reset user passwords (including the root user) You can get them either from the Proxmox dashboard or by running the qm list command on your host system. In order to use the following commands, you need to get the VMID of your virtual machines. Since the guest agent is pretty essential in case you want to be able to do properly shut down the VMs without performing virtual powercuts or being able to create consistent backups, you want to install it on all of your Linux guests anyways. Using the qm guest command requires qemu-guest-agent to be installed inside your Linux guests. Since calling the qemu-guest-agent interface is not very intuitive by itself, Proxmox provides the qm guest command which acts like a bridge between the host system and the VMs. Proxmox Virtual Environment uses KVM/QEMU as virtualization technology. However, did you know that you can even send commands to your VMs directly from your Proxmox host system? Some features like passing ACPI information for a clean guest shutdown are pretty well-known. qemu-guest-agent acts as an interface between the VMs and the host system. Therefore, QEMU offers a companion service called qemu-guest-agent for Linux guests. Since virtual machines created with KVM/QEMU are not simple containers but quite isolated from the host’s environment, exchanging data and information between the host and the VMs can be a bit tricky.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |