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: http://git.annexia.org/?p=import-to-ovirt.git

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.

28 Comments

Filed under Uncategorized

28 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 ./import-to-ovirt.pl 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 ./import-to-ovirt.pl /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 ?

    Thanks.

    • 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 http://www.ovirt.org/develop/release-management/features/virt/virt-v2v-integration/ or https://bugzilla.redhat.com/show_bug.cgi?id=1302427

    • 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

  10. max

    Hi my friend,I encountered this issue:
    [root@node ~]# ./import-to-ovirt.pl test.qcow2 192.168.1.189:/home/export
    guestfs_launch failed.
    See http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
    and/or run ‘libguestfs-test-tool’. at ./import-to-ovirt.pl line 247.
    it is weird….
    thanks

    • rich

      And what happened when you followed the instructions which it prints out telling you exactly what to read and do?

      • max

        thanks man,and I followed the tips .
        And i enable debug mode:
        #export LIBGUESTFS_DEBUG=1
        #export LIBGUESTFS_TRACE=1
        and I executed it againe,it warning:
        uses a qcow2 feature which is not supported by this qemu version: QCOW version 3
        qemu-kvm: -drive file=test.qcow2,snapshot=on,cache=writeback,id=hd0,if=none: could not open disk image test.qcow2: Operation not supported

        Finally I found it is about qcow2 version,so i executed it on my kvm host:
        qemu-img amend -f qcow2 -o compat=0.10 xxx.qcow2
        After done,but I met this new issue:
        ./import-to-ovirt.pl test.qcow2 192.168.1.189:/home/export
        ./import-to-ovirt.pl: no operating system was found on the disk

    • max

      and i enable debug mode,i found it is about qcow2 version,so i executed it on my kvm host:
      qemu-img amend -f qcow2 -o compat=0.10 xxx.qcow2
      After done,but I met this new issue:
      ./import-to-ovirt.pl test.qcow2 192.168.1.189:/home/export
      ./import-to-ovirt.pl: no operating system was found on the disk

      • rich

        http://libguestfs.org/guestfs-faq.1.html#whats-the-deal-with-guestfish–i

        It basically means we couldn’t find any operating system in the image being converted. You can only convert and import actual guests.

      • max

        thanks man, I will check it out.

      • max

        [root@node ~]# virt-cat test.qcow2 /var/log/messages
        virt-cat: no operating system was found on this disk

        If using guestfish ‘-i’ option, remove this option and instead
        use the commands ‘run’ followed by ‘list-filesystems’.
        You can then mount filesystems you want by hand using the
        ‘mount’ or ‘mount-ro’ command.

        If using guestmount ‘-i’, remove this option and choose the
        filesystem(s) you want to see by manually adding ‘-m’ option(s).
        Use ‘virt-filesystems’ to see what filesystems are available.

        If using other virt tools, this disk image won’t work
        with these tools. Use the guestfish equivalent commands
        (see the virt tool manual page).

        RHEL 6 notice
        ————-
        libguestfs will return this error for Microsoft Windows guests if the
        separate ‘libguestfs-winsupport’ package is not installed. If the
        guest is running Microsoft Windows, please try again after installing
        ‘libguestfs-winsupport’.

        By the way,my guest is linux.I still have no idea…

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.