Installing QEMU Guest Agent in a Windows VM
In Progress
Getting the VM Ready
If you are doing this barebones with just qemu, you need to acquire the qemu-ga drivers and agent for the Windows VM. With modern Windows, they will be rejected for not being signed so fortunately RedHat maintains a repository of signed drivers available in a variety of installable formats (.iso, .msi, etc). https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md https://wiki.libvirt.org/Qemu_guest_agent.html
| qemu devices to install |
Getting the Hypervisor Ready
The problem is simple, the XML configuration file for Windows hosts does not reflect the "serial device" that qemu-ga uses to communicate with the hypervisor. It's easy to edit with virsh.
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-managing_guest_virtual_machines_with_virsh-editing_a_guest_virtual_machines_configuration_file
virsh list --all
virsh edit VMNAME
virsh list --all
virsh edit VMNAME
https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/virtualization_administration_guide/sect-qemu_guest_agent-running_the_qemu_guest_agent_on_a_windows_guest
There are three parts necessary in the XML file for the Hypervisor to actually communicate with the virtual machine. Often, two of them are correctly populated. The first defines the virtio-serial, virtual serial port, which serves as the communication link. It's usually automatically present and can be found in the <devices> section after the pci and sata block.
<controller type="virtio-serial" index="0">
<address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
</controller>
The second block that is usually automatically present is the spicevnc channel block. This one serves to allow a virtual console to the underlying VM.
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
<address type="virtio-serial" controller="0" bus="0" port="2"/>
</channel>
The missing block is the unix channel which utilizes the virtual serial port to pass commands and receive data from the VM. Using the virsh XML editor, copy this missing block into the file. A good place to put it is either above or below the spicevnc section.
<channel type="unix">
<target type="virtio" name="org.qemu.guest_agent.0"/>
<address type="virtio-serial" controller="0" bus="0" port="1"/>
</channel>
The Easy Way
Naturally, after fighting through the system and finding the XML configuration files, etc, I did find the solution was much more obvious if you want to click around with the GUI. So for the less 1337 solution:
- Click "Add Hardware" at the bottom of the device list
- Click "Channel" in the left pane's device list
- Select "org.qemu.guest_agent.0" in the name dropdown
- Select "UNIX socket(unix)" in the device type dropdown
As you revel in your functioning qemu connectivity with the hypervisor, just pretend you used the command line when telling your friends. https://www.reddit.com/r/linuxquestions/comments/13hlvbs/how_to_install_configure_qemuguestagent_on_windows/


