Qemu-kvm debug using gdb and put breakpoints on required systemcalls

Attach gdb to the qemu-kvm process. Start benchmark on VM and put a breakpoint on required systemcalls.  In this example, i am tracing  io_submit

1) Edit XML file

Change this

<domain type=’kvm’>


<domain type=’kvm’ xmlns:qemu=’http://libvirt.org/schemas/domain/qemu/1.0′&gt;

<qemu:arg value=’-s’/>

and restart VM

2) root@kvm-1 ~]# gdb /usr/lib/debug/lib/modules/3.10.0-229.4.2.el7.x86_64/vmlinux
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-64.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “x86_64-redhat-linux-gnu”.
For bug reporting instructions, please see:
Reading symbols from /usr/lib/debug/lib/modules/3.10.0-229.4.2.el7.x86_64/vmlinux…done.

3) attach qemu-kvm pid which needs to be traced

(gdb) attach <qemu-kvm pid>


(gdb) b io_submit
Breakpoint 1 at 0x7ff9fd094690: file io_submit.c, line 23.
(gdb) c

Breakpoint 1, io_submit (ctx=0x7ff9fee24000, nr=1, iocbs=0x7ffa045f2660) at io_submit.c:23
23    io_syscall3(int, io_submit, io_submit, io_context_t, ctx, long, nr, struct iocb **, iocbs)

Happy qemu Debugging

Thanks to Fam Zheng for help


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s