操作系统:Ubuntu Server 20.04 LTS 64bit
一、安装流程
#1.下载&解压
# wget https://download.qemu.org/qemu-3.1.0.tar.xz
# tar -xvf qemu-3.1.0.tar.xz
#2.配置
cd /qemu-3.1.0
# prefix可设置安装路径,默认路径为/usr/local
./configure
#3.编译&安装
make && make install
二、问题&解决
配置时报错:ERROR: glib-2.40 gthread-2.0 is required to compile QEMU
解决:安装2.40以上版本的glib 和 2.0以上的gthread
apt-cache search glib2 # 查找glib2应该安装哪个库
apt-get install libglib2.0-dev
配置时报错:ERROR: pixman >= 0.21.8 not present.
解决:安装pixman-devel的gthread
apt-cache search pixman # 查找pixman应该安装哪个库
apt-get install libpixman-1-dev
搭建QEMU-native模块报错:
.../qemu-version/linux-user/syscall.c:253:16: error: static declaration of ‘gettid’ follows non-static declaration
253 | _syscall0(int, gettid)
^~~~~~~
.../qemu/linux-user/syscall.c:184:13: note: in definition of macro ‘_syscall0’
184 | static type name (void)
解决:gettid 需要rename 为 sys_gettid
# 文件.../qemu-version/linux-user/syscall.c中
#define TARGET_NR__llseek TARGET_NR_llseek
#endif
- _syscall0(int, gettid)
+ #define __NR_sys_gettid __NR_gettid
+ _syscall0(int, sys_gettid)
--------------------------------------------
ts = (TaskState *)cpu->opaque;
- info->tid = gettid();
+ info->tid = sys_gettid();
task_settid(ts);
--------------------------------------------
if (flags & CLONE_CHILD_SETTID)
- put_user_u32(gettid(), child_tidptr);
+ put_user_u32(sys_gettid(), child_tidptr);
if (flags & CLONE_PARENT_SETTID)
- put_user_u32(gettid(), parent_tidptr);
+ put_user_u32(sys_gettid(), parent_tidptr);
ts = (TaskState *)cpu->opaque;
--------------------------------------------
case TARGET_NR_gettid:
- return get_errno(gettid());
+ return get_errno(sys_gettid());
#ifdef TARGET_NR_readahead
搭建QEMU-native模块报错:
.../qemu-version/linux-user/ioctls.h:174:9: error: ‘SIOCGSTAMPNS’ undeclared here (not in a function); did you mean ‘SIOCGSTAMP_OLD’?
174 | IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
| ^~~~
解决:在 .../qemu-version/linux-user/syscall.c中添加头文件<linux/sockios.h>
# 文件.../qemu-version/linux-user/syscall.c中
#include <sys/socket.h>
+ #include <linux/sockios.h>
#include <sys/un.h>
链接时报错:
.../qemu-version/linux-user/syscall.c:7657: undefined reference to 'stime'
| collect2: error: ld returned 1 exit status
解决:在 .../qemu-version/linux-user/syscall.c 中修改stime函数调用
# 文件.../qemu-version/linux-user/syscall.c中
return -TARGET_EFAULT;
- return get_errno(stime(&host_time));
+ return get_errno(clock_settime(CLOCK_REALTIME, &host_time));
参考资料
https://blog.csdn.net/sukysun...
https://blog.csdn.net/fuxy3/a...
https://blog.csdn.net/xiaoqia...
https://blog.csdn.net/geniusl...
https://github.com/google/AFL...
https://patchwork.kernel.org/...
https://lkml.org/lkml/2019/6/...
https://lists.openembedded.or...,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,73197049
https://blog.csdn.net/pk_2014...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。