首页 新闻 搜索 专区 学院

Xen内存共享

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-10-08 18:23

有人知道Xen么?

实现两个domain之间的内存共享下面是offer虚拟机和map虚拟机的代码,求大神讲解

void offer_page()
{
uint16_t flags;
/* Create the grant table */
gnttab_setup_table_t setup_op;

setup_op.dom = DOMID_SELF;
setup_op.nr_frames = 1;
setup_op.frame_list = grant_table;

HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup_op, 1);

/* Offer the grant */
grant_table[0].domid = DOMID_FRIEND;
grant_table[0].frame = shared_page >> 12;
flags = GTF_permit_access & GTF_reading & GTF_writing;
grant_table[0].flags = flags;
}

 

grant_handle_t map(domid_t friend,
unsigned int entry,
void * shared_page,
grant_handle_t * handle)
{
/* Set up the mapping operation */
gnttab_map_grant_ref_t map_op;
map_op.host_addr = shared_page;
map_op.flags = GNTMAP_host_map;
map_op.ref = entry;
map_op.dom = friend;
/* Perform the map */
HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op,1);
/* Check if it worked */
if(map_op.status != GNTST_okay)
{
return -1;
}
else
{
/* Return the handle */
*handle = map_op.handle;
return 0;
}
}

Albery的主页 Albery | 菜鸟二级 | 园豆:207
提问于:2015-07-17 22:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册