Migrate a KVM Guest Using virsh

Use the virsh utility to move a KVM guest to another host.

Ensure that the following are true before proceeding:

  • The KVM guest is shut down on the source host.

    Note:

    For live migration options, see Managed KVM Server Virtualization.

  • You have administrator privileges on the source and destination hosts.
  • The source and destination hosts must be mutually reachable over the network, and all required migration ports must be open on the destination host.
  • CPUs on the source and destination hosts must be compatible. If the KVM guest configuration requests a CPU model or features not available on the destination, the migrated guest might fail to start.
  • Shared storage (for example, NFS/iSCSI/Ceph) must be visible to both hosts, or use --copy-storage-all to transfer disks during migration.
  • The libvirtd service must be enabled on both hosts. See Manage the libvirtd Service.

Follow these steps to migrate a KVM guest from one host to another.

  1. Confirm that the KVM guest is shut down on the source host:
    sudo virsh list --all

    If the State field in the output doesn't show the KVM guest as shut off, shut it down before proceeding:

    sudo virsh shutdown KVM_Guest_Name
  2. (Optional) If using shared storage, ensure that the KVM guest's disks are on a shared path visible to both hosts (for example, an NFS pool).
  3. Migrate the KVM guest configuration to the destination host.

    Run the following command to re-create the KVM guest configuration on the destination host so that it survives service or host reboots:

    sudo virsh migrate --offline --persistent KVM_Guest_Name \
        qemu+ssh://destination-host/system

    If you're not using shared storage, add --copy-storage-all to migrate the disks:

    sudo virsh migrate --offline --persistent KVM_Guest_Name \
        qemu+ssh://destination-host/system --copy-storage-all
  4. Verify that the KVM guest now exists on the destination host.

    Run the following command and ensure that the migrated KVM guest appears in the list:

    sudo virsh list --all

    View basic information about the migrated KVM guest:

    sudo virsh dominfo KVM_Guest_Name
  5. (Optional) If storage was copied then archive or remove old disk files on the source per the organization's retention policy.