Converting the Image Format Using qemu-img-hw

Scenarios

You can import an image file in VHD, VMDK, QCOW2, RAW, VHDX, QCOW, VDI, QED, ZVHD, or ZVHD2 format to the cloud platform. Image files in other formats need to be converted into any of these formats using the open-source tool qemu-img before being imported. However, the qemu-img tool cannot convert image files to the ZVHD or ZVHD2 format. To convert image files to any of the two formats, use the self-developed tool qemu-img-hw. This section describes how to use qemu-img-hw to convert an image file to ZVHD2.

Background

qemu-img-hw can be used only in Linux. You can run it on a local Linux server or a Linux ECS on the cloud platform. The following procedure uses an EulerOS ECS as an example.

Procedure

  1. Upload the image file to be converted to the ECS.
    • If the local host runs a Linux OS, run the scp command.

      For example, to upload image01.qcow2 to the /usr/ directory on the ECS, run the following command:

      scp /var/image01.qcow2 root@xxx.xxx.xx.xxx:/usr/

      xxx.xxx.xx.xxx indicates the EIP bound to the ECS.

    • If the local host runs a Windows OS, use a file transfer tool, such as WinSCP, to upload the image file to the ECS.
  2. Obtain the qemu-img-hw software package, upload it to the ECS, and then decompress the package.
    Table 1 qemu-img-hw package

    Tool Package

    How to Obtain

    quick-import-tools

    https://obs-20181128.ims.obs.eu-de.otc.t-systems.com/DT-image-convert-tools.zip

    This tool can be used only on x86 servers.

  3. Convert the image format.
    1. Go to the directory where qemu-img-hw is stored, for example, /usr/quick-import-tools/qemu-img-hw.

      cd /usr/quick-import-tools/qemu-img-hw

    2. Run the following command to change file permissions:

      chmod +x qemu-img-hw

    3. Run the qemu-img-hw command to convert the image file to the ZVHD2 format.

      The command format of qemu-img-hw is as follows:

      ./qemu-img-hw convert -p -O Target_image_format Source_image_file Target_image_file

      For example, run the following command to convert an image01.qcow2 file to an image01.zvhd2 file:

      ./qemu-img-hw convert -p -O zvhd2 image01.qcow2 image01.zvhd2

Appendix 1: Common qemu-img-hw Commands

Appendix 2: Common Errors During qemu-img-hw Running