Can two instances of the same VM run safely?

This is for discussing general topics about how to use VirtualBox.
Post Reply
spurvis
Posts: 3
Joined: 5. May 2011, 19:40
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP

Can two instances of the same VM run safely?

Post 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.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

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

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
spurvis
Posts: 3
Joined: 5. May 2011, 19:40
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP

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

Post 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.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

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

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
spurvis
Posts: 3
Joined: 5. May 2011, 19:40
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP

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

Post by spurvis »

Thanks for tip! I was thinking of a script but was not aware of the RDP functionality.
Post Reply