xen 添加hypercall
来源:互联网 发布:傻瓜记账软件 编辑:程序博客网 时间:2024/05/20 04:28
在linux系统中添加新的系统调用,一般需要三个步骤:
1.
2. 更新系统调用表
3.
在xen中添加一个 hypercall,类似于在linux中添加一个系统调. 基本上也是上面几个步骤。
现在举个具体的例子:
比如我们要在xen中添加一个打印消息的hypercall,参数有一个,类型为char*, 代表我们要打印的消息.函数原型为:
do_print_string(char*message),xen中原有37个hypercall,因此我们添加的超级调用号为38.
1. 首先注册一个hypercall调用号。
xen/include/public/xen.h
+#define__HYPERVISOR_print_string
2.更新系统调用表
/xen/arch/x86/x86_32/entry.S
ENTRY(hypercall_table)
+
ENTRY(hypercall_args_table)
+
3. 定义函数头文件
/xen/include/asm-x86/hypercall.h
extern int
do_kexec(
+extern int
+do_print_string(char * message);
4.定义函数(函数定义在合适的文件中,这个例子采用mm.c)
/xen/arch/x86/mm.c
int do_print_string(char * message)
{
}
OK.
重新编译安装
make dist
make install
重新制作img
mkinitrd -v -f initrd-2.6.18.8-xen.img 2.6.18.8-xen
重启
然后编辑一个.c file, 在用户空间测试新的hypercall.如下:
(xen提供了privcmd这个驱动文件,从而在3环(用户空间)可以利用ioctl来调用hypercall)
- #include
<stdio.h> - #include
<stdlib.h> - #include
<errno.h> - #include
<sys/ioctl.h> - #include
<sys/types.h> - #include
<fcntl.h> - #include
<string.h> - #include
<xenctrl.h> - #include
<xen/sys/privcmd.h> - int
main( intargc, char*argv[]) - {
-
int fd, ret; -
char * message; -
if (argc != 2) { -
printf("please put );one parameter!\n" -
return -1; -
} -
message = (char *) sizeof(char)malloc( * (strlen(argv[1])+1)); -
strcpy(message, argv[1]); -
privcmd_hypercall_t hcall = { -
__HYPERVISOR_print_string, -
{message, 0, 0, 0, 0} -
}; -
fd = open("/proc/xen/privcmd", O_RDWR); -
if (fd < 0) { -
perror("open"); -
exit(1); -
} else -
printf("fd = ,%d\n" fd); -
ret = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, &hcall); -
printf("ret = ,%d\n" ret); - }
也可以采用加载模块的形式,在内核空间之间调用hypercall来测试。
编译该文件,并测试如下:
查看日志文件,检测是否新的hypercall安装成功:(linux下的log一般在/var/log/mesages,而xen下的日志采用xm dm命令查看)
OK!
- xen 添加hypercall
- xen 添加hypercall
- xen 添加hypercall
- xen 添加hypercall
- Xen添加一个hypercall
- xen 添加hypercall
- Xen添加一个hypercall
- Xen中添加hypercall
- XEN添加和调用Hypercall
- Xen添加hypercall获取page_fault次数
- XEN添加和调用Hypercall (zz)
- 【XEN学习笔记】XEN添加和调用Hypercall
- Xen HyperCall 详解
- Xen HVM hypercall
- Hypercall
- Xen虚拟机添加网卡
- Xen虚拟机添加磁盘操作方法
- xen server6.2 添加硬盘
- Android的Window类
- 59空格超简单数独题
- 嵌入式机器视觉在中国的发展趋势及主要生产商介绍
- Linux常用的网络命令
- 图像特征简介
- xen 添加hypercall
- 网络游戏demo开发实例:多人在线RPG游戏(MMO RPG)demo的开发记录(第17篇下)
- Hessian学习
- 转android Reflection 反射
- 聊天工具
- iBatis中易混概念isNull isEmpty isNotNull isNotEmpty
- 文件信息批量导入数据库(Struts2实现文件上传,POI实现Excel文件读取并写入数据库) .
- 分治_数列最大值
- 总结一下基于s3c2440开发板进行开发的一些流程