mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0034-v2v-Add-op-output-password-file-option.patch

e9bfca
From 2d80f9e648fc4c7598f77dc0c15faeaacf63137d Mon Sep 17 00:00:00 2001
e9bfca
From: "Richard W.M. Jones" <rjones@redhat.com>
e9bfca
Date: Thu, 22 Feb 2018 11:43:33 +0000
e9bfca
Subject: [PATCH] v2v: Add -op (output password file) option.
e9bfca
e9bfca
Currently unused, in a future commit this will allow you to pass in a
e9bfca
password to be used when connecting to the target hypervisor.
e9bfca
e9bfca
(cherry picked from commit a4e181137a38f5767dd1bf05dc482959cb7283be)
e9bfca
---
e9bfca
 v2v/cmdline.ml       | 18 ++++++++++++++++++
e9bfca
 v2v/test-v2v-docs.sh |  2 +-
e9bfca
 v2v/virt-v2v.pod     |  7 +++++++
e9bfca
 3 files changed, 26 insertions(+), 1 deletion(-)
e9bfca
e9bfca
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
e9bfca
index e80b0689b..bfdc250fc 100644
e9bfca
--- a/v2v/cmdline.ml
e9bfca
+++ b/v2v/cmdline.ml
e9bfca
@@ -62,6 +62,7 @@ let parse_cmdline () =
e9bfca
   let output_conn = ref None in
e9bfca
   let output_format = ref None in
e9bfca
   let output_name = ref None in
e9bfca
+  let output_password = ref None in
e9bfca
   let output_storage = ref None in
e9bfca
   let password_file = ref None in
e9bfca
   let vddk_config = ref None in
e9bfca
@@ -218,6 +219,8 @@ let parse_cmdline () =
e9bfca
                                     s_"Set output format";
e9bfca
     [ M"on" ],       Getopt.String ("name", set_string_option_once "-on" output_name),
e9bfca
                                     s_"Rename guest when converting";
e9bfca
+    [ M"op" ],       Getopt.String ("filename", set_string_option_once "-op" output_password),
e9bfca
+                                    s_"Use password from file to connect to output hypervisor";
e9bfca
     [ M"os" ],       Getopt.String ("storage", set_string_option_once "-os" output_storage),
e9bfca
                                     s_"Set output storage location";
e9bfca
     [ L"password-file" ], Getopt.String ("file", set_string_option_once "--password-file" password_file),
e9bfca
@@ -312,6 +315,7 @@ read the man page virt-v2v(1).
e9bfca
   let output_format = !output_format in
e9bfca
   let output_mode = !output_mode in
e9bfca
   let output_name = !output_name in
e9bfca
+  let output_password = !output_password in
e9bfca
   let output_storage = !output_storage in
e9bfca
   let password_file = !password_file in
e9bfca
   let print_source = !print_source in
e9bfca
@@ -462,6 +466,8 @@ read the man page virt-v2v(1).
e9bfca
     | `Glance ->
e9bfca
       if output_conn <> None then
e9bfca
         error_option_cannot_be_used_in_output_mode "glance" "-oc";
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "glance" "-op";
e9bfca
       if output_storage <> None then
e9bfca
         error_option_cannot_be_used_in_output_mode "glance" "-os";
e9bfca
       if qemu_boot then
e9bfca
@@ -473,6 +479,8 @@ read the man page virt-v2v(1).
e9bfca
 
e9bfca
     | `Not_set
e9bfca
     | `Libvirt ->
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "libvirt" "-op";
e9bfca
       let output_storage = Option.default "default" output_storage in
e9bfca
       if qemu_boot then
e9bfca
         error_option_cannot_be_used_in_output_mode "libvirt" "--qemu-boot";
e9bfca
@@ -482,6 +490,8 @@ read the man page virt-v2v(1).
e9bfca
       output_format, output_alloc
e9bfca
 
e9bfca
     | `Local ->
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "local" "-op";
e9bfca
       let os =
e9bfca
         match output_storage with
e9bfca
         | None ->
e9bfca
@@ -501,6 +511,8 @@ read the man page virt-v2v(1).
e9bfca
         error_option_cannot_be_used_in_output_mode "null" "-oc";
e9bfca
       if output_format <> None then
e9bfca
         error_option_cannot_be_used_in_output_mode "null" "-of";
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "null" "-op";
e9bfca
       if output_storage <> None then
e9bfca
         error_option_cannot_be_used_in_output_mode "null" "-os";
e9bfca
       if qemu_boot then
e9bfca
@@ -510,6 +522,8 @@ read the man page virt-v2v(1).
e9bfca
       Some "raw", Sparse
e9bfca
 
e9bfca
     | `QEmu ->
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "qemu" "-op";
e9bfca
       let os =
e9bfca
         match output_storage with
e9bfca
         | None ->
e9bfca
@@ -523,6 +537,8 @@ read the man page virt-v2v(1).
e9bfca
       output_format, output_alloc
e9bfca
 
e9bfca
     | `RHV ->
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "rhv" "-op";
e9bfca
       let os =
e9bfca
         match output_storage with
e9bfca
         | None ->
e9bfca
@@ -534,6 +550,8 @@ read the man page virt-v2v(1).
e9bfca
       output_format, output_alloc
e9bfca
 
e9bfca
     | `VDSM ->
e9bfca
+      if output_password <> None then
e9bfca
+        error_option_cannot_be_used_in_output_mode "vdsm" "-op";
e9bfca
       let os =
e9bfca
         match output_storage with
e9bfca
         | None ->
e9bfca
diff --git a/v2v/test-v2v-docs.sh b/v2v/test-v2v-docs.sh
e9bfca
index c8ca193eb..bb1ddefd7 100755
e9bfca
--- a/v2v/test-v2v-docs.sh
e9bfca
+++ b/v2v/test-v2v-docs.sh
e9bfca
@@ -22,4 +22,4 @@ $TEST_FUNCTIONS
e9bfca
 skip_if_skipped
e9bfca
 
e9bfca
 $top_srcdir/podcheck.pl virt-v2v.pod virt-v2v \
e9bfca
-  --ignore=--debug-overlay,--ic,--if,--in-place,--it,--no-trim,--oa,--oc,--of,--on,--os,--vmtype
e9bfca
+  --ignore=--debug-overlay,--ic,--if,--in-place,--it,--no-trim,--oa,--oc,--of,--on,--op,--os,--vmtype
e9bfca
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
e9bfca
index d81a2339c..4df3791a9 100644
e9bfca
--- a/v2v/virt-v2v.pod
e9bfca
+++ b/v2v/virt-v2v.pod
e9bfca
@@ -442,6 +442,13 @@ If not specified, then the input format is used.
e9bfca
 Rename the guest when converting it.  If this option is not used then
e9bfca
 the output name is the same as the input name.
e9bfca
 
e9bfca
+=item B<-op> file
e9bfca
+
e9bfca
+Supply a file containing a password to be used when connecting to the
e9bfca
+target hypervisor.  Note the file should contain the whole password,
e9bfca
+B<without any trailing newline>, and for security the file should have
e9bfca
+mode C<0600> so that others cannot read it.
e9bfca
+
e9bfca
 =item B<-os> storage
e9bfca
 
e9bfca
 The location of the storage for the converted guest.
e9bfca
-- 
8ff76f
2.20.1
e9bfca