Friday, July 12, 2013

How to change QEMU processes names

I am currently working on trace analysis and correlation between a host and multiple guests. I am using qemu/kvm as a hypervisor and one of the problems that I encountered was how to know which qemu (or qemu-kvm depending on the version you are using) belongs to which virtual machine. Then I discovered a very interesting feature in qemu allowing you to set the name of the virtual machine's process running on the host (knowing that one VM is a process, and each virtual CPU is a thread belonging to this process).

First, you have to enable the feature from /etc/libvirt/qemu.conf (or whatever configuration file you're using for qemu). Search for the line
#set_process_name = 1
and uncomment it (or make sure it is set to 1):
set_process_name = 1
Then you should restart the libvirt daemon (or reboot your system).

You can then simply give the additional following option:
$> qemu [options] -name vm_name,process="process_name"
to QEMU to set the name of the process to "process_name".

If you omit to provide the process="process_name" option to qemu, the process's name will be set to qemu:vm_name. You have to know that the name of a process can only be 15 characters long, so with this method you've already lost 5 characters. The rest of the name will be truncated.

Make sure this worked by running
$> top
or
$> pgrep -l process_name



Registering a probe to a kernel module using Systemtap

I was trying to register a probe on a function of a kernel module of mine using Systemtap. The .stp file was fairly simple: $> cat mymod...