If you want to see KVM/QEMU on VMHost with Libvirt client you can use libvirt-clients
apt install -y libvirt-clients
Assume UUIDVM
result from virsh list
& 192.168.2.13
are Server HOST. for Remote Virsh make sure TCP port 16509
are open.
- List VM
virsh list
- Remote List VM
virsh -c qemu+tcp://192.168.2.13/system list
- Exec Command
virsh -c qemu:///system qemu-agent-command UUIDVM '{"execute": "guest-exec", "arguments": { "path": "apt", "arg": [ "autoremove","-y" ], "capture-output": true }}' --pretty
- Remote Exec Command (Linux)
virsh -c qemu+tcp://192.168.2.13/system qemu-agent-command UUIDVM '{"execute": "guest-exec", "arguments": { "path": "systemctl", "apt": [ "autoremove","-y" ], "capture-output": true }}' --pretty
- Remote Exec Command (Windows)
virsh -c qemu+tcp://192.168.2.13/system qemu-agent-command UUIDVM '{"execute":"guest-exec", "arguments":{"path":"cmd.exe","arg":["/c","echo 123 > C:\\123.txt"]}}' --pretty
## Example to Set IP Address
virsh -c qemu+tcp://192.168.2.13/system qemu-agent-command UUIDVM '{"execute":"guest-exec", "arguments":{"path":"cmd.exe","arg":["/c","netsh interface ipv4 set address name=\"Ethernet 2\" static 172.16.0.15 255.255.0.0 172.16.0.1"]}}' --pretty
## Example to Set Hostname
virsh -c qemu+tcp://192.168.2.13/system qemu-agent-command UUIDVM '{"execute":"guest-exec", "arguments":{"path":"powershell.exe","arg":["Rename-Computer -NewName \"WinHK05-POC\""]}}' --pretty
## Example to Reboot Guest OS
virsh -c qemu+tcp://192.168.1.16/system qemu-agent-command 1be52c2df60c491bb8f46fb129585786 '{"execute":"guest-exec", "arguments":{"path":"shutdown.exe","arg":["/r","/t","0"]}}' --pretty
virsh -c qemu+tcp://192.168.2.13/system qemu-agent-command UUIDVM '{"execute": "guest-exec-status", "arguments": { "pid": 1127307 }}' --pretty