From 4d5509a98823cc0b8930678716b862adbd2c0b81 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 6 Aug 2021 13:01:28 +0100 Subject: [PATCH 01/12] Revert "v2v: Remove -o rhv-upload -oa preallocated" This reverts commit 18084f90d9dd9092831cb3487039328981796291. --- v2v/cmdline.ml | 2 +- v2v/output_rhv_upload.ml | 22 ++++++++++++++++++++-- v2v/output_rhv_upload.mli | 7 ++++--- v2v/rhv-upload-transfer.py | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index 79d943df..5e7c01f8 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -699,7 +699,7 @@ read the man page virt-v2v(1). | Some os -> os in if qemu_boot then error_option_cannot_be_used_in_output_mode "rhv-upload" "--qemu-boot"; - Output_rhv_upload.output_rhv_upload output_conn + Output_rhv_upload.output_rhv_upload output_alloc output_conn output_password os rhv_options, output_format, output_alloc diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml index 6a632eaa..50baa595 100644 --- a/v2v/output_rhv_upload.ml +++ b/v2v/output_rhv_upload.ml @@ -146,11 +146,22 @@ let error_unless_nbdkit_compiled_with_selinux config = 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.") ) +(* 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 + *) +let error_current_limitation required_param = + error (f_"rhv-upload: currently you must use ā€˜%sā€™. This restriction will be loosened in a future version.") required_param + +let error_unless_output_alloc_sparse output_alloc = + if output_alloc <> Sparse then + error_current_limitation "-oa sparse" + let json_optstring = function | Some s -> JSON.String s | None -> JSON.Null -class output_rhv_upload output_conn +class output_rhv_upload output_alloc output_conn output_password output_storage rhv_options = (* Create a temporary directory which will be deleted on exit. *) @@ -189,6 +200,9 @@ class output_rhv_upload output_conn "output_conn", JSON.String output_conn; "output_password", JSON.String output_password; "output_storage", JSON.String output_storage; + "output_sparse", JSON.Bool (match output_alloc with + | Sparse -> true + | Preallocated -> false); "rhv_cafile", json_optstring rhv_options.rhv_cafile; "rhv_cluster", JSON.String (Option.default "Default" rhv_options.rhv_cluster); @@ -257,6 +271,7 @@ object error_unless_nbdkit_min_version config; error_unless_nbdkit_python_plugin_working plugin_script; error_unless_nbdkit_compiled_with_selinux config; + error_unless_output_alloc_sparse output_alloc; (* Python code prechecks. *) let json_params = match rhv_options.rhv_disk_uuids with @@ -282,6 +297,9 @@ object method as_options = "-o rhv-upload" ^ + (match output_alloc with + | Sparse -> "" (* default, don't need to print it *) + | Preallocated -> " -oa preallocated") ^ sprintf " -oc %s -op %s -os %s" output_conn output_password output_storage @@ -449,7 +467,7 @@ object (* Create the metadata. *) let ovf = Create_ovf.create_ovf source inspect target_meta targets - Sparse sd_uuid disk_uuids vol_uuids vm_uuid + output_alloc sd_uuid disk_uuids vol_uuids vm_uuid OVirt in let ovf = DOM.doc_to_string ovf in diff --git a/v2v/output_rhv_upload.mli b/v2v/output_rhv_upload.mli index 01507dff..eb85a57d 100644 --- a/v2v/output_rhv_upload.mli +++ b/v2v/output_rhv_upload.mli @@ -25,8 +25,9 @@ val print_output_options : unit -> unit val parse_output_options : (string * string) list -> rhv_options (** Print and parse rhv-upload -oo options. *) -val output_rhv_upload : string -> string -> string -> rhv_options -> - Types.output -(** [output_rhv_upload output_conn output_password output_storage rhv_options] +val output_rhv_upload : Types.output_allocation -> string -> string -> + string -> rhv_options -> Types.output +(** [output_rhv_upload output_alloc output_conn output_password output_storage + rhv_options] creates and returns a new {!Types.output} object specialized for writing output to oVirt or RHV directly via RHV APIs. *) diff --git a/v2v/rhv-upload-transfer.py b/v2v/rhv-upload-transfer.py index cf4f8807..5aebcd1d 100644 --- a/v2v/rhv-upload-transfer.py +++ b/v2v/rhv-upload-transfer.py @@ -111,6 +111,7 @@ def create_disk(connection): # size, based on qemu-img measure of the overlay. initial_size=params['disk_size'], provisioned_size=params['disk_size'], + # XXX Ignores params['output_sparse']. # Handling this properly will be complex, see: # https://www.redhat.com/archives/libguestfs/2018-March/msg00177.html sparse=True, -- 2.31.1