Skip to contentSkip to conversation

Inter-domain shared memory facility in Xen?

DISCUSSION David Stone 6 participants 9 messages Oct 30, 2007 – Dec 3, 2007 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hopefully this question belongs in xen-devel and not xen-users:

Is there any kind of inter-domain shared memory facility in Xen? E.g. an API callable from DomU user-mode that would cause the system sets up two DomU's page tables so they a range of virtual addresses in both resolve to the same set of machine pages?

Thanks,
Dave

#1 lore raw

Hi,

Quoted 6 lines

Hopefully this question belongs in xen-devel and not xen-users:

Is there any kind of inter-domain shared memory facility in Xen? E.g. an API callable from DomU user-mode that would cause the system sets up two DomU's page tables so they a range of virtual addresses in both resolve to the same set of machine pages?

You may be able to use grant table.
Grant table can make shared memroy.

If you want to share memory between dom0 and domU, you can use the following fanction.

1. HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref) and gnttab_grant_foreign_access()
It is kernel API used in blk split driver.

2. xc_map_foreign_range()
It is dom0 user API used in xc_core.c.
It can share memory between dom0 user vaddr and domU guest maddr.

If you want to share memory between domU user vaddr and the other domU's, you need to make the API.

Best Regards,

Akio Takebe

#2 lore raw

Hi,

I had a similar question on another email thread and I have a following question.
If I understand correctly, I need to change the kernels of domUs to make the sharing happen (explicitly call those APIs). Is it possible to do the sharing without
changing domUs? In another word, is it possible to let Xen, the hypervisor, to perform the sharing transparently without modifying domUs. For example, Xen can share all the identical pages among domUs and apply Copy-On-Write on them. I guess, it requires changes inside the Xen's memory management. Any suggestion on how it may be possible?

Thanks

Haifeng

Quoted 35 lines · Akio Takebe

Hi,

Quoted 6 lines

Hopefully this question belongs in xen-devel and not xen-users:

Is there any kind of inter-domain shared memory facility in Xen? E.g. an API callable from DomU user-mode that would cause the system sets up two DomU's page tables so they a range of virtual addresses in both resolve to the same set of machine pages?

You may be able to use grant table.
Grant table can make shared memroy.

If you want to share memory between dom0 and domU, you can use the following fanction.

1. HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref) and gnttab_grant_foreign_access()
It is kernel API used in blk split driver.

2. xc_map_foreign_range()
It is dom0 user API used in xc_core.c.
It can share memory between dom0 user vaddr and domU guest maddr.

If you want to share memory between domU user vaddr and the other domU's, you need to make the API.

Best Regards,

Akio Takebe

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

Hi,

http://sourceforge.net/projects/xvmsocket/
http://xen.xensource.com/files/xensummit_4/SuzanneMcIntosh_XenSummit_2007.pdf
See XenSocket. I think it is your help.

http://lists.xensource.com/archives/html/xen-devel/2007-05/msg00122.html
Xway is also the similar facility.

Best Regards,

Akio Takebe

Quoted 53 lines

Hi,

I had a similar question on another email thread and I have a following question.
If I understand correctly, I need to change the kernels of domUs to make the sharing happen (explicitly call those APIs). Is it possible to do the sharing without
changing domUs? In another word, is it possible to let Xen, the hypervisor, to perform the sharing transparently without modifying domUs. For example, Xen can share all the identical pages among domUs and apply Copy-On-Write on them. I guess, it requires changes inside the Xen's memory management. Any suggestion on how it may be possible?

Thanks

Haifeng

Quoted 35 lines · Akio Takebe

Hi,

Quoted 6 lines

Hopefully this question belongs in xen-devel and not xen-users:

Is there any kind of inter-domain shared memory facility in Xen? E.g. an API callable from DomU user-mode that would cause the system sets up two DomU's page tables so they a range of virtual addresses in both resolve to the same set of machine pages?

You may be able to use grant table.
Grant table can make shared memroy.

If you want to share memory between dom0 and domU, you can use the following fanction.

1. HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref) and gnttab_grant_foreign_access()
It is kernel API used in blk split driver.

2. xc_map_foreign_range()
It is dom0 user API used in xc_core.c.
It can share memory between dom0 user vaddr and domU guest maddr.

If you want to share memory between domU user vaddr and the other domU's, you need to make the API.

Best Regards,

Akio Takebe

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

(Forgot to include the list)

---------- Forwarded message ----------
From: David Stone <[email protected]>
Date: Nov 1, 2007 9:39 AM
Subject: Re: [Xen-devel] Inter-domain shared memory facility in Xen?
To: Akio Takebe <[email protected]>

Thanks for your help on this. So based on your responses I just want to confirm my understanding is correct...is it true that:

1. It is currently possible to establish shared memory between Dom0 and DomU, but
2. It is currently not possible to establish shared memory between two DomUs in an released Xen versions, nor the current xen-unstable branch nor any other branch on http://xenbits.xensource.org. There are projects that address this that you mentioned though.

Thanks again,
Dave

Quoted 6 lines

http://sourceforge.net/projects/xvmsocket/
http://xen.xensource.com/files/xensummit_4/SuzanneMcIntosh_XenSummit_2007.pdf
See XenSocket. I think it is your help.

http://lists.xensource.com/archives/html/xen-devel/2007-05/msg00122.html
Xway is also the similar facility.

#6 lore raw
Quoted 9 lines · David Stone

Thanks for your help on this. So based on your responses I just want to confirm my understanding is correct...is it true that:

1. It is currently possible to establish shared memory between Dom0 and DomU, but
2. It is currently not possible to establish shared memory between two DomUs in an released Xen versions, nor the current xen-unstable branch nor any other branch on http://xenbits.xensource.org. There are projects that address this that you mentioned though.

i did not follow this discussion until now, but are you aware of the grant table facility part of the PV interface?

xensocket and xway are projects targeting sockets-based APIs. grant table ops are, like all hypercalls, a kernel-level interface, but the xen-specific modules in dom0 as well as the control libraries already contain some code to let userland use it.

regarding item 2.: no, shared memory can be established between arbitrary domains. otherwise, the sockets interfaces could not work, right? grants work about as follows: dom1 'grants' a page to dom2, which creates a 'grant reference'. that grant reference can be used by dom2 to (map|transfer) that page into its respective own address space(s).

this is what e.g. the pv driver codebase is using for bulk data transfers. similarly, a userland interface may be built to e.g. implement something similar to posix shm on top of it. if that is what you need.

not sure what exactly you're looking for, though.

grant refs are concisely described in the interface manual.

regards,
dns

Signature · 3 lines
[email protected]

Wire up your home and stay there.
#7 lore raw
In reply to David Stone
Quoted 9 lines · David Stone

Thanks for your help on this. So based on your responses I just want to confirm my understanding is correct...is it true that:

1. It is currently possible to establish shared memory between Dom0 and DomU, but
2. It is currently not possible to establish shared memory between two DomUs in an released Xen versions, nor the current xen-unstable branch nor any other branch on http://xenbits.xensource.org. There are projects that address this that you mentioned though.

It *is* possible to establish shared memory between two DomUs, using the grant table mechanism. At present, it is only possible to grant access to memory from a VM kernel, but it is possible to map that granted memory into either the kernel (using the kernel wrappers to the necessary hypercalls) or user-space (using gntdev, the user-space granted memory driver).

Up to and including the current stable release (3.1.1), it is only possible for domains that have I/O memory permissions (typically only Dom0) to map granted pages. Therefore, it is necessary to give some dummy permissions to any domain that you want to allow to map grants. However, the issue that led to this restriction has been fixed in the current version of xen-unstable.

As I understand it, the other projects that were mentioned provide a socket-like communication mechanism for Xen, with the advantage that they do not (necessarily) use the networking stack. I presume that you are looking for something simpler, such as creating a shared data structure between two or more domains. In that case, the mechanisms that
exist in Xen today and that I have described above are sufficient for
your needs.

Regards,

Derek Murray.

#8 lore raw

Thanks guys, I'm clear now.

Quoted 37 lines · Derek Murray
Quoted 9 lines · David Stone

Thanks for your help on this. So based on your responses I just want to confirm my understanding is correct...is it true that:

1. It is currently possible to establish shared memory between Dom0 and DomU, but
2. It is currently not possible to establish shared memory between two DomUs in an released Xen versions, nor the current xen-unstable branch nor any other branch on http://xenbits.xensource.org. There are projects that address this that you mentioned though.

It *is* possible to establish shared memory between two DomUs, using the grant table mechanism. At present, it is only possible to grant access to memory from a VM kernel, but it is possible to map that granted memory into either the kernel (using the kernel wrappers to the necessary hypercalls) or user-space (using gntdev, the user-space granted memory driver).

Up to and including the current stable release (3.1.1), it is only possible for domains that have I/O memory permissions (typically only Dom0) to map granted pages. Therefore, it is necessary to give some dummy permissions to any domain that you want to allow to map grants. However, the issue that led to this restriction has been fixed in the current version of xen-unstable.

As I understand it, the other projects that were mentioned provide a socket-like communication mechanism for Xen, with the advantage that they do not (necessarily) use the networking stack. I presume that you are looking for something simpler, such as creating a shared data structure between two or more domains. In that case, the mechanisms that
exist in Xen today and that I have described above are sufficient for
your needs.

Regards,

Derek Murray.

#9 lore raw

A couple of my longterm personal projects involve interdomain shared memory too.

One of these is a Xen version of the IBM zSeries DCSS (which is basically a big lump of shared memory, which can optionally be used as a disk). The other is XenFS which presents a filesystem interface.

The end goal for either of those would include the ability to share userspace application memory between domains using just an mmap() call, but I've not got that working yet ;-)

Cheers,
Mark

Quoted 44 lines · David Stone

Thanks guys, I'm clear now.

Quoted 33 lines · Derek Murray
Quoted 9 lines · David Stone

Thanks for your help on this. So based on your responses I just want to confirm my understanding is correct...is it true that:

1. It is currently possible to establish shared memory between Dom0 and DomU, but
2. It is currently not possible to establish shared memory between two DomUs in an released Xen versions, nor the current xen-unstable branch nor any other branch on http://xenbits.xensource.org. There are projects that address this that you mentioned though.

It *is* possible to establish shared memory between two DomUs, using the grant table mechanism. At present, it is only possible to grant access to memory from a VM kernel, but it is possible to map that granted memory into either the kernel (using the kernel wrappers to the necessary hypercalls) or user-space (using gntdev, the user-space granted memory driver).

Up to and including the current stable release (3.1.1), it is only possible for domains that have I/O memory permissions (typically only Dom0) to map granted pages. Therefore, it is necessary to give some dummy permissions to any domain that you want to allow to map grants. However, the issue that led to this restriction has been fixed in the current version of xen-unstable.

As I understand it, the other projects that were mentioned provide a socket-like communication mechanism for Xen, with the advantage that they do not (necessarily) use the networking stack. I presume that you are looking for something simpler, such as creating a shared data structure between two or more domains. In that case, the mechanisms that
exist in Xen today and that I have described above are sufficient for
your needs.

Quoted 3 lines

Regards,

Derek Murray.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!