[英]How to build and run a Linux kernel module on QEMU?
My teacher gives me a linux kernel vmlinuz-3.17.2 and a rootfs.ext2 which can be loaded to qemu. 我的老师给了我一个Linux内核vmlinuz-3.17.2和一个rootfs.ext2,可以将其加载到qemu中。 And he asks me to build a simplest kernel module which prints a hello world as homework.
他要求我构建一个最简单的内核模块,该模块将作业打招呼的世界打印出来。
However, I can't see anything in dmesg or /var/log/messages Is there anything wrong? 但是,我在dmesg或/ var / log / messages中看不到任何东西吗? How can I do with this?
我该怎么办? There is also nothing to be printed when I run rmmod hello.ko successfully.
当我成功运行rmmod hello.ko时,也没有任何内容可以打印。
My log level is 7 4 1 7 我的日志级别是7 4 1 7
I have make my hello.c as follows: 我将hello.c设置如下:
#include <linux/init.h>
#include <linux/module.h>
static int __init hello_init(void)
{
pr_info("Hello World");
return -1;
// I changed this to -1 deliberately, Because It seems that the code is not executed.
}
static void __exit hello_exit(void)
{
printk(KERN_ERR "Goodbye, cruel world\n");
}
MODULE_LICENSE("GPL");
module_init(hello_init);
module_exit(hello_exit);
Buildroot Buildroot里面
Buildroot is the easiest way to do it: Buildroot是最简单的方法:
Tested on Ubuntu 16.04. 在Ubuntu 16.04上测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.