Blame SOURCES/0041-v2v-o-rhv-upload-Don-t-require-of-raw-parameter.patch

97ae69
From 1b7f750e9244c6d0cd184ffa8a64461db70be263 Mon Sep 17 00:00:00 2001
97ae69
From: "Richard W.M. Jones" <rjones@redhat.com>
97ae69
Date: Fri, 20 Apr 2018 11:48:47 +0100
97ae69
Subject: [PATCH] =?UTF-8?q?v2v:=20-o=20rhv-upload:=20Don't=20require=20?=
97ae69
 =?UTF-8?q?=E2=80=98-of=20raw=E2=80=99=20parameter.?=
97ae69
MIME-Version: 1.0
97ae69
Content-Type: text/plain; charset=UTF-8
97ae69
Content-Transfer-Encoding: 8bit
97ae69
97ae69
Because we checked the limitation of raw+sparse during command line
97ae69
processing, it had the effect of forcing you to use ‘-of raw’ even if
97ae69
the input was already in raw format.  Move the checking to the output
97ae69
mode to avoid this.
97ae69
97ae69
Fixes commit cc04573927cca97de60d544d37467e67c25867a7.
97ae69
97ae69
(cherry picked from commit b3769afaece360b8a2095e3d8a7a934d351c3ade)
97ae69
---
97ae69
 v2v/cmdline.ml           |  5 -----
97ae69
 v2v/output_rhv_upload.ml | 18 +++++++++++++++++-
97ae69
 2 files changed, 17 insertions(+), 6 deletions(-)
97ae69
97ae69
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
97ae69
index 6321eb656..d0be1deb6 100644
97ae69
--- a/v2v/cmdline.ml
97ae69
+++ b/v2v/cmdline.ml
97ae69
@@ -589,11 +589,6 @@ read the man page virt-v2v(1).
97ae69
         | None ->
97ae69
            error (f_"-o rhv-upload: use ‘-oc’ to point to the oVirt or RHV server REST API URL, which is usually https://servername/ovirt-engine/api")
97ae69
         | Some oc -> oc in
97ae69
-      (* Output format / sparse must currently be raw+sparse.  We can
97ae69
-       * change this in future.  See TODO file for details. XXX
97ae69
-       *)
97ae69
-      if output_alloc <> Sparse || output_format <> Some "raw" then
97ae69
-        error (f_"-o rhv-upload: currently you must use ‘-of raw’ and you cannot use ‘-oa preallocated’ with this output mode.  These restrictions will be loosened in a future version.");
97ae69
       (* In theory we could make the password optional in future. *)
97ae69
       let output_password =
97ae69
         match output_password with
97ae69
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
97ae69
index 129461242..dc0d96d53 100644
97ae69
--- a/v2v/output_rhv_upload.ml
97ae69
+++ b/v2v/output_rhv_upload.ml
97ae69
@@ -169,6 +169,19 @@ See also \"OUTPUT TO RHV\" in the virt-v2v(1) manual.")
97ae69
       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.")
97ae69
   in
97ae69
 
97ae69
+  (* Output format/sparse must be raw/sparse.  We may be able to
97ae69
+   * lift this limitation in future, but it requires changes on the
97ae69
+   * RHV side.  See TODO file for details.  XXX
97ae69
+   *)
97ae69
+  let error_current_limitation required_param =
97ae69
+    error (f_"rhv-upload: currently you must use ‘%s’.  This restriction will be loosened in a future version.") required_param
97ae69
+  in
97ae69
+
97ae69
+  let error_unless_output_alloc_sparse () =
97ae69
+    if output_alloc <> Sparse then
97ae69
+      error_current_limitation "-oa sparse"
97ae69
+  in
97ae69
+
97ae69
   (* JSON parameters which are invariant between disks. *)
97ae69
   let json_params = [
97ae69
     "verbose", JSON.Bool (verbose ());
97ae69
@@ -220,6 +233,7 @@ object
97ae69
     error_unless_python_binary_on_path ();
97ae69
     error_unless_nbdkit_working ();
97ae69
     error_unless_nbdkit_python3_working ();
97ae69
+    error_unless_output_alloc_sparse ();
97ae69
     if have_selinux then
97ae69
       error_unless_nbdkit_compiled_with_selinux ()
97ae69
 
97ae69
@@ -260,7 +274,9 @@ object
97ae69
 
97ae69
         let disk_format =
97ae69
           match t.target_format with
97ae69
-          | ("raw" | "qcow2") as fmt -> fmt
97ae69
+          | "raw" as fmt -> fmt
97ae69
+          | "qcow2" ->
97ae69
+             error_current_limitation "-of raw"
97ae69
           | _ ->
97ae69
              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.")
97ae69
                    t.target_format in
97ae69
-- 
97ae69
2.17.1
97ae69