Importing KVM guests to oVirt or RHEV

One of the tools I maintain is virt-v2v. It’s a program to import guests from foreign hypervisors like VMware and Xen, to KVM. It only does conversions to KVM, not the other way. And a feature I intentionally removed in RHEL 7 was importing KVM → KVM.

Why would you want to “import” KVM → KVM? Well, no reason actually. In fact it’s one of those really bad ideas for V2V. However it used to have a useful purpose: oVirt/RHEV can’t import a plain disk image, but virt-v2v knows how to import things to oVirt, so people used virt-v2v as backdoor for this missing feature.

Removing this virt-v2v feature has caused a lot of moaning, but I’m adamant it’s a very bad idea to use virt-v2v as a way to import disk images. Virt-v2v does all sorts of complex filesystem and Windows Registry manipulations, which you don’t want and don’t need if your guest already runs on KVM. Worst case, you could even end up breaking your guest.

However I have now written a replacement script that does the job:

If your guest is a disk image that already runs on KVM, then you can use this script to import the guest. You’ll need to clone the git repo, read the README file, and then read the tool’s man page. It’s pretty straightforward.

There are a few shortcomings with this script to be aware of:

  1. The guest must have virtio drivers installed already, and must be able to boot off virtio-blk (default) or virtio-scsi. For virtio-scsi, you’ll need to flip the checkbox in the ‘Advanced’ section of the guest parameters in the oVirt UI.
  2. It should be possible to import guests that don’t have virtio drivers installed, but can use IDE. This is a missing feature (patches welcome).
  3. No network card is added to the guest, so it probably won’t have network when it boots. It should be possible to add a network card through the UI, but really this is something that needs to be fixed in the script (patches welcome).
  4. It doesn’t handle all the random packaging formats that guests come in, like OVA. You’ll have to extract these first and import just the disk image.
  5. It’s not in any way supported or endorsed by Red Hat.


Filed under Uncategorized

21 responses to “Importing KVM guests to oVirt or RHEV

  1. Adrian

    When attempting to use this tool from a CentOS7.1 host I get:

    libvirt needs authentication to connect to libvirt URI qemu:///system
    libvirt: XML-RPC error : authentication failed: authentication failed
    could not connect to libvirt (URI = qemu:///system): authentication failed: authentication failed at ./ line 230.

    It doesn’t matter what credentials I use. Can you shed any light on what exactly this is looking for?

      • Adrian

        I’ve figured this out. The code below worked:
        LIBGUESTFS_BACKEND=direct ./ /opt/images/mu_import_image.img 10.1.X.X:/mnt/my_pool/ovirt_vm_exports
        For whatever reason, not setting the “direct” variable prompted me to provide credentials to log in to libvirt when using this script. Even after applying the correct credentials (thanks Ovirt Users list!) the process would fail with a different error afterward.

        The import worked as expected after setting the backend=direct variable. Thanks!

  2. Pingback: How to import qcow2 images to ovirt | gfnork

  3. We migrated CentOS 6.x VM from KVM/QEMU to oVirt.
    Two problems we encountered.
    The old KVM, we used serial console, the linux boot command line had console=ttyS0,115200n8 … removed this parameter so the SPICE/KVM console is available.

    Two disks on old VM, one is /dev/vda, second is /dev/sdb.
    Once imported to oVirt, booted single user, edit /etc/fstab to make /dev/sdb be /dev/vdb.
    Reboot, all good.

  4. Hi Richard !

    Git repo seems to be unavailable … 😦

    Can you take a look ?


    • rich

      Looks like the server ran out of memory. It’s working now. Note that this is *obsolete* if you are using a new enough version of oVirt.

      • My oVirt versions are 4.0.4, but i am trying to import libvirt vm using thin lvm. Seem´s libguestfs 1.28 does not support thin lvm. So i use an alternative aproach ( dd to new created vm disks ). But i want to try your script. Do you think i will have sucess ?

      • rich

        No idea, you’d have to try it.

  5. Hi Rich,

    as a convenience to people (me) that may be finding this when searching for information about the new oVirt/RHV capability (Oct 2016), would you consider updating this post? I was hoping a preceding paragraph could be added which mentions that this may be obsolete, and perhaps reference the new way of doing it or

    • rich

      I don’t think the ovirt link is the right one. This is not related to virt-v2v. The Bugzilla link is the right one I think.

  6. Yes it is. I have just tired it, but it’s very slow and unconvinient, because you have to connect to kvm via qemu+ssh:// protocol etc. But the machine must by power off. So it is useless to import several dozen of virtual machines to the RHEV due to downtime.
    Ok I know how to convert qemu2 to the raw image but how to import the raw to the RHEV? On the RHEV-M machine is a tool engine-image-uploader but it imports from the OVF format only.

  7. OK now I see the option in RHEV: Disks -> Upload -> Start, but I can browse only from my local workstation only, not from the server side, and when the qcow2 in raw format is above 50GB it is a little bit inconvenient. Ok I am asking the support mabye there is a another way to import disk 🙂

  8. martin

    RH Support told me that there is impossible to upload disk from host and local storage, so your script is the one solution to move machines from qcow to RHEV2 quickly. I didn’t belive that they deploy RHEV without so obvious function.

    • rich

      I don’t know if what Red Hat’s support are telling you is correct or not, but in any case it’s better to ask on one of the oVirt (upstream) mailing lists if you want the definitive upstream answer. (Also possibly it’s something we disable in RHV for support reasons or whatever).

  9. Pingback: Keep Your Servers and Run Your Applications Forever with Red Hat Virtualization powered by KVM | Keith Tenzer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s