<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Themel</id>
	<title>KVM - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Themel"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/page/Special:Contributions/Themel"/>
	<updated>2026-04-22T18:31:33Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Migration&amp;diff=2318</id>
		<title>Migration</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Migration&amp;diff=2318"/>
		<updated>2009-05-26T08:33:09Z</updated>

		<summary type="html">&lt;p&gt;Themel: Removed file:// migration reference - no longer in current kvm.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Migration=&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
KVM currently supports savevm/loadvm and offline or live migration&lt;br /&gt;
Migration commands are given when in qemu-monitor (Alt-Ctrl-2).    &lt;br /&gt;
Upon successful completion, the migrated VM continues to run on the destination host.&lt;br /&gt;
&lt;br /&gt;
==== Note ====&lt;br /&gt;
You can migrate a guest between an AMD host to an Intel host and back. Naturally, a 64-bit guest can only be migrated to a 64-bit host, but a 32-bit guest can be migrated at will.&lt;br /&gt;
&lt;br /&gt;
There are some older Intel processors which don&#039;t support NX (or XD), which may cause problems in a cluster which includes NX-supporting hosts. To disable NX for a given guest, start it with such a parameter: -cpu qemu64,-nx&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
* The VM image is accessible on both source and destination hosts (located on a shared storage, e.g. using nfs).                                                                                                  &lt;br /&gt;
* It is recommended an images-directory would be found on the same path on both hosts (for migrations of a copy-on-write image -- an image created on top of a base-image using &amp;quot;qemu-image create -b ...&amp;quot;)       &lt;br /&gt;
* The src and dst hosts must be on the same subnet (keeping guest&#039;s network when tap is used).           &lt;br /&gt;
* Do not use -snapshot qemu command line option.                                                         &lt;br /&gt;
* For tcp: migration protocol                                                                            &lt;br /&gt;
* the guest on the destination must be started the same way it was started on the source.                &lt;br /&gt;
&lt;br /&gt;
== highlights / merits ==&lt;br /&gt;
* Almost unnoticeable guest down time&lt;br /&gt;
* Guest is not involved (unique to KVM Live Migration [#1 1])&lt;br /&gt;
* Capability to tunnel VM state through an external program (unique to KVM Live Migration [#1 1])&lt;br /&gt;
* ssh/gzip/bzip2/gpg/your own                                                                    &lt;br /&gt;
* Upon success guest continues to run on destination host, upon failure guest continues to run on source host (with one exception)                                                                                &lt;br /&gt;
* Short and Simple                                                                                       &lt;br /&gt;
* Easy to enhance                                                                                        &lt;br /&gt;
* Hardware independence (almost).                                                                        &lt;br /&gt;
* Support for migration of stopped (paused) VMs.                                                         &lt;br /&gt;
* Open                                                                                                   &lt;br /&gt;
&lt;br /&gt;
[[Anchor(1)]] 1  These features are unique to KVM Live Migration as far as I know. If you know of other hypervisor that support any of them please update this page or let me (Uri) know.                         &lt;br /&gt;
&lt;br /&gt;
== User Interface ==&lt;br /&gt;
The user interface is through the qemu monitor (alt-ctrl-2 on the SDL window)&lt;br /&gt;
&lt;br /&gt;
=== Management ===&lt;br /&gt;
 migrate [-d] &amp;lt;URI&amp;gt;&lt;br /&gt;
 migrate_cancel    &lt;br /&gt;
&lt;br /&gt;
The &#039;-d&#039; will let you query the status of the migration.&lt;br /&gt;
&lt;br /&gt;
With no &#039;-d&#039; the monitor prompt returns when the migration completes.&lt;br /&gt;
URI can be one of &#039;exec:&amp;lt;command&amp;gt;&#039; or tcp:&amp;lt;ip:port&amp;gt;                  &lt;br /&gt;
&lt;br /&gt;
=== Status ===&lt;br /&gt;
              &lt;br /&gt;
 info migrate &lt;br /&gt;
&lt;br /&gt;
=== Migration Parameters ===&lt;br /&gt;
 migrate_set_speed &amp;lt;speed&amp;gt;   set bandwidth control parameters (max transfer rate per second)&lt;br /&gt;
&lt;br /&gt;
== Example / HOWTO ==&lt;br /&gt;
A is the source host, B is the destination host:&lt;br /&gt;
===&#039;&#039;TCP&#039;&#039; example:===&lt;br /&gt;
1. Start the VM on B with the exact same parameters as the VM on A, in migration-listen mode (-incoming tcp:0:4444 (or other PORT))                                                                               &lt;br /&gt;
2. Start the migration (always on the source host):                                                      &lt;br /&gt;
 A: migrate -d tcp:B:4444 (or other PORT)                                                                &lt;br /&gt;
3. Check the status (on A only):                                                                         &lt;br /&gt;
 info migrate                                                                                            &lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;Offline&#039;&#039; example:===&lt;br /&gt;
1. unlimit bandwidth used for migration:&lt;br /&gt;
 A: migrate_set_speed 1g                &lt;br /&gt;
2. stop the guest:                      &lt;br /&gt;
 A: stop                                &lt;br /&gt;
3. continue with either TCP or exec migration as described above.&lt;br /&gt;
&lt;br /&gt;
== Problems / Todo ==&lt;br /&gt;
* TSC offset on the new host must be set in such a way that the guest sees a monotonically increasing TSC, otherwise the guest may hang indefinitely after migration.                                             &lt;br /&gt;
* usbdevice tablet complains after migration.                                                            &lt;br /&gt;
* handle migration completion better (especially when network problems occur).                           &lt;br /&gt;
* More informative status.                                                                               &lt;br /&gt;
* Migration does not work while CPU real-mode/protected mode are still changing.                         &lt;br /&gt;
&lt;br /&gt;
== savevm/loadvm to an external state file (using pseudo-migration) ==&lt;br /&gt;
&lt;br /&gt;
* To be supported directly by Migration Protocols, but until then...&lt;br /&gt;
* Save VM state into a compressed file                              &lt;br /&gt;
** Save                                                          &lt;br /&gt;
 stop                                                               &lt;br /&gt;
 migrate_set_speed 4095m                                            &lt;br /&gt;
 migrate &amp;quot;exec:gzip -c &amp;gt; STATEFILE.gz&amp;quot;                              &lt;br /&gt;
&lt;br /&gt;
** Load&lt;br /&gt;
 gzip -c -d STATEFILE.gz | &amp;lt;qemu-command-line&amp;gt; -incoming stdio&lt;br /&gt;
* Save VM State into an encrypted file (assumes KEY has already been generated)&lt;br /&gt;
** Save                                                                     &lt;br /&gt;
 stop                                                                          &lt;br /&gt;
 migrate_set_speed 4095m                                                       &lt;br /&gt;
 migrate &amp;quot;exec:gpg -q -e -r KEY -o STATFILE.gpg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Load VM state from an encrypted file&lt;br /&gt;
 gpg -q -d -r KEY STATEFILE.gpg | &amp;lt;qemu-command-line&amp;gt; -incoming stdio&lt;br /&gt;
&lt;br /&gt;
== more exec: options ==&lt;br /&gt;
&lt;br /&gt;
* Send encrypted VM state from host A to host B (Note: ssh is probably better, this is just for show)&lt;br /&gt;
&lt;br /&gt;
** on host A&lt;br /&gt;
 migrate &amp;quot;exec:gpg -q -e -r KEY | nc B 4444&amp;quot;&lt;br /&gt;
&lt;br /&gt;
** on host B&lt;br /&gt;
 nc -l 4444 | gpg -q -d -r KEY | &amp;lt;qemu-command-line&amp;gt; -incoming stdio&lt;br /&gt;
&lt;br /&gt;
== Algorithm (the short version) ==&lt;br /&gt;
1. Setup&lt;br /&gt;
* Start guest on destination, connect, enable dirty page logging and more&lt;br /&gt;
2. Transfer Memory&lt;br /&gt;
* Guest continues to run&lt;br /&gt;
* Bandwidth limitation (controlled by the user)&lt;br /&gt;
* First transfer the whole memory&lt;br /&gt;
* Iteratively transfer all dirty pages (pages that were written to by the guest).&lt;br /&gt;
3. Stop the guest&lt;br /&gt;
* And sync VM image(s) (guest&#039;s hard drives).&lt;br /&gt;
4. Transfer State&lt;br /&gt;
* As fast as possible (no bandwidth limitation)&lt;br /&gt;
* All VM devices&#039; state and dirty pages yet to be transferred&lt;br /&gt;
5. Continue the guest&lt;br /&gt;
* On destination upon success&lt;br /&gt;
** Broadcast &amp;quot;I&#039;m over here&amp;quot; Ethernet packet to announce new location of NIC(s).&lt;br /&gt;
* On source upon failure (with one exception).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Instructions for kvm-13 and below: [[MigrationQemu0.8.2]].&lt;/div&gt;</summary>
		<author><name>Themel</name></author>
	</entry>
</feed>