Import from any KVM host over SSH

Copy libvirt domains from any KVM host, such as VirtFusion, plain libvirt or another panel's hypervisor, to VMStack over SSH, keeping firmware, disks and cards.

Any Linux host that runs KVM through libvirt can be a source: VirtFusion, KoaVM, Virtlix or VirtConsole hypervisors, or plain KVM. A VMStack node logs into the host over SSH with its own key, reads each domain (virsh list --all and virsh dumpxml) and copies its disks. There is no API: you add the host's SSH login, and the rest uses the same wizard, dry run, queue and progress page as the panel imports.

Nothing on the host is changed, except a domain shut down for its copy when you ask for it (and started again if the import does not complete).

Before you start#

  • SSH. The VMStack nodes reach the host on TCP 22 (or the port you set) and log in as a user that can run virsh and read the disks. root is the simple case.
  • The host runs libvirt with virsh and qemu-img. With zstd installed, disks travel compressed.
  • The nodes that read the host and receive its servers run a current agent; one whose agent cannot read a KVM host yet is shown as such on the form.

Add the host#

  1. Go to Infrastructure › Import from another panel › Connect a panel.
  2. Under The panel, choose KVM host and give it a Name.
  3. Under SSH login from the nodes, enter the SSH host, Port and User.
  4. Add the lines under The nodes' keys to add to the host's /root/.ssh/authorized_keys to that file on the host. Each line may carry from="<node address>" so the key works only from its node; leave it out when the node reaches the host from another address. Each node's private key never leaves the node.
  5. Under Where its servers go, choose the VMStack node.
  6. Set Servers copied at once and press Save and check.

The first check only reads the host's SSH key; nothing is sent. Compare the fingerprint the page shows with the key file it names on the host, for example:

ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub

and press Trust host key…. The next check logs in and reads every domain (up to 500 per check): vCPUs, memory, machine type, firmware, UEFI variable store, TPM, disks with their paths and sizes, cards with their MAC addresses and networks, and the guest's addresses (from the guest agent or ARP). The check line also says whether disks will travel compressed. Check and read again refreshes the list; a domain read again keeps its number.

Import the domains#

Press Import… on the source. The wizard skips accounts, plans and IP blocks (a KVM host has none) and shows each domain with its firmware and cards. In How it maps:

Choice Notes
Servers Copy its disks now or Skip for each domain
Owner Servers whose account is not imported go to the account you choose
Plan of the servers without a mapped plan A plan, or Their own size. A node whose only addresses are a NAT block needs a NAT plan
Shut each domain down on the KVM host before its copy Recommended: the node runs virsh shutdown, waits up to 20 minutes, copies, and runs virsh start again if the import fails or is cancelled. Without it, the disks are read while the domain runs; a domain that still runs is made but not started on VMStack
Addresses Keep them where the node's blocks have them free (else new ones), or new addresses
Network card, Disk bus As on the host by default
Other network cards Each libvirt network or bridge (network:default, bridge:br1) to a VMStack private network (MAC kept) or Not carried

Then review What will happen and press Run the import. Copies appear on Infrastructure › Imports in progress with the stages stop, connect, copy, write, create and start.

What is copied#

  • Disks: files, block devices (LVM volumes, ZFS zvols) and storage pool volumes, raw or qcow2. A qcow2 with a backing chain is copied file by file and flattened into one disk on the node. Zero blocks of raw disks are not written.
  • Firmware: BIOS, UEFI, or UEFI with Secure Boot. UEFI guests are made q35. The UEFI variable store is copied when it fits the node's 4 MB firmware; otherwise the server starts with fresh variables (a note says so).
  • TPM: a new, empty TPM 2.0 (a note warns about keys sealed to the old one).
  • The first card: its model and MAC address. Other cards join the private networks you mapped, or are noted and left out.
  • Windows is recognised from the domain's Hyper-V settings or its libosinfo id.

Refused, with the reason shown already in the inventory: network disks (RBD, iSCSI, Gluster), formats other than raw and qcow2, domains that are not x86_64, and a domain whose disk set changed after the server was made (domain_missing). Guest IPv6 addresses are not carried over onto the copy; a second card on a public network is noted but its addresses are not moved.

If a copy fails, the node starts the domain again (when it shut it down), the VMStack server stays in error with its addresses, and Retry starts over.