github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/Doc/gdbdebugParition.txt (about)

     1  If you want to be able to debug a Linux kernel that’s running as 
     2  a KVM guest, you need to specify the ‘-s’ parameter for the command 
     3  line of qemu-kvm. The problem is, there’s no (easy) way to do this 
     4  when you’re using libvirt and virt-manager to manager your virtual 
     5  machines, instead of using KVM directly. What you need to do is 
     6  change the XML configuration of the virtual machine so that the 
     7  ‘-s’ parameter is passed on to qemu-kvm
     8  
     9  
    10  $ virsh edit f14-test
    11  
    12  Here, f14-test is the name of the VM that is managed via virt-manager. 
    13  This will bring up the XML configuration of the VM in your editor. 
    14  The first line of the XML file should be:
    15  
    16  <domain type='kvm'>
    17  
    18  This has to be changed to
    19  
    20  <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    21  
    22  and you also need to add:
    23  
    24  <qemu:commandline>
    25  <qemu:arg value='-s'/>
    26  </qemu:commandline>
    27  
    28  under the <domain> level of the XML. After you save and quit the editor, 
    29  the new configuration will come into effect. When you start the virtual 
    30  machine, there will be a local TCP port (1234 by default) that can be 
    31  used as a remote debugging port from gdb. You can connect to this port 
    32  by using the command
    33  
    34  target remote localhost:1234
    35  
    36  from gdb running on the host machine.
    37  
    38  gdb /usr/src/linux...  (guest build area)
    39  
    40