Managing virtual machine images

RHVM stores virtual machine disk images in data domains. A data domain can only be attached to one data center at a time. However, one data center may have multiple data domains attached to it at the same time.

From time to time, you may need to relocate disk images. For example:

  1. You may want to move a virtual machine’s disk image from one data domain to another.
  2. You may want to export virtual machines from one data center and import them into another.
  3. You may want to import an existing QCOW2 image from outside RHV into a data domain, so it can be attached to a virtual machine.

The current version of Red Hat Virtualization allows you to import images directly into data domains and to move data domains from one data center to another. Older versions of Red Hat Virtualization used a special export domain to export and import images between data domains. While the export domain feature is being phased out in favor of newer methods, it is still available and can be useful if you are working with older versions of the product.

Importing virtual machine images into RHV

The latest version of Red Hat Virtualization allows you to use Administration Portal or the API to directly import virtual machine disk images in QCOW2 format into a data domain. Once in a data domain, the images can be attached to existing virtual machines and used.

For this method to work, you must have configured RHVM to provide the Image I/O Proxy at installation time. You need to import the CA certificate from RHVM into your browser and trust its usage for web sites. Finally, your browser must support certain HTML5 APIs. Internet Explorer 10, Firefox 35, and Chrome 13, or later, are known to work.

To import a virtual machine image using Administration Portal:

  1. Select the Disks tab. On that tab, select Upload → Start.
  2. A new window titled Upload Image appears. In the window, click Choose File and select the image you want to upload from your local system. Specify a size to make the image, an Alias for its name, and the Data Center and Storage Domain to store it in. Click OK to start the import.
  3. The image appears on the list in the Disks tab. A progress bar displays underneath it as it uploads. When RHVM finishes the image upload, its status changes to OK. Note that it is not attached to any virtual machine yet.

To attach a disk image to an existing virtual machine with the Administration Portal:

  1. Select the Virtual Machines tab, and click on the name of the virtual machine to which you want to attach the image.
  2. Select the Disks tab for that virtual machine at the bottom of the interface. This lists all disk images attached to the virtual machine.
  3. If the virtual machine has any disks already attached that you want to get rid of, click Remove. A window opens asking you to confirm that you want to do that. If you want the disk deleted from the data domain entirely, select the Remove permanently check box.
  4. To add your imported disk image, click Attach. A window opens, listing all disk images. Select the check box next to the disk image you want to attach. Adjust its Interface to use the desired connection protocol. Finally, if this is the boot disk for the system, select the check box under the circled letters OS.

Click OK to attach the disk to your virtual machine.

Importing VM Images using Export Domains

An older method to import virtual machine images used export domains to import and export virtual machines in Open Virtualization Format (OVF). Export domains were also used to transfer images from one data domain to another in different data centers.

NOTE: Export domains have been deprecated in Red Hat Virtualization 4.1, but are currently still available.

If you have a virtual machine stored as an Open Virtual Appliance (OVA) file, you can import it into Red Hat Virtualization using an export domain and the image uploader tool. The disk images stored in the OVA file need to be in RAW or QCOW2 format.

First, an export domain needs to be created and attached to the data center for the new virtual machine. To create an export domain, use the Storage tab, as with ISO and data domains, and then select Export as the domain function.

Next, use the ovirt-image-uploader command with the upload directive to upload the OVA file to the export domain. This command requires at least two parameters: an OVA file and an export domain. It also asks for a username and a password to log into the RHV environment. The –insecure option permits an insecure connection to an RHV environment.

[[email protected] ~]# ovirt-image-uploader --insecure -e exportdomain upload example.ova
Please provide the REST API username for oVirt Engine (CTRL+D to
 abort): [email protected]
Please provide the REST API password for the [email protected] oVirt Engine
 user (CTRL+D to abort): mypass
Uploading: [########################################] 100%

To move the image from the export domain to a data domain in the data center, select the Storage tab in Administration Portal, and click on the entry for the export domain. Select the VM Import tab that appears at the bottom of the interface. Select your imported image and click Import.

VM import

The Import Virtual Machine(s) window opens. Name the new virtual machine and click OK to import it into the data domain and the data center.

Exporting VM Images using Export Domains

When RHVM exports a virtual machine into an export domain, it puts the virtual machine’s OVF Package in a directory structure in that export domain. This directory structure includes two subdirectories: images and master. The directories which comprise the OVF Package include an “OVF file” which is named with the .ovf file extension. This is a descriptor file that specifies the virtual hardware configuration for the virtual machine. The directories also include virtual disk image files for that virtual machine. An OVA file or package is just a TAR archive of the OVF Package’s directory structure.

If you can directly access the storage for the export domain, this provides an unsupported way to extract virtual machines from Red Hat Virtualization.

The official way to extract images from Red Hat Virtualization is to use its API, which is beyond the scope of this course. For more information, see the Red Hat Virtualization REST API Guide.

Moving VM disks to a new data domain

If a particular data domain is getting full or its usage is high, you may want to move some virtual machine disks to another data domain in the data center. You can also export virtual machines to a new data center by moving them into a new data domain and then moving the data domain to another data center.

Red Hat Virtualization supports the manual migration of virtual machine disks from one data domain to another.

To move virtual machine disks to a new data domain using the Administration Portal:

1. In the Disks tab, select the disk(s) associated with the virtual machine. Click Move.

Virtual machine disks

2. The Move Disk(s) window opens. For each disk, select the destination data domain in the Target and the Disk profile fields. Click OK to move the virtual machine disks to the destination data domain. It may take up to a minute for the virtual machine disks to move.

Destination data domain

3. In the Disks tab, click on each disk entry. A new section, providing disk details appears at the bottom of the window. In that new section, go to the Storage tab, and verify that the destination data domain is listed.

Virtual machine disks migration

Exporting virtual machines to a different data center

RHVM supports the usage of data domains to move virtual machine images between data centers. A data domain needs to store the virtual machines images. The following procedure details how to export a virtual machine between data centers using a data domain in the Administration Portal.

1. In the Storage tab, select the row for the data domain. A new section on data domain configuration details appears at the bottom of the interface.

In that new section, go to the Data Center tab, and click Maintenance to move the data domain into maintenance mode in the source data center. All virtual machines should be powered off to move a data domain into maintenance mode.

Maintenance mode

2. A Storage Domain maintenance window opens, asking you to confirm that you want to move the data domain into maintenance mode. Click OK.

3. When the value of the Domain status in Data Center field for the source data center is Maintenance, click Detach to detach the data domain from the source data center.

Data domain detachment

4. A window titled Detach Storage opens. Click OK to detach the data domain from the source data center.

5. Once detached, the source data center no longer appears in the Data Center tab for the data domain configuration details section. In the same tab, click Attach.

verification of data domain detachment

6. The Attach to Data Center window opens. Select the radio button for the destination data center. Click OK to attach the data domain to the destination data center.

Data domain attachment

7. In the data domain configuration details section, go to the VM Import tab. This tab includes a list of virtual machine images stored in the data domain. Select a virtual machine and click Import.

Virtual machine import

8. The Import Virtual Machine(s) window opens. Select the cluster of the destination data center. Click OK to import the virtual machine.

Virtual machine import configuration

9. Click System in the left navigation pane, and go to the Virtual Machines tab. Verify that the imported virtual machine is listed and that its status is Down.

Virtual machine import verification