How to import qcow images into RHEV

Posted by cjung on Wed, Jan 14, 2015

Red Hat is providing KVM/QCOW2 images on the support portal for easy access and use in virtualized or cloud environments. The images are stripped down and cloud-init enabled so they can be used for example in OpenStack, RHEV/ovirt or plain KVM. CloudForms/ManageIQ provides support for managing cloud-init templates and the combination of those technologies dramatically simplifies template management.

To use such an image on RHEV, you have to first import it. Sadly the rhevm-image-uploader does not support qcow images yet, so you have to import the image manually. This is the way I did - there might be better ways to do it.

create a new VM in RHEV

  • choose RHEL 6 or 7 depending on which template you want to import
  • give it a reasonable name
  • adjust other settings as you see fit

add a disk to the new VM. The minimum size can be retrieved from the qcow image itself:

$ qemu-img info rhel-guest-image-6.6-20141222.0.x86_64.qcow2
image: rhel-guest-image-6.6-20141222.0.x86_64.qcow2
file format: qcow2
virtual size: 16G (17179869184 bytes)
disk size: 340M
cluster_size: 65536

This image needs a minimum disk size of 16 GB. The image automatically grows on first boot, if you create a larger disk.

Identify the associated file on disk. If you’re using NFS, this is rather simple. You can try to find the newly created image directly on your disk, if you’re already familiar with the internal structure. Or you can use the RHEV REST API to identify the file name.


You should find a block similar to this one (output truncated):

<template href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6" id="66081542-2ef7-4978-bf30-5e79173630e6">
<actions><link href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6/export" rel="export"/></actions>
<link href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6/disks" rel="disks"/>

Try to access the link for the list of associated disks, e.g.:


You should get an output like this (output truncated):

<disk href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6/disks/cde4a207-df4c-4b45-81bd-3ed0a72f4c52" id="cde4a207-df4c-4b45-81bd-3ed0a72f4c52"><actions><link href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6/disks/cde4a207-df4c-4b45-81bd-3ed0a72f4c52/export" rel="export"/>
<link href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6/disks/cde4a207-df4c-4b45-81bd-3ed0a72f4c52/copy" rel="copy"/></actions>
<template href="/api/templates/66081542-2ef7-4978-bf30-5e79173630e6" id="66081542-2ef7-4978-bf30-5e79173630e6"/>

You should find a file with the name matching the image ID on your NFS server.

If you use fibre channel or iSCSI the on disk layout is different, but the above calls should help you to identify the proper LUN and logical volume.

Big fat warning! Do not continue if you’re not absolutely sure you identified the correct file! You will ruin your RHEV environment and have been warned.

Make sure you identified the correct file:

$ pwd

As you can see cde4a207-df4c-4b45-81bd-3ed0a72f4c52 matches the disk ID retrieved via the REST API. And there is a file in this directory matching the disk ID retrieved in the second API call:

# ls

Again, do not proceed if the IDs do not match!

Overwrite the image with qemu-img:

# qemu-img convert -O raw /tmp/rhel-guest-image-6.6-20141222.1.x86_64.qcow2 bfcffeba-8b81-4a64-82eb-9007a28557b4`

Make sure you convert to the appropriate on disk format. Check the v2vguide for details.

If you now start this VM, it should come up with the RHEL KVM image.

That’s all folks!