From Fedora Project Wiki

No edit summary
(Misc updates)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{QA/Test_Case
{{QA/Test_Case
|description=This test case checks that basic live migration using libvirt between two Fedora 12 hosts works correctly.
|description=
Live migrate a VM between 2 Fedora hosts, and verify it is running correctly on the new host. These test steps aim for the simplest setup possible, using just a single host and two VMs: one as the migration destination, and one VM to migrate.
 
|setup=
 
If you've been following along with a test day, you should have an up to date Fedora VM available. This will be the host that we migrate the VM to. With the default setup this will require [[QA:Testcase_KVM_nested_virt|using nested virt]] for the desintation.
 
{{ admon/warning | The default network setup does not allow the migrated guest to maintain continuous network connectivity. | In real deployments you would want to use bridged networking, but it isn't required for these basic tests. }}
 
== SSH key access ==
 
* On the physical host, create an SSH key for root:
** <code>su -</code>
** <code>ssh-keygen</code>
 
* Set up the SSH key as an authorized key for the destination host VM
** <code>sudo virsh start test-day-vm</code>
** <code>virt-viewer --connect qemu:///system test-day-vm</code>
** Open a terminal, <code>su -</code>
** <code>mkdir -p /root/.ssh && chmod 700 /root/.ssh</code>
** Make note of the guest IP here, since it is required for the migration step: <code>ifconfig -a</code>
 
== Create the VM to migrate ==
 
If you've been following the test day, you likely only have 1 VM created. Feel free to skip this step if you have multiple VMs available.
 
* Clone the existing test day VM: <code>sudo virt-clone -o test-day-vm -n test-day-vm-migrate --auto-clone</code>
* If your test day VM is using nested virt, you want to turn that off for the new VM since it can cause migration compatibility issues since we are migrating into a VM: <code>sudo virt-xml test-day-vm-migrate --edit --cpu clearxml=yes</code>
* Edit the guest so that it has a smaller amount of memory. My destination had 4G, and the migrating VM had 2G. You can likely go much smaller.
* Start the VM, verify it works correctly.
 
== Sharing storage ==
 
Inside the destination VM, setup shared storage using sshfs:
 
* <code>sudo virsh start test-day-vm && virt-viewer --connect qemu:///system test-day-vm</code>
* <code>yum install sshfs</code>
* <code>sshfs -o allow_other root@HOST-IP:/var/lib/libvirt/images /var/lib/libvirt/images</code>
* <code>sudo setsebool -P virt_use_fusefs=1</code>
 
 
|actions=
|actions=
# On the source machine, edit the guest so that it has some small amount of memory (say, 512MB).
 
# On the source machine, start the guest.
{{admon/tip | This example uses tunnelled migration | Tunnelled migration passes all traffic through libvirtd, so no extra firewall ports need to be opened. <br>It has a usability hurdle though: qemu+ssh URIs will only work if it can authenticate without user input.}}
# Once the guest has fully booted, find out the IP address of the guest (by logging into the guest and running ifconfig, or whatever is equivalent in the guest OS of your choice). From the source machine, start a ping to the guest:<br><br><code>$ ping <guest-IP></code><br><br>
 
# Now execute:<br><br><code>$ virsh migrate --live <guestname> qemu+ssh://<destination host>/system<br><br>
# On the source host, prep the migration:
# Shutdown the guest on the destination machine. Once it's successfully shut down, edit the guest on the source machine and give it random, differing amounts of memory: 1024MB, 2111MB, etc. Then repeat the test for these differing amounts of memory.
#* <code>source-host$ sudo virsh start test-day-vm-migrate< && virt-viewer --connect qemu:///system test-day-vm-migrate</code>
# Repeat the entire test for as many different guest OS's as are relevant. We would at least like to see the following guests:
#* Log in to the guest graphical desktop. Open a terminal, start a simple loop like <code>dest-vm$ for i in `seq 1 10000`; do echo $i; sleep 1; done</code>
## Fedora 12
# The destination host VM should be started and have storage prepped as mentioned above.
## Fedora 11
# Verify you can SSH to the storage host non-interactively as root: <code> su - </code> , then <code> ssh root@$DEST-VM-IP</code> , then <code>exit</code>
## RHEL-4
# On the source host, perform the migration: <code>source-host$ sudo virsh migrate --verbose --p2p --tunnelled --live test-day-vm-migrate qemu+ssh://$DEST-VM-IP/system</code>
## RHEL-5
# After migration completes, verify the migrated VM is running on the destination
## Windows XP
#* <code>source-host$ virt-viewer --connect qemu:///system test-day-vm</code>
## Windows Vista
#* <code>dest-vm$ virt-viewer --connect qemu:///system test-day-vm-migrate</code>
## SUSE
#* Verify the simple echo loop is still running, guest appears to be working okay.
# Stop the migrated VM:
#* <code>dest-vm$ sudo virsh destroy test-day-vm-migrate</code>
#* Verify that after destroying the VM, it no longer appears in <code>dest-vm$ sudo virsh list --all</code> . (that is because we didn't pass the --persistent option to 'virsh migrate')
# Verify that the VM is stopped on the original host: <code>source-host$ sudo virsh list --all</code>  (the VM is still there because we didn't pass the --undefinesource option to 'virsh migrate')
 
 
=== Migration without shared storage ===
 
Migration without shared storage is a feature greatly improved in Fedora 19. It allows migrating a guest to a new host without setting up any shared network storage location.
 
{{admon/caution | These steps actually don't work | --copy-storage* and --tunnelled is an invalid combo.}}
 
# Don't follow the 'Sharing storage' steps above. Or undo them with <code>dest-vm$ umount /var/lib/libvirt/images</code>
# On the source host, prep the migration:
#* <code>source-host$ sudo virsh start test-day-vm-migrate< && virt-viewer --connect qemu:///system test-day-vm-migrate</code>
#* Log in to the guest graphical desktop. Open a terminal, start a simple disk access loop like <code>dest-vm$ for i in `seq 1 10000`; do echo $i >> count.out; cat count.out <nowiki>|</nowiki> tail -1; sync; sleep 1; done</code>
# Record the storage details of the VM that will be migrated: <code>source-host# sudo qemu-img info /var/lib/libvirt/images/test-day-vm-migrate.img</code>
# Prep the destination host
#* <code>source-host# sudo virsh start test-day-vm</code>
#* A stub disk image must be created that matches the format and size of the source image, ex: <code>dest-vm# sudo qemu-img create -f raw /var/lib/libvirt/images/test-day-vm-migrate.img 10G</code> ([https://bugzilla.redhat.com/show_bug.cgi?id=967233 virsh should add an option to do this automatically])
# Perform the migration: continue at step 3 for the above regular migration case, but add <code>--copy-storage-all</code> to the migrate command. Continue the steps and verify the guest is running as expected. ([https://bugzilla.redhat.com/show_bug.cgi?id=967242 This can fail on F19])
 
 
|results=
|results=
# After executing the virsh migrate command, the guest should migrate over to the destination machine, and not be running anymore on the source machine. Use <code>virsh list</code> on both machines to verify this.  Additionally, the ping that was started in step 3 should continue uninterrupted.
All steps complete without error and the migrated VM behaves as expected.
 
# Step #1 completes without error
# The system boots into runlevel 5
# Program completes with exit code 0
 
|optional=
If you have pre-existing VMs of other operating systems, please try migrating those as well.
}}
}}
[[Category:Virtualization Live Migration]]
 
[[Category:Virtualization Test Cases]]

Latest revision as of 17:02, 16 September 2014


Description

Live migrate a VM between 2 Fedora hosts, and verify it is running correctly on the new host. These test steps aim for the simplest setup possible, using just a single host and two VMs: one as the migration destination, and one VM to migrate.

Setup

If you've been following along with a test day, you should have an up to date Fedora VM available. This will be the host that we migrate the VM to. With the default setup this will require using nested virt for the desintation.

Warning.png
The default network setup does not allow the migrated guest to maintain continuous network connectivity.
In real deployments you would want to use bridged networking, but it isn't required for these basic tests.

SSH key access

  • On the physical host, create an SSH key for root:
    • su -
    • ssh-keygen
  • Set up the SSH key as an authorized key for the destination host VM
    • sudo virsh start test-day-vm
    • virt-viewer --connect qemu:///system test-day-vm
    • Open a terminal, su -
    • mkdir -p /root/.ssh && chmod 700 /root/.ssh
    • Make note of the guest IP here, since it is required for the migration step: ifconfig -a

Create the VM to migrate

If you've been following the test day, you likely only have 1 VM created. Feel free to skip this step if you have multiple VMs available.

  • Clone the existing test day VM: sudo virt-clone -o test-day-vm -n test-day-vm-migrate --auto-clone
  • If your test day VM is using nested virt, you want to turn that off for the new VM since it can cause migration compatibility issues since we are migrating into a VM: sudo virt-xml test-day-vm-migrate --edit --cpu clearxml=yes
  • Edit the guest so that it has a smaller amount of memory. My destination had 4G, and the migrating VM had 2G. You can likely go much smaller.
  • Start the VM, verify it works correctly.

Sharing storage

Inside the destination VM, setup shared storage using sshfs:

  • sudo virsh start test-day-vm && virt-viewer --connect qemu:///system test-day-vm
  • yum install sshfs
  • sshfs -o allow_other root@HOST-IP:/var/lib/libvirt/images /var/lib/libvirt/images
  • sudo setsebool -P virt_use_fusefs=1

How to test

Idea.png
This example uses tunnelled migration
Tunnelled migration passes all traffic through libvirtd, so no extra firewall ports need to be opened.
It has a usability hurdle though: qemu+ssh URIs will only work if it can authenticate without user input.
  1. On the source host, prep the migration:
    • source-host$ sudo virsh start test-day-vm-migrate< && virt-viewer --connect qemu:///system test-day-vm-migrate
    • Log in to the guest graphical desktop. Open a terminal, start a simple loop like dest-vm$ for i in seq 1 10000; do echo $i; sleep 1; done
  2. The destination host VM should be started and have storage prepped as mentioned above.
  3. Verify you can SSH to the storage host non-interactively as root: su - , then ssh root@$DEST-VM-IP , then exit
  4. On the source host, perform the migration: source-host$ sudo virsh migrate --verbose --p2p --tunnelled --live test-day-vm-migrate qemu+ssh://$DEST-VM-IP/system
  5. After migration completes, verify the migrated VM is running on the destination
    • source-host$ virt-viewer --connect qemu:///system test-day-vm
    • dest-vm$ virt-viewer --connect qemu:///system test-day-vm-migrate
    • Verify the simple echo loop is still running, guest appears to be working okay.
  6. Stop the migrated VM:
    • dest-vm$ sudo virsh destroy test-day-vm-migrate
    • Verify that after destroying the VM, it no longer appears in dest-vm$ sudo virsh list --all . (that is because we didn't pass the --persistent option to 'virsh migrate')
  7. Verify that the VM is stopped on the original host: source-host$ sudo virsh list --all (the VM is still there because we didn't pass the --undefinesource option to 'virsh migrate')


Migration without shared storage

Migration without shared storage is a feature greatly improved in Fedora 19. It allows migrating a guest to a new host without setting up any shared network storage location.

Stop (medium size).png
These steps actually don't work
--copy-storage* and --tunnelled is an invalid combo.
  1. Don't follow the 'Sharing storage' steps above. Or undo them with dest-vm$ umount /var/lib/libvirt/images
  2. On the source host, prep the migration:
    • source-host$ sudo virsh start test-day-vm-migrate< && virt-viewer --connect qemu:///system test-day-vm-migrate
    • Log in to the guest graphical desktop. Open a terminal, start a simple disk access loop like dest-vm$ for i in seq 1 10000; do echo $i >> count.out; cat count.out | tail -1; sync; sleep 1; done
  3. Record the storage details of the VM that will be migrated: source-host# sudo qemu-img info /var/lib/libvirt/images/test-day-vm-migrate.img
  4. Prep the destination host
    • source-host# sudo virsh start test-day-vm
    • A stub disk image must be created that matches the format and size of the source image, ex: dest-vm# sudo qemu-img create -f raw /var/lib/libvirt/images/test-day-vm-migrate.img 10G (virsh should add an option to do this automatically)
  5. Perform the migration: continue at step 3 for the above regular migration case, but add --copy-storage-all to the migrate command. Continue the steps and verify the guest is running as expected. (This can fail on F19)

Expected Results

All steps complete without error and the migrated VM behaves as expected.

  1. Step #1 completes without error
  2. The system boots into runlevel 5
  3. Program completes with exit code 0

Optional

If you have pre-existing VMs of other operating systems, please try migrating those as well.