Libvirt: how to pass qemu command line args?

elbarna's own answer is the way to go for configuration options "natively" supported by libvirt (and thus its domain XML). For qemu commandline arguments (and more) not supported by libvirt, you need to include qemu's XML namespace declaration in the 'domain' root element:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>

Reference: https://libvirt.org/drvqemu.html#qemucommand


If you have virt-xml 1.4.1 (released in 2017, so should be widespread by now) or later in your path (provided by community/virt-install in Arch), you can use:

virt-xml $DOMAIN --edit --confirm --qemu-commandline '-my-args 1234'
virt-xml $DOMAIN --edit --confirm --qemu-commandline 'env=MY-ENV=1234'

to automatically add the XML corresponding to env vars and/or args, including the namespace. --confirm allows you to preview the changes before committing.

This is much more convenient than trying to manually paste in the XML namespace, and worked for me even though virsh edit was no longer accepting identical manual changes.

Ref: https://blog.wikichoon.com/2017/03/easy-qemu-commandline-passthrough-with.html


Found solution using this workaround

Converting QEMU arguments to domain XML

After converting to xml import with

virsh create file.xml

Tags:

Qemu

Libvirt