mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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