简体   繁体   中英

How to modify the kvm module in linux kernel?

I want to make some modifications in the kvm module in my Linux kernel. For this, I did the following:

  1. Obtained the Kernel sources:
    apt-get source linux-image-source-$(uname-r)
  2. Modified a function in the file emulate.c - changed some variables and added a printk statement.
  3. Built the kernel:
    fakeroot debian/rules clean
    fakeroot debian/rules binary-headers binary generic
  4. Installed the packages produced as a result of building:
    sudo dpkg -i linux*(version)*.deb
  5. Rebooted the system.
  6. Executed QEMU with kvm enabled.

However the changes I made, didn't seem to reflect when I try to test them in QEMU. Neither did the printk statement execute when I checked with dmesg .

Can anyone please point out which part I am getting wrong?

Installing a new kernel wont necessarily make it boot into it, you may need to change the default in your boot loader. (eg grub)

You can check whether the kernel you just compiled and installed is the same as what you booted with using:

cat /proc/version

If this is not as expected, then you need to tweak your Grub config and/or reboot and manually choose the correct kernel.

Having established the correct kernel, you may need to change the level of which messages are reported by the kernel (via dmesg)

This is controlled by a kernel proc file. You can see what the current values are by printing this file:

cat /proc/sys/kernel/printk

Example output:

4 4 1 7

The first argument - messages with severity < 4 (ie 0, 1 2 or 3) will be recorded. The second argument - messages with no specified severity default to 4 and thus not seen by the system in the above example.

So the following will change the log so that all kernel messages are seen:

echo 8 > /proc/sys/kernel/printk

See (for example) http://www.makelinux.net/books/lkd2/ch18lev1sec3 for further information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM