Page 1 of 1

Can two instances of the same VM run safely?

Posted: 5. May 2011, 20:01
by spurvis
I've setup a shared location on a mac (OS X 10.6) where all VMs and .vdi's reside. Although I'm using a mac, I think this applies equally well to another OS. This location can be accessed by multiple users simultaneously (fast user switching is enabled). As a result, I can login as one user and run a WinXP VM, then switch to a second user, open VirtualBox, and run the exact same WinXP VM using the same .vdi file. When I first tried this, I somewhat expected the attempt by the second user to be refused by VirtualBox, with some sort of "can't run, currently in use" message. Instead, it simply reported the VM as turned off and proceeded as usual turning it on. Is this intended/safe functionality? I feel like this situation would cause write conflicts on the .vdi and I really don't want to corrupt the .vdi file.

Re: Can two instances of the same VM run safely?

Posted: 7. May 2011, 13:25
by Sasquatch
It should have errored out already, as you would expect. But somehow, it didn't. Unless the disk is added as immutable, you can't do what you want as it would severely corrupt the file.

Re: Can two instances of the same VM run safely?

Posted: 8. May 2011, 05:40
by spurvis
How is VirtualBox supposed to protect against this, that is, multiple use of the same .vbi file? Does it attempt to lock the .vbi file so it can't be opened by other users on the system? Or does it track the status of the .vbi in another (say XML) file? If it's tracking the status in a file, maybe I just need to have both users share this same 'status' file to fix my issue. If it's attempting to lock the file from other users I have a problem as, in my setup, both users are gaining access to the file through the same shared user account. If this is the case, I'll have to find a different way to handle sharing the .vbi file.

Re: Can two instances of the same VM run safely?

Posted: 8. May 2011, 12:24
by Sasquatch
If you want to make a quick and dirty check for it, then make a shell script that will start the VM. It will have two results: first it checks if a process is already running with the name of the VM (use ps ax or whatever parameter you want to check for command line arguments of a process). If it doesn't show one, then start the VM normally using VBoxManage. If it does, then the user will start an RDP session to the VM, either through it's native RDP or through VRDP. The latter needs to be enabled in order to use it, so the ExtPack is required.

Re: Can two instances of the same VM run safely?

Posted: 8. May 2011, 16:17
by spurvis
Thanks for tip! I was thinking of a script but was not aware of the RDP functionality.