7

I have the current libvirt 1.2.20 i want to pass to my machine create with virt-manager some qemu flags. I edited the file and add

  </devices>
  <qemu:commandline>
          <qemu:arg value='-L pc-bios'/>
  </qemu:commandline>
</domain>

But doesn't work i also tried to edit from virsh

virsh edit domain

and put

<qemu:commandline>
          <qemu:arg value='-L pc-bios'/>
  </qemu:commandline>

But give me this error

errore: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Element domain has extra content: qemu:commandline

Failed. Try again? [y,n,i,f,?]: 

How to pass correctly qemu command line? Thanks

8

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

  • for servers who don't support kvm natively you can use type='qemu' – Jonas Libbrecht Feb 15 '17 at 14:10
  • That schema is 404 now. – Vilius May 19 '18 at 16:41
  • Seems they migrated to RelaxNG for the XML schemas. Though IDK if replacing above URL with https://libvirt.org/schemas/domain.rng works, if required at all. – argonym Jun 1 '18 at 12:56
  • @argonym No, does not seem to work out of the box. – Bostrot Sep 25 '18 at 23:03
3

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

0

Found solution using this workaround

Converting QEMU arguments to domain XML

After converting to xml import with

virsh create file.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.