In this entry, I will demonstrate how to use the new feature of
VirtualBox version 3.1 Migration (a.k.a teleporting) for moving a
virtual machine over a network from one VirtualBox host to another,
while the virtual machine is running.
Introduction to VirtualBox
VirtualBox is a general-purpose full virtualizer for x86 hardware.
Targeted at server, desktop and embedded use, it is now the only
professional-quality virtualization solution that is also Open Source
Introduction to Teleporting
Teleporting requires that a machine be currently running on one host,
which is then called the "source". The host to which the virtual
machine will be teleported will then be called the "target". The
machine on the target is then configured to wait for the source to
contact the target. The machine's running state will then be
transferred from the source to the target with minimal downtime.
This works regardless of the host operating system that is running on
the hosts: you can teleport virtual machines between Solaris and Mac
hosts, for example.
Architecture layout :
1. The target and source machines should both be running VirtualBox version 3.1or later.
2. The target machine must be configured with the same amount of memory
(machine and video memory) and other hardware settings, as the source
machine. Otherwise teleporting will fail with an error message.
3. The two virtual machines on the source and the target must share the same storage
they either use the same iSCSI targets or both hosts have access to the same storage via NFS or SMB/CIFS.
4. The source and target machines cannot have any snapshots.
5. The hosts must have fairly similar CPUs. Teleporting between Intel and AMD CPUs will probably fail with an error message.
Preparing the storage environment
For this example, I will use OpenSolaris x86 as CIFS server in order to
enable shared storage for the source and target machines ,but you can
use any iSCSI NFS or CIFS server for this task.
Install the packages from the OpenSolaris.org repository:
# pfexec pkg install SUNWsmbs SUNWsmbskr
Reboot the system to activate the SMB server in the kernel.
# pfexec reboot
Enable the CIFS service:
# pfexec svcadm enable –r smb/server
If the following warning is issued, you can ignore it:
svcadm: svc:/milestone/network depends on svc:/network/physical, which has multiple instances
Verified the service
# pfexec svcs smb/server
STATE STIME FMRI
online 8:38:22 svc:/network/smb/server:default
The Solaris CIFS SMB service uses WORKGROUP as the default group. If
the workgroup needs to be changed, use the following command to change
the workgroup name:
# pfexec smbadm join –w workgroup-name
Next edit the /etc/pam. conf file to enable encrypted passwords to be used for CIFS.
Add the following line to the end of the file:
other password required pam_smb_passwd. so. 1 nowarn
# pfexec echo "other password required pam_smb_passwd.so.1 nowarn" >> /etc/pam.conf
Each user currently in the /etc/passwd file needs to re-encrypt to be able to use the CIFS service:
# pfexec passwd user-name
Note - After the PAM module is installed, the passwd command
automatically generates CIFS-suitable passwords for new users. You must
also run the passwd command to generate CIFS-style passwords for
Create mixed-case ZFS file system.
# pfexec zfs create -o casesensitivity=mixed rpool/vboxstorage
Enable SMB sharing for the ZFS file system.
# pfexec zfs set sharesmb=on rpool/vboxstorage
Verify how the file system is shared.
# pfexec sharemgr show -vp
Now, you can access the share by connecting to \\\\solaris-hostname\\share-name
Create new Virtual machine, for the virtual hard disk select “Create new hard disk” then select next
Select the next button
For the disk location enter the network drive that you mapped from the previous section then press the next button
Verify the disk settings and then press
the finish button
Continue with the Install process ,after finishing the install process shutdown the Virtual machine in order to avoid any storage locking.
On the target machine :
Map the same network drive
Configure a new virtual machine but
instead of selecting “Create new hard drive” select use “Use existing hard drive”.
In the Virtual Media Manger window
select the Add button,and point to the same location as the
source machine hard drive ( the network drive).
Don't start the Virtual machine yet.
To wait for a teleport request to arrive when it is started,use the following VBoxManage command:
VBoxManage modifyvm <targetvmname> --teleporter on --teleporterport <port>
where <targetvmname> is the name of the virtual machine on the
target in this use case opensolaris ,and <port> is a TCP/IP
port number to be used on both the source and the target. In this example, I used port 6000.
C:\\Program Files\\Sun\\VirtualBox>VBoxManage modifyvm opensolaris --teleporter on --teleporterport 6000
Next, start the VM on the target. You will see that instead of actually
running, it will show a progress dialog. indicating that it is waiting
for a teleport request to arrive.
You can see that the machine status changed to Teleporting
On the source machine:
Start the Virtual machine
When it is running and you want it to be teleported, issue the following command :
VBoxManage controlvm <sourcevmname> teleport --host <targethost> --port <port>
where <sourcevmname> is the name of the virtual machine on the
source (the machine that is currently running), <targethost> is
the host or IP name of the target that has the machine that is waiting
for the teleport request, and <port> must be the same number as
specified in the command on the target (i.e. for this example: 6000).
C:\\Program Files\\Sun\\VirtualBox>VBoxManage controlvm opensolaris teleport --host target_machine_ip --port 6000
VirtualBox Command Line Management Interface Version 3.1.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
You can see that the machine status changed to Teleported
The teleporting process took ~5 seconds
For more information about VirtualBox