Enable tracing

In virsh

 qemu-monitor-command <vm> --hmp trace-event usb_xhci_* on
 qemu-monitor-command <vm> --hmp info trace-events

output goes to /var/log/libvirt/qemu/.log by default


  • Libvirt XML

      <filesystem type='mount' accessmode='mapped'>
          <source dir='/cache/ltstest'/>
          <target dir='ltstest'/>

mapped is important. It uses extended attributes so the filesystem that needs to be mounted with user_xattr on the host filesystem and the folder needs to be writeable by qemu:

    mount -o remount,user_xattr /cache/ltstest
    chown libvirt-qemu /cache/ltstest

The Guests fstab then uses:

ltstest /ltstest 9p   trans=virtio,version=9p2000.L,rw 0 0

After mounting you can write from the guest to the hosts fileystem:

mount /ltstest
cd /ltstest && touch a

results on the host as extended attributes

 # attr -l a
 Attribute "virtfs.uid" has a 4 byte value for a
 Attribute "virtfs.gid" has a 4 byte value for a
 Attribute "virtfs.mode" has a 4 byte value for a

For details on 9pfs see http://man.cat-v.org/plan_9/5/intro

Hot (un)plug Devices

PCI devices





Devices are not hotpluggable via libvirt (#1417464) but via QMP monitor:

    qemu-monitor-command <vm> '{ "execute": "device_add",  "arguments": { "driver": "ES1370", "id": "snd1" }}'
    qemu-monitor-command <vm> '{ "execute": "device_del",  "arguments": { "id": "snd1" }}

    qemu-monitor-command <vm> '{ "execute": "device_add",  "arguments": { "driver": "AC97", "id": "snd2" }}'
    qemu-monitor-command <vm> '{ "execute": "device_del",  "arguments": { "id": "snd2" }}

More details on QMP commands


  • List all devices:

      qemu-system-x86_64 -device ?
  • Enabling the monitor on raw qemu

      $ qemu-system-i386 -qmp tcp:localhost:4444,server,nowait
      $ telnet localhost 4444
      { "execute": "qmp_capabilities" }
      {"execute": "commands"}