When using oVirt >= 4.3, we can enable the NBD based backend in imageio
by specifying that we transfer raw data when creating a transfer. With
the NBD backend, we can import to disks using qcow2 format.
To make it work, we override output#transfer_format to return always raw
format, but we create the disk on RHV side using qcow2 format.
The pipeline looks like this:
qemu-img convert <nbd> rhv-upload <http> imageio <nbd> qemu-nbd
---
v2v/output_rhv_upload.ml | 7 ++++---
v2v/rhv-upload-plugin.py | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
index 3514714b..7b5ad7a8 100644
--- a/v2v/output_rhv_upload.ml
+++ b/v2v/output_rhv_upload.ml
@@ -174,7 +174,7 @@ See also the virt-v2v-output-rhv(1) manual.")
error (f_"nbdkit was compiled without SELinux support. You will have to
recompile nbdkit with libselinux-devel installed, or else set SELinux to Permissive mode
while doing the conversion.")
in
- (* Output format/sparse must be raw/sparse. We may be able to
+ (* Output sparse must be sparse. We may be able to
* lift this limitation in future, but it requires changes on the
* RHV side. See TODO file for details. XXX
*)
@@ -287,6 +287,8 @@ object
method supported_firmware = [ TargetBIOS; TargetUEFI ]
+ method transfer_format t = "raw"
+
(* rhev-apt.exe will be installed (if available). *)
method install_rhev_apt = true
@@ -333,8 +335,7 @@ object
let disk_format =
match target_format with
| "raw" as fmt -> fmt
- | "qcow2" ->
- error_current_limitation "-of raw"
+ | "qcow2" as fmt -> fmt
| _ ->
error (f_"rhv-upload: -of %s: Only output format ‘raw’ or ‘qcow2’ is
supported. If the input is in a different format then force one of these output formats
by adding either ‘-of raw’ or ‘-of qcow2’ on the command line.")
target_format in
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index a9e82250..75e4f404 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -18,6 +18,7 @@
import builtins
import functools
+import inspect
import json
import logging
import socket
@@ -448,6 +449,8 @@ def create_disk(connection):
name = params['disk_name'],
description = "Uploaded by virt-v2v",
format = disk_format,
+ # XXX For qcow2 disk on block storage, we should use the estimated
+ # size, based on qemu-img measure of the overlay.
initial_size = params['disk_size'],
provisioned_size = params['disk_size'],
# XXX Ignores params['output_sparse'].
@@ -489,11 +492,16 @@ def create_transfer(connection, disk, host):
system_service = connection.system_service()
transfers_service = system_service.image_transfers_service()
+ extra = {}
+ if transfer_supports_format():
+ extra["format"] = types.DiskFormat.RAW
+
transfer = transfers_service.add(
types.ImageTransfer(
disk = types.Disk(id = disk.id),
host = host,
inactivity_timeout = 3600,
+ **extra,
)
)
@@ -591,6 +599,17 @@ def finalize_transfer(connection, transfer, disk_id):
"timed out waiting for transfer %s to finalize"
% transfer.id)
+def transfer_supports_format():
+ """
+ Return True if transfer supports the "format" argument, enabing the NBD
+ bakend on imageio side, which allows uploading to qcow2 images.
+
+ This feature was added in ovirt 4.3. We assume that the SDK version matches
+ engine version.
+ """
+ sig = inspect.signature(types.ImageTransfer)
+ return "format" in sig.parameters
+
# oVirt imageio operations
def parse_transfer_url(transfer):
--
2.21.0