4
votes

I installed Ubuntu18.04 desktop in a kvm-qemu virtualization setup and it is working. I found that there is a direct kernel boot option in virt-manager settings for a virtual machine. I want to debug the kernel using gdb from the host.

enter image description here

Please help in finding the kernel path and initrd.img file path.

Is kernel path same as arch/x86/boot/bzImage ?. Is it possible to copy the initrd.img file inside the guest (/boot/ directory) to the host machine?

Thanks!

2
Don't use these options. They are not meant for normal installations. Leave them blank. - Michael Hampton
@MichaelHampton Actually I want this to happen for debugging purpose. I already did it with qemu-system and remote gdb. I wanted to know whether is it possible using virt-manager or not? - Debashish
You should continue doing it that way, then, even with virt-manager. You can use virsh qemu-monitor-command to enable remote debugging for a VM. - Michael Hampton
Can you explain a bit more on it? I am new to virsh - Debashish

2 Answers

2
votes

Please help in finding the kernel path and initrd.img file path.

To find currently running kernel you can do this: cat /proc/cmdline. It contains "Kernel command line parameters" and you should find there path to the currently running kernel file. More info: https://manpages.debian.org/jessie/systemd/kernel-command-line.7.en.html

There should be no problem with copying files from guest to host machine, unless I misunderstood your question. There are few ways, you could copy it over ssh, or you could share some directory between host and guest or check this out: https://askubuntu.com/questions/858649/how-can-i-copypaste-from-the-host-to-a-kvm-guest not sure what are your requirements here?

1
votes

Despite a comment above, using the Direct Boot option is one of the only ways to get an Ubuntu cloud image to run on virt-manager: https://askubuntu.com/questions/1375589/what-are-the-different-versions-available-as-ubuntu-cloud-images

So, there is no way to point those fields to the internal kernel files. But you can use them like they would be normally in any machine by configuring the Virt-manager bios to recognize them. I'm trying to troubleshoot that currently. Basically, it goes Bios>MBR/GPT(bootloader not easily accessible files except using tools like fdisk, cdisk, parted)>Grub. The boot partition, whichever has /boot/grub on it, has to be flagged as 'boot'. Gparted is one way to see that flag, cfdisk also.

You can point those fields to your own kernel files, they are usually roughly compatible. Then use root=/dev/sda(X) adjust to your own root path. Get in and use tools like update-grub or efiboot to configure the image.