mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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