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

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