shared memory between VMs?

This is for discussing general topics about how to use VirtualBox.
Post Reply
logicprobe
Posts: 3
Joined: 22. Feb 2017, 21:39

shared memory between VMs?

Post by logicprobe »

I want to model a HPC cluster that enables one node (i.e. a VM) to directly access another node's memory. This sort of functionality will be enabled by chip-to-chip interconnects such as CCIX, OpenCAPI, and Gen-Z.

Is it possible to share memory between virtual machines?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: shared memory between VMs?

Post by scottgus1 »

I have not read anything in the manual that says Virtualbox has the capability to let guests access the data in each others' memory.

Just in case you read through the manual and come across it, there is a "memory balloon" system that can switch guest-designated memory between running guests, but I don't think the contents of the memory remain available for the next guest to use. And the balloon switching is automatic, not user-scriptable. I don't think the balloon will do what you want.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: shared memory between VMs?

Post by socratis »

logicprobe wrote:This sort of functionality will be enabled by chip-to-chip interconnects such as CCIX, OpenCAPI, and Gen-Z.
That's really, really special hardware you're talking about. VirtualBox emulate a standard PC, and one that's less powerful than your actual computer. Simple answer; no.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
logicprobe
Posts: 3
Joined: 22. Feb 2017, 21:39

Re: shared memory between VMs?

Post by logicprobe »

Thanks for your comments, but I'm not looking for emulation of "special hardware"; I want to share a handful of memory pages among two or more VMs. This can be done today with libfabric and the sockets provider, but it's not real shared memory; I'm looking for a more direct method ahead of the special hardware being available.
Last edited by socratis on 22. Feb 2017, 23:46, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: shared memory between VMs?

Post by socratis »

logicprobe wrote:I'm not looking for emulation of "special hardware"
All the references to what you want to work with are about specialized hardware. And you said so in the last part of your reply: "ahead of the special hardware being available."
logicprobe wrote:I want to share a handful of memory pages
I don't believe that the amount is relevant at this point. It's the if and the how.
logicprobe wrote:This can be done today with libfabric and the sockets provider
Well if you could do it with two right-off-the-shelf computers, I guess you can try that recipe in VirtualBox. I'm not familiar with that library, so I can't comment anymore.
logicprobe wrote:I'm looking for a more direct method ahead of the special hardware being available.
As I said, VirtualBox emulates a standard PC. If you can get two standard PCs to do what you want, you may be able to do it in VirtualBox.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
logicprobe
Posts: 3
Joined: 22. Feb 2017, 21:39

Re: shared memory between VMs?

Post by logicprobe »

Maybe a custom virtual device that two VMs could use simultaneously? Is that possible in VirtualBox?
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: shared memory between VMs?

Post by socratis »

Not that I know of. The only "device", that I know of, that could be shared between two VMs is a special mode of a virtual disk image, known as "Shareable hard disks". I'll quote the whole reference from the manual Ch. 5.4 Special image write modes, since it's a paragraph long only:
Shareable hard disks are a variant of write-through hard disks. In principle they behave exactly the same, i.e. their state is not saved when a snapshot is taken, and not restored when a snapshot is restored. The difference only shows if you attach such disks to several VMs. Shareable disks may be attached to several VMs which may run concurrently. This makes them suitable for use by cluster filesystems between VMs and similar applications which are explicitly prepared to access a disk concurrently. Only fixed size images can be used in this way, and dynamically allocated images are rejected.
This is an expert feature, and misuse can lead to data loss – regular filesystems are not prepared to handle simultaneous changes by several parties.
Now if you make a RAM disk, turn it into a write-through image, attach it to both VMs, and write a small program that dumps/reads the contents of the memory to/from that disk, you could (in theory) make something work. But, as I said, that's in theory and not a very attractive solution, IMHO. And before you ask, no, I've never tried it or heard anyone else that has even attempted it.

What you're looking to achieve is very exotic and not your everyday computer task, so, it's not going to be easy, if it is doable at all...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: shared memory between VMs?

Post by scottgus1 »

I have run guests with virtual disks on a host ram disk before. Had host BSODs until I went from dynamic to fixed-size virtual disks on the ram disk. (Might not have been the issue but the BSODs stopped. And tech may have progressed, or it might have just been my ram disk program.)

Anyhoo, write-to-ram-disk is much quicker than write-to-platter-disk, or even an SSD, but no doubt not as quick as direct ram, of course. However, getting the standard OS's to both use the same disk without data loss is a big problem; allow me to reiterate the quoted warning from Socratis' post":
regular filesystems are not prepared to handle simultaneous changes
So your standard Windows guests will choke on a shared virtual disk. You'll have to get special OS's, maybe Linux based, to both read and write to the shared disk. Maybe Beowulf cluster OS's? Just a guess.

If you were planning such a shared environment with usual OS's, I'd say the only safe thing would be to put a shared folder in the host ram disk then have the guests access that.

Essentially, you need to figure out how to solve your problem with two or more physical PCs standing side by side, then you can solve the problem the same way in Virtualbox.
thingsto
Posts: 1
Joined: 19. Mar 2017, 17:15

Re: shared memory between VMs?

Post by thingsto »

As far as I know if you run both VMs in the same time you cannot access other VM memory, however it might be possible but it needs a lot of customization and also special hardware.
Post Reply