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:
- 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.
- 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).
- 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).
- 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.
- It’s not in any way supported or endorsed by Red Hat.
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?
No idea. Maybe ask the libvirt users mailing list.
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!
Pingback: How to import qcow2 images to ovirt | gfnork
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.
Which version of virt-v2v?
Hi Richard !
Git repo seems to be unavailable … 😦
Can you take a look ?
Thanks.
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 ?
No idea, you’d have to try it.
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
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.
How to clone http://git.annexia.org/?p=import-to-ovirt.git, where is the right path to the repo?
Thank you, now it works. By the way, I completly do not understand RH politicy about attract RHEV when even there is no tool to migrate directly from qcow2 to RHEV.
There’s a way to import disk images in the latest RHV. I don’t know if it can import qcow2 format, but you can convert those to raw trivially using
qemu-img convert
.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.
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 🙂
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.
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).
Pingback: Keep Your Servers and Run Your Applications Forever with Red Hat Virtualization powered by KVM | Keith Tenzer
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
And what happened when you followed the instructions which it prints out telling you exactly what to read and do?
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
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
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.
thanks man, I will check it out.
[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…