[Libguestfs] Using guestfs to debug kernel
Richard W.M. Jones
rjones at redhat.com
Tue Dec 3 18:48:15 UTC 2013
On Tue, Dec 03, 2013 at 06:05:24PM +0100, Teto wrote:
> I would like to use libguestfs to help me setup a VM that I run later
> with qemu to debug my linux kernel (via qemu -kernel <mykernel>
> -append ...).
> One problem I face for instance is that my VM lacks the modules
> matching my kernel version. So what would you consider as the best
> option here to load the modules for the kernel ?
> Should I upload the modules from the host to the VM /lib/modules (need
> to tar this fodler and upload it via tar_in ?!) ? Or can I access my
> /lib/modules over the network via a specific initramfs ?
> I am quite open to any suggestion, I've already got the libguestfs
> python binding working.
A couple of ideas:
(1) Keep /lib/modules on a separate virtual disk (mounted in the guest
using /etc/fstab or an early init script), so you only have to rebuild
that disk when your kernel changes. You can use guestfish or
virt-make-fs to rebuild the virtual disk (relatively) quickly.
virt-make-fs /lib/modules/`uname -r` modules.img
takes 11.2 seconds (warmed up) on my machine.
(2) Use 9p to export the /lib/modules directory from the host into the
guest. http://wiki.qemu.org/Documentation/9psetup has instructions
how to do this. This way you don't need to build any modules disk at
all, but you will need to compile 9p into your test kernel and have an
init script that mounts the 9p disk quite early in the boot process
(before any modules are needed).
Hope that is of some help.
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
More information about the Libguestfs