Usually, this is fine. However, there are times when you may wish to control how the Guest operates. This could be for a variety of testing reasons, particularly with Edge-Case Testing.
For example, Active Directory Authentication, Mirroring and Witnesses, Replication, Clustering, etc. In each of these applications, if the servers involved get beyond five minutes from one another, they may cease to operate normally.
By disabling time synchronization between the Host and the Guest, you will be able to move each servers' time backwards and forwards while you observe how they behave. Will your application continue to function? Will you be able to trap error messages and inform the user?
VirtualBox includes a command-line utility, VBoxManage, that will allow you to control every aspect of your Guest VMs.
On a Windows host you will find this in the following directory: C:\Program Files\Oracle\VirtualBox
|VirtualBox Manage List VMs|
This example lists all the VMs that you have defined on your VirtualBox installation.
.vbox Configuration Files
Before we dive into this utility, another piece we need to look at are the VirtualBox Machine Definition Files. These are XML file which control how your Guest VMs operate. Basically, when you use the GUI to setup and control your VM, all the various settings are stored here.
On my Host, these files are stored in C:\Users\<USERNAME>VirtualBox VMs
You will see one directory for each VM that you have defined. Within that folder you will see a file with the .vbox extension. Before we go too much further, go ahead and make a copy of that file. This way, if something happens while you are working with it, you can restore your VM's configuration.
Now, use Notepad to open the .vbox file and poke around a bit. Just be careful not to modify anything yet, that comes later. You should see something like this...
|VirtualBox Configuration File|
This is an XML file that contains all the configuration information for your VM.
Let's go take a look at a couple of sections and see what they do.
As you might guess, this section contains 'extra' data about your Guest VM.
|Extra Data Section Before|
And this section contains information on how the virtual BIOS operates.
|BIOS Section Before|
OK, now that we've seen that, it's time to get to work.
Disable Time Synchronization
First, let's turn off Time Synchronization.
VBoxManage SetExtraData "YOURVMNAME" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"
Note, if your VM has spaces in its name, then surround it with quotes.
If you want to turn Time Synchronization back on, use a '0'.
VBoxManage SetExtraData "YOURVMNAME" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"
If you don't remember the names of all your VMs, try this first.
OK, let get down to business. To turn off Time Synchronization, use this command:
|Disable Time Sync Command|
Now, the Extra Data section of your .vbox file should look like this.
|Extra Data Section After|
So now when you start your VM, you will be able to change the Date and Time. Presumably, one could simply edit the .vbox file to make this change.
OK, but what if you would like your VM to start with a different time. That's easy to do, as well. For this step, there isn't a command-line option, so we need to edit the .vbox file manually.
Find the BIOS section, then edit the TimeOffset line with something similar...
It should look like this when done.
|BIOS Section After|
The number represents milliseconds so adjust as necessary for your needs. Also, the number can be positive or negative.
Et voila! Your Guest VM now has a completely different time from your Host.