Help to edit the .XML file of a KVM machine

So I have been trying to tackle an issue with my wireless mouse just to get myself swamped deep into KVM (alleged) bugs..

I’m attempting to modify the XML section in the mouse tab

I run virt-manager as root but no matter how many times I enable XML editing that doesn’t unlock the actual editing. This issue have been reported elsewhere already, it seems a root issue.

If I run virt-manager as non-root the .xml field is accessible (is possible to type in) but as soon as I hit the Apply button I get Error changing VM configuration: xmlParseDoc() failed

I then tried modifying the XML via terminal. I used mostly nano, virsh gave me an headache :slightly_smiling_face:

As shown in the screenshot the mouse XML by default is <input type="mouse" bus="ps2"/>. I started making minor changes like <input type="mouse" bus="ps2"></input> just to see if back in the GUI I could see a change in the XML. I obviously sudo systemctl restart libvirtd every time i did the change.
…Nothing. No change in the XML.

I then paste what I wanted to experiment with inside the input tag

<input type='mouse' bus='ps2'>
<hostdev mode="subsystem" type="usb" managed="yes">
  <source startupPolicy="optional">
    <vendor id="0x1ea7"/>
    <product id="0x0066"/>
  </source>
  <address type="usb" bus="0" port="4"/>
</hostdev>     
</input>

Restart libvirtd…Nothing changes.

Am I actually changing the file?
I think so, because if I delete the / that closes the input tag and restart libvirtd I “break” the virtual machine - mymachine disappears from the list in virt-manager GUI.
This is the XML path sudo nano /etc/libvirt/qemu/mymachine.xml. After changing it I do ctrl+o to save and ctrl+x to exit.

Any suggestion?

You could try using sudo virsh edit name-of-vm as described here: 20.22. Editing a Guest Virtual Machine's XML Configuration Settings | Virtualization Deployment and Administration Guide | Red Hat Enterprise Linux | 7 | Red Hat Documentation

I think anything which does not get parsed correctly will be rejected; this document has some information and available config tags but I don’t know what it is how to achieve what you are trying to do: libvirt: Domain XML format

Edit: I see in your other post you already know about using virxh; you can change from using vi by altering the EDITOR env variable:

specified by the $EDITOR shell parameter (set to vi by default).

2 Likes

Libvirt won’t accept a configuration that’s incomplete, or even slightly incorrect. The common theme is, if it doesn’t like the configuration, it it rejects it outright.

I have got virsh edit XML configurations to work, where they don’t work in virt-manager’s XML editor.

But this is not one of those cases.

You will only get 3 bttons to work with bus="ps2". Mice only ever had 2 buttons back in the early ps2 days (that third button and wheel is actually a nice bonus).

2 Likes

You likely need to enable XML editing.

In the image we can see:

XML editing is disabled in ‘Preferences’. Only enable it if you know what are you doing.

In virt-manager, you can enable this in Edit > Preferences and toggle on Enable XML editing.

1 Like