0

I'm trying to debug the QEMU source code to track dirty page updates during live migration. My goal is to inspect the behavior inside functions like cpu_physical_memory_set_dirty_lebitmap() on the destination server, which handles syncing of KVM dirty pages.

When I simply use QEMU logs (printf) inside that function, it only prints 0 dirty pagesuntil I connect to the destination VM using RealVNC, then it starts printing proper dirty page counts. This suggests some laziness or delay in page updates that I want to analyze deeper.

To be clear: I have run a memory-intensive process inside the guest VM to intentionally dirty pages, so dirty pages should be getting tracked.

So I turned to GDB, but I'm running into issues.

  1. Built QEMU from source with debugging enabled using --enable-debug.

  2. Launched the destination VM with:

    qemu-system-x86_64 ... -s -S
    
    • -s opens a GDB server on port 1234.
    • -S tells QEMU to not start the CPU until GDB gives the continue command.
  3. Attached GDB like this:

    gdb qemu-system-x86_64
    (gdb) target remote localhost:1234
    (gdb) break cpu_physical_memory_set_dirty_lebitmap
    (gdb) continue
    

But the destination VM (and the source as well, which is normal in post-copy live migration) hangs and displays an unresponsive GUI. Nothing progresses from there.

  1. If I remove -S, the migration works fine and the destination VM doesn’t hang — but I can’t insert breakpoints early enough, so I lose the ability to properly debug.

  2. In the QEMU documentation, it suggests launching GDB like this:

    gdb vmlinux
    

    But from what I understand, that's meant for debugging the Linux kernel, not QEMU itself. Since I'm trying to debug the QEMU source code, I believe the correct approach is:

    gdb qemu-system-x86_64
    

Question

How can I debug QEMU with GDB during live migration, without the destination VM or the migration process hanging when I use -S?

1
  • What you are currently doing is attaching to a debug server within QEMU, which allows you to debug the thing running within QEMU. If what you want is to debug QEMU, then you could do gdb --args qemu-system-x86_64 ... then at the GDB prompt just run. Or you could start gdb as gdb qemu-system-x86_64 then at the GDB prompt attach PID to attach to an already running QEMU process. Commented May 26 at 9:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.