UML/User-mode Linux

2012年4月6日 发表评论 阅读评论 10,129 次浏览

之前提到过KML,这里描述一下UML,但关于UML的编译和使用不想做过多的介绍,因为官网等都有很多这方面的资料,不过我乐意提供另外一些汇总信息,也是我在编译使用UML过程中遇到的问题,当然限于环境关系,这些问题在另外的环境里不一定就出现,另外的环境里出现的问题我这里可能没有遇到。

一,不错的相关站点:http://user-mode-linux.sourceforge.net/http://uml.devloop.org.uk/index.html
二,文件系统:http://fs.devloop.org.uk/
三,邮件列表:http://dir.gmane.org/gmane.linux.uml.develhttp://dir.gmane.org/gmane.linux.uml.user
四,UML项目并没有废弃,一直在更新维护,这从邮件列表的活动情况可以看出来,Linux 3.0还有UML的更新:http://kernelnewbies.org/Linux_3.0#head-64b1d7b9dd5fdd57ce0350987108ac475634e5e7
五,在编译和使用UML过程中,可能遇到的问题:
1,找不到文件系统
[ 0.230000] VFS: Cannot open root device “98:0″ or unknown-block(98,0)
[ 0.230000] Please append a correct “root=” boot option; here are the available partitions:
[ 0.230000] Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(98,0)
解决:首先请确保UML内核编译时已经选上这么几项:
— Block devices
[*] Virtual block device
[*] Always do synchronous disk IO for UBD
其次,如果你的根文件系统是ext4的,请确保选中:
File systems —>
<*> The Extended 4 (ext4) filesystem
其它文件系统类似。
最后,请确保运行uml时带上了ubda或udba这样的选项。
另外几个选项也建议选上:将以虚拟设备作为网络设备:
[*] Networking support —>
UML Network Devices —>
[*] Virtual network device
[*] Ethertap transport
[*] TUN/TAP transport
使用UML大部分是为了调内核,这两个选项必不可少:
Kernel hacking —>
[*] Compile the kernel with debug info
[*] Compile the kernel with frame pointers
2,编译警告:
LD vmlinux.o
MODPOST vmlinux.o
WARNING: vmlinux.o (.__syscall_stub.2): unexpected non-allocatable section.
Did you forget to use “ax”/”aw” in a .S file?
Note that for example contains
section definitions for use in .S files.
GEN .version
解决:http://comments.gmane.org/gmane.linux.uml.devel/12200

diff –git a/arch/um/sys-x86_64/stub.S b/arch/um/sys-x86_64/stub.S
index 6d9edf9..20e4a96 100644
— a/arch/um/sys-x86_64/stub.S
+++ b/arch/um/sys-x86_64/stub.S
@@ -1,7 +1,7 @@
#include “as-layout.h”
.globl syscall_stub
-.section .__syscall_stub, “x”
+.section .__syscall_stub, “ax”
syscall_stub:
syscall
/* We don’t have 64-bit constants, so this constructs the address
3,模块插入错误:
[root@localhost ~]# insmod test.ko
[ 3120.390000] test: Unknown symbol memcpy
[ 3120.390000] test: Unknown symbol _GLOBAL_OFFSET_TABLE_
insmod: error inserting ‘test.ko': -1 Unknown symbol in module
[root@localhost ~]#
解决:https://dev.openwrt.org/browser/branches/backfire/target/linux/uml/patches-2.6.30/003-fix_memcpy_export_on_x86_64.patch?rev=21295
arch/um/os-Linux/user_syms.c
a b
23 23 EXPORT_SYMBOL(strstr);
24 24 #endif
25 25
26 — #ifndef __x86_64__
++ 26 #if !defined(__x86_64) || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || (__GNUC__ < 4) 27 27 extern void *memcpy(void *, const void *, size_t); 28 28 EXPORT_SYMBOL(memcpy); 29 29 #endif _GLOBAL_OFFSET_TABLE_的问题解决: 不要有-fPIC编译选项或者直接设置-fno-pic https://github.com/LeeDroid-/Flyer-2.6.35/commit/778422912da1042b9febb59a8786718628e93487
-CFLAGS_MODULE = $(MODFLAGS)
+CFLAGS_MODULE = $(MODFLAGS) -fno-pic
4,模块插入错误:
出现另外的错误(如果设置的内存大于等于504M):
[root@localhost tmp]# insmod test.ko
[ 605.820000] overflow in relocation type 11 val 1a0b93b40
[ 605.820000] `test’ likely not compiled with -mcmodel=kernel
insmod: error inserting ‘test.ko': -1 Invalid module format
[root@localhost tmp]#
解决:貌似这是UML本身bug,把内核设置为小于504M吧。
5,运行警告:
IRQ 5/eth1: IRQF_DISABLED is not guaranteed on shared IRQs
解决:
http://comments.gmane.org/gmane.linux.uml.devel/12098
—–
— arch/um/drivers/net_kern.c.orig 2009-03-11 21:16:36.000000000 +0100
+++ arch/um/drivers/net_kern.c 2009-03-11 21:16:46.000000000 +0100
-165,7 +165,7
}
err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt,
– IRQF_DISABLED | IRQF_SHARED, dev->name, dev);
+ IRQF_SHARED, dev->name, dev);
if (err != 0) {
printk(KERN_ERR “uml_net_open: failed to get irq(%d)\n”, err);
err = -ENETUNREACH;
6,编译错误:
[root@localhost ~]$ make linux ARCH=um
make[1]: `arch/um/sys-x86_64/user-offsets.s’ is up to date.
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-um
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
CC arch/um/os-Linux/mem.o
arch/um/os-Linux/mem.c: In function ‘create_tmp_file’:
arch/um/os-Linux/mem.c:216: error: implicit declaration of function ‘fchmod’
make[1]: *** [arch/um/os-Linux/mem.o] Error 1
make: *** [arch/um/os-Linux] Error 2
[root@localhost ~]$
解决:在源文件mem.c内加入#include 即可。
http://moodlearchive.epfl.ch/2010-2011/mod/forum/discuss.php?d=108781
在对应的源文件里包含即可。
7,gdb提示:Program received signal SIGTRAP, Trace/breakpoint trap.
在gdb调试里执行如下命令:
handle SIGSEGV pass nostop noprint
handle SIGUSR1 pass nostop noprint
handle SIGTRAP pass nostop noprint
六,UML的网络支持:这个还是比较多的,这在内核选项里可以看到:make menuconfig ARCH=um
[*] Networking support —>
UML Network Devices —>
[*] Virtual network device
[*] Ethertap transport
[*] TUN/TAP transport
[*] SLIP transport
[*] Daemon transport
[ ] VDE transport
[*] Multicast transport
[*] pcap transport
[*] SLiRP transport
但需要如下两个工具:
http://sourceforge.net/projects/tunctl/files/
http://user-mode-linux.sourceforge.net/uml_utilities_20070815.tar.bz2
七,UML对SMP支持:
这个从UML的邮件列表来看,x86 估计是直接支持的:
http://thread.gmane.org/gmane.linux.kernel/326919/focus=327289
http://thread.gmane.org/gmane.linux.uml.devel/9298/focus=9301
而x86-64下估计有问题:
http://thread.gmane.org/gmane.linux.kernel/326919
http://thread.gmane.org/gmane.linux.uml.devel/12206/focus=12209
http://article.gmane.org/gmane.linux.kernel/235089/match=smp
http://thread.gmane.org/gmane.linux.kernel/600015
但我并未做实际验证,所以对此尚且不太清楚。

转载请保留地址:http://www.lenky.info/archives/2012/04/1471http://lenky.info/?p=1471


备注:如无特殊说明,文章内容均出自Lenky个人的真实理解而并非存心妄自揣测来故意愚人耳目。由于个人水平有限,虽力求内容正确无误,但仍然难免出错,请勿见怪,如果可以则请留言告之,并欢迎来讨论。另外值得说明的是,Lenky的部分文章以及部分内容参考借鉴了网络上各位网友的热心分享,特别是一些带有完全参考的文章,其后附带的链接内容也许更直接、更丰富,而我只是做了一下归纳&转述,在此也一并表示感谢。关于本站的所有技术文章,欢迎转载,但请遵从CC创作共享协议,而一些私人性质较强的心情随笔,建议不要转载。

法律:根据最新颁布的《信息网络传播权保护条例》,如果您认为本文章的任何内容侵犯了您的权利,请以Email或书面等方式告知,本站将及时删除相关内容或链接。

  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须在 登录 后才能发布评论.