libguestfs/SOURCES/0007-v2v-Add-op-output-password-file-option.patch

139 lines
5.4 KiB
Diff

From ae2d0a507af53563d0b70d28654c9c60a857fd10 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 22 Feb 2018 11:43:33 +0000
Subject: [PATCH] v2v: Add -op (output password file) option.
Currently unused, in a future commit this will allow you to pass in a
password to be used when connecting to the target hypervisor.
(cherry picked from commit a4e181137a38f5767dd1bf05dc482959cb7283be)
---
v2v/cmdline.ml | 18 ++++++++++++++++++
v2v/test-v2v-docs.sh | 2 +-
v2v/virt-v2v.pod | 7 +++++++
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 75909ee77..2a067741e 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -62,6 +62,7 @@ let parse_cmdline () =
let output_conn = ref None in
let output_format = ref None in
let output_name = ref None in
+ let output_password = ref None in
let output_storage = ref None in
let password_file = ref None in
let vddk_config = ref None in
@@ -219,6 +220,8 @@ let parse_cmdline () =
s_"Set output format";
[ M"on" ], Getopt.String ("name", set_string_option_once "-on" output_name),
s_"Rename guest when converting";
+ [ M"op" ], Getopt.String ("filename", set_string_option_once "-op" output_password),
+ s_"Use password from file to connect to output hypervisor";
[ M"os" ], Getopt.String ("storage", set_string_option_once "-os" output_storage),
s_"Set output storage location";
[ L"password-file" ], Getopt.String ("file", set_string_option_once "--password-file" password_file),
@@ -314,6 +317,7 @@ read the man page virt-v2v(1).
let output_format = !output_format in
let output_mode = !output_mode in
let output_name = !output_name in
+ let output_password = !output_password in
let output_storage = !output_storage in
let password_file = !password_file in
let print_source = !print_source in
@@ -461,6 +465,8 @@ read the man page virt-v2v(1).
| `Glance ->
if output_conn <> None then
error_option_cannot_be_used_in_output_mode "glance" "-oc";
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "glance" "-op";
if output_storage <> None then
error_option_cannot_be_used_in_output_mode "glance" "-os";
if qemu_boot then
@@ -472,6 +478,8 @@ read the man page virt-v2v(1).
| `Not_set
| `Libvirt ->
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "libvirt" "-op";
let output_storage = Option.default "default" output_storage in
if qemu_boot then
error_option_cannot_be_used_in_output_mode "libvirt" "--qemu-boot";
@@ -481,6 +489,8 @@ read the man page virt-v2v(1).
output_format, output_alloc
| `Local ->
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "local" "-op";
let os =
match output_storage with
| None ->
@@ -500,6 +510,8 @@ read the man page virt-v2v(1).
error_option_cannot_be_used_in_output_mode "null" "-oc";
if output_format <> None then
error_option_cannot_be_used_in_output_mode "null" "-of";
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "null" "-op";
if output_storage <> None then
error_option_cannot_be_used_in_output_mode "null" "-os";
if qemu_boot then
@@ -509,6 +521,8 @@ read the man page virt-v2v(1).
Some "raw", Sparse
| `QEmu ->
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "qemu" "-op";
let os =
match output_storage with
| None ->
@@ -520,6 +534,8 @@ read the man page virt-v2v(1).
output_format, output_alloc
| `RHV ->
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "rhv" "-op";
let os =
match output_storage with
| None ->
@@ -531,6 +547,8 @@ read the man page virt-v2v(1).
output_format, output_alloc
| `VDSM ->
+ if output_password <> None then
+ error_option_cannot_be_used_in_output_mode "vdsm" "-op";
let os =
match output_storage with
| None ->
diff --git a/v2v/test-v2v-docs.sh b/v2v/test-v2v-docs.sh
index 5d034c465..0e3bd916a 100755
--- a/v2v/test-v2v-docs.sh
+++ b/v2v/test-v2v-docs.sh
@@ -22,4 +22,4 @@ $TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-v2v.pod virt-v2v \
- --ignore=--debug-overlay,--ic,--if,--it,--no-trim,--oa,--oc,--of,--on,--os,--vmtype
+ --ignore=--debug-overlay,--ic,--if,--it,--no-trim,--oa,--oc,--of,--on,--op,--os,--vmtype
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 0ea5fa97f..00ba45555 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -569,6 +569,13 @@ If not specified, then the input format is used.
Rename the guest when converting it. If this option is not used then
the output name is the same as the input name.
+=item B<-op> file
+
+Supply a file containing a password to be used when connecting to the
+target hypervisor. Note the file should contain the whole password,
+B<without any trailing newline>, and for security the file should have
+mode C<0600> so that others cannot read it.
+
=item B<-os> storage
The location of the storage for the converted guest.
--
2.21.0