Libvirt provides a lot of help to debug problems:
it creates per virtual machine logfiles in /var/log/libvirt/ (when running as root) and
~/.libvirt/qemu/logs/(when running as user). These contain the verbatim calls to QEMU/KVM so you can copy/paste them into the shell - you usually want to drop the-monitor ptyargument then so you can access the QEMU/KVM monitor interactively (Ctrl-Alt-F2).running it verbosely in foreground mode is as easy as simply running
libvirtd -v.if you do
export LIBVIRT_DEBUG=1before doing the above you'll get the very useful debugging output. I usally drop the-vthen.also use the above export statement when debugging problems in virt-manager, virt-viewer or virsh but note that in the case of QEMU/KVM you'll end up calling into libvirtd with these tools so watching the daemon's debug output is more important.
when debugging testcase failures in the source code
export VIR_TEST_DEBUG=1is your friend. Debugging a XML testcase failure then looks like:abs_srcdir=/your/path/to/libvirt.cvs/tests/ VIR_TEST_DEBUG=1 ./qemuxml2xmltest