21

I had a qemu virtual-machine which crashed several times because HDD in hypervisor had no space left. This made me wonder is there a possibility to to set up a logging/debugging for quemu virtual-machines. I tried to start virtual-machine with -D /tmp/qemu-debug-log command:

qemu-system-i386 -D /tmp/qemu-debug-log -monitor pty -device e1000,netdev=tap0 -netdev tap,id=tap0 -m 512M -display vnc=:1 -drive file=FreeBSD10.2

..but this did not even create a /tmp/qemu-debug-log file.

In addition, qemu does not seem to write into messages or kernel ring buffer(dmesg). What are the best practices to enable logging for qemu virtual machines?

2
  • Have you tried to use libvirt's functions instead? Oct 27, 2015 at 20:26
  • I would prefer to work with qemu directly and not through tools which use libvirt which in turn should use libvirt qemu driver.
    – Martin
    Oct 30, 2015 at 14:43

3 Answers 3

19
+50

qemu command accepts a simple -D switch which can create a log file. So for example including -D ./log.txt will create "log.txt" in your working directory.

You can access more logging/debugging options via QEMU Monitor (e.g. qemu -monitor stdio).

7

If you use the -d <component> parameter when starting up QEMU, it will enable debugging for that component. This is useful if you have the QEMU source code and want to see detailed debugs for a given component.

For example, passing -d cpu_reset will enable CPU_LOG_RESET debugging which will "show CPU state before CPU resets". See qemu/util/log.c for a full list of logging options.

By default, logs are written to /tmp/qemu.log, but you can specify a different log file with the -D <logfile> parameter.

5

Any logging option provided by QEMU will be far too low-level for what you need: your problem is not that the virtual hardware is misbehaving, only that the software inside the VM needs attention.

In this respect a VM is no different to a real machine, and the solution is the same. Your question suggests that the VM is running FreeBSD, so you should check out using rsyslog to push the logs to an external syslog server (which could be your host machine) via the network connection.

(I'm not very familiar with the BSDs, so I'm not 100% certain that rsyslog is the right or only solution here, but that keyword should get you started.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .