How Does vMotion Work?

|

,

If you need to take a host offline for maintenance, you can move the virtual machine to another host. Migration with vMotion™ allows virtual machine processes to continue working throughout a migration.

With vMotion, you can change the host on which a virtual machine is running, or you can change both the host and the datastore of the virtual machine.

When you migrate virtual machines with vMotion and choose to change only the host, the entire state of the virtual machine is moved to the new host. The associated virtual disk remains in the same location on storage that is shared between the two hosts.

When you choose to change both the host and the datastore, the virtual machine state is moved to a new host and the virtual disk is moved to another datastore. vMotion migration to another host and datastore is possible in vSphere environments without shared storage.

After the virtual machine state is migrated to the alternate host, the virtual machine runs on the new host. Migrations with vMotion are completely transparent to the running virtual machine.

The state information includes the current memory content and all the information that defines and identifies the virtual machine. The memory content includes transaction data and the bits of the operating system and applications that are in the memory. The defining and identification information stored in the state includes all the data that maps to the virtual machine hardware elements, such as BIOS, devices, CPU, MAC addresses for the Ethernet cards, chip set states, registers, and so forth.

When you migrate a virtual machine with vMotion, the new host for the virtual machine must meet compatibility requirements so that the migration can proceed.

Below are the steps:

Source host esx01 VM running Destination host esx02 shadow VM 1. Compatibility check (CPU / EVC, networks, storage) 2. Create shadow VM, reserve CPU + memory 3. Start dirty-page tracking, copy all memory 4. Re-send pages dirtied meanwhile (repeat) 5. Remaining set small: stun VM briefly 6. Copy last pages + CPU / device state 7. Resume on destination, RARP to physical switch 8. Power off and remove source VM process physical switch vMotion traffic uses the vmkernel port tagged for vMotion; shared or non-shared storage both supported.
Iterative memory pre-copy in vMotion: the VM is paused only for the final small copy.
  1. The first step is to ensure that the source VM can be operated on the chosen destination server (compatible CPU features, using EVC if the CPU generations differ, and a VMkernel adapter with the vMotion service enabled on both hosts, ideally on a dedicated vMotion network rather than the management network).
  2. Then a second VM process is started on the target host and the resources are reserved.
  3. Next, a system memory checkpoint is created. This means all changes to the source VM are written to an extra memory area.
  4. The contents of the system memory recorded at the checkpoint are transferred to the target VM(on the destination host).
  5. The checkpoint/checkpoint-restore process is repeated until only the smallest change sets remain in the target VM’s memory.
  6. The CPU of the source VM is stopped.
  7. The last modifications to the main memory are transferred to the target VM in milliseconds.
  8. The vMotion process is ended and a reverse ARP packet is sent to the physical switch (important: Notify Switches must be activated in the properties of the virtual switch). Hard disk access is taken over by the target ESX.
  9. The source VM is shut down. This means the VM process on the source ESXi is deleted.

A very good article on troubleshooting vMotion issues is Understanding and troubleshooting vMotion (Broadcom KB, formerly 1003734). For a longer walk-through see vMotion Deep Dive: How It Works.

One response

  1. Anonymous

    5

Leave a Reply