This article describes how to import virtual machines (VMs) and VM images created with the software:

  • Hyper-V;
  • VirtualBox;
  • VMware;
  • Xen;
  • various hypervisors using QEMU-KVM technology.

The import consists of the following steps:

  1. Preparation of the source VM.
  2. Preparation of VMmanager.
  3. Transfer of VM disks.
  4. Starting the VM.

Importing VMs created with OVZ virtualization is described in the article Moving an OVZ container to LXD cluster.

Restrictions


The following is not supported on imported VMs:

  • changing the password using VMmanager;
  • automatic adding and deletion of IP addresses;
  • automatic change of disk partitions.

Because different hypervisors may use different drivers when working with WIndows OS, the correct import of VMs with Windows family OS is not guaranteed.

On VMs with Windows OS imported from Hyper-V, increasing resources with the Add resources without restarting the VM option may not work properly.

Preparation of the source VM


This step converts the source VM files into a format supported by VMmanager and transfers them to the platform cluster node. VMmanager supports the following VM disk formats:

  • RAW — for Ceph and LVM storage;
  • Qcow2 — for file storage.

For more information about VM disk formats, see the article Storage types.

Since RAW files are large in size, we recommend converting them to Qcow2 format before transferring them to the VMmanager cluster node.

Preparation procedure

  1. Stop the source VM.
  2. If the files of VM disks:

    • are in a Ceph storage:

      1. Connect to the Ceph monitor server from the source VM.

      2. Export VM disks: 

        rbd export <pool_name>/<disk_name> <raw_file>
        CODE

        <pool_name> — name of Ceph pool

        <disk_name> — name of VM disk

        <raw_file> — output file in RAW format

      3. Convert disc files to Qcow2 format: 

        qemu-img convert -f raw -O qcow2 <raw_file> <qcow_file>
        CODE

        <raw_file> — input file in RAW format

        <qcow_file> — output file in Qcow2 format

    • are in the LVM storage:

      1. Export them and convert them to Qcow2 format

        qemu-img convert -f raw -O qcow2 <path_to_vm/raw_file> <qcow_file>
        CODE

        <path_to_vm/raw_file> — path and name of the source VM disk file in RAW format

        <qcow_file> — output file in Qcow2 format

  3. If the format of the VM files is different from Qcow2, perform the conversion:

    qemu-img convert -f <input_format> -O qcow2 <input_file> <qcow_file>
    CODE

    <input_format> — input format (optional parameter):

    • vdi — for VirtualBox hypervisor;
    • vmdk — for VMware hypervisor;
    • vpc — for Hyper-V hypervisor

    <input_file> — input file

    <qcow_file> — output file in Qcow2 format

  4. Move the VM disk files to the VMmanager cluster node.

Preparation of VMmanager


  1. If required, prepare and connect the correct type of storage to the cluster. Read more:
  2. Create VMs with required parameters: Virtual machines → Create a VM. During the creation:
    1. Select NoOS as the operating system.
    2. Select or create a configuration with at least the same disk size as the original VM. If the source VM has more than one disk, select or create a configuration with the required number of disks.
    3. Select the required storage type.
    4. If you want to import a VM without changing the IP address, select the required IP address: PoolAllocate IP.
  3. Stop the created VM: Virtual machines → select the VM →   menu → Stop.

Migration of VM disks


When migrating, you will need to replace the disk files created by the platform with those of the source VM. The file names should remain the same.

If the VM has one disk, the file name is id_VM-name. For example, 42_vmtest. If the VM has more than one disk, it is stored in several files. For the first disk, the file name is id_VM-name, for the other disks — id_VM-name_disk-name. For example, a VM with three disks can be stored in files 42_vmtest, 42_vmtest_disc2, 42_vmtest_disc3.

The order of transfer depends on the type of storage used.

File storage

Copy the disks of the source VM to the storage directory on the cluster node:

cp <qcow_file> <vm_dir>/<vm_file>
CODE

<qcow_file> — imported file in Qcow2 format

<vm_dir> — VM storage directory. When creating storage with the default setting — /vm.

<vm_file> — file with the VM disk

Local LVM storage

Import the disks of the source VM to LVM storage:

qemu-img convert -f qcow2 -O raw <qcow_file> /dev/mapper/<vm_file>
CODE

<qcow_file> — imported file in Qcow2 format

/dev/mapper/ — path to the LVM disk

<vm_file> — file with the VM disk

Network LVM storage

Import the disks of the source VM to LVM storage:

qemu-img convert -f qcow2 -O raw <qcow_file> /dev/Network_lvm_<dev_disk>/<id_name>
CODE

<qcow_file> — imported file in Qcow2 format

/dev/Network_lvm_<dev_disk>/<id_name> — path to the LVM disk

To get the path to the VM disk:

  1. Run virsh list command and store the id value for the desired VM.
  2. Run virsh domblklist <VM_id> command. The output of the command will contain the disk path.

<dev_disk> value may vary depending on the disk connection type and multipath settings.

Ceph

  1. Convert the disk files of the source VM to RAW format:

    qemu-img convert -f qcow2 -O raw <qcow_file> <raw_file>
    CODE

    <qcow_file> — input file in Qcow2 format

    <raw_file> — output file in RAW format

  2. On the Ceph monitor server:

    1. Delete the disks of the created VM:

      rbd rm <pool_name>/<vm_file>
      CODE

      <pool_name> — name of Ceph pool

      <vm_file> — file with the VM disk

    2. Import the disks of the source VM:

      rbd import <raw_file> <pool_name>/<vm_file>
      CODE

      <raw_file> — imported file in RAW format

      <pool_name> — name of Ceph pool

      <vm_file> — file with the VM disk

Starting the VM


  1. Run the imported VM: Enter Virtual machines → select the VM → menu → Start.
  2. If necessary, connect to the VM via VNC or SPICE and change its network settings: Enter Virtual machines → select the VM → menu → VNC (SPICE). Read more about the network settings in the Assigning IP addresses with OS tools article.