Blob Blame History Raw
From 34ab1cf2d4f849b69a01ddb2eb7e87c80523f03f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Jun 2016 13:53:37 +0100
Subject: [PATCH] p2v: Add --verbose option to virt-p2v-make-{disk,kickstart}.

For virt-p2v-make-kickstart this doesn't do very much.  But for
virt-p2v-make-disk it enables verbose mode in virt-builder which is
extremely useful for debugging problems.

Thanks: Ming Xie.
(cherry picked from commit 6358633bf22d19c1bc9b9638dfff8e5ac50a37eb)
---
 p2v/virt-p2v-make-disk.in       | 13 ++++++++++++-
 p2v/virt-p2v-make-disk.pod      |  7 +++++++
 p2v/virt-p2v-make-kickstart.in  |  9 +++++++--
 p2v/virt-p2v-make-kickstart.pod |  7 +++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in
index 88c171f..d58e7f1 100644
--- a/p2v/virt-p2v-make-disk.in
+++ b/p2v/virt-p2v-make-disk.in
@@ -24,7 +24,7 @@ version="@PACKAGE_VERSION@"
 
 TEMP=`getopt \
         -o o:V \
-        --long help,inject-ssh-identity:,output:,version \
+        --long help,inject-ssh-identity:,output:,verbose,version \
         -n $program -- "$@"`
 if [ $? != 0 ]; then
     echo "$program: problem parsing the command line arguments"
@@ -34,6 +34,7 @@ eval set -- "$TEMP"
 
 output=
 upload=
+verbose=
 
 usage ()
 {
@@ -52,6 +53,10 @@ while true; do
         -o|--output)
             output="$2"
             shift 2;;
+        -v|--verbose)
+            set +x
+            verbose=1
+            shift;;
         -V|--version)
             echo "$program $version"
             exit 0;;
@@ -170,9 +175,15 @@ while read line; do
     fi
 done < $depsfile
 
+# Add -v -x if we're in verbose mode.
+if [ "x$verbose" = "x1" ]; then
+    verbose_option="-v -x"
+fi
+
 # Run virt-builder.  Note we controversially assume systemd here.  We
 # could provide a sysvinit fallback if required.
 virt-builder "$osversion"                                       \
+    $verbose_option						\
     --output "$output"                                          \
     --update                                                    \
     --install "$install"                                        \
diff --git a/p2v/virt-p2v-make-disk.pod b/p2v/virt-p2v-make-disk.pod
index 79bf499..d5a5db5 100644
--- a/p2v/virt-p2v-make-disk.pod
+++ b/p2v/virt-p2v-make-disk.pod
@@ -106,6 +106,13 @@ See L</ADDING AN SSH IDENTITY> above.
 Write output to C<OUTPUT>, which can be a local file or block device.
 B<The existing contents of the device will be erased>.
 
+=item B<-v>
+
+=item B<--verbose>
+
+Enable verbose output.  Use this if you need to debug problems with
+the script or if you are filing a bug.
+
 =item B<-V>
 
 =item B<--version>
diff --git a/p2v/virt-p2v-make-kickstart.in b/p2v/virt-p2v-make-kickstart.in
index 74bee61..8a6e4d8 100644
--- a/p2v/virt-p2v-make-kickstart.in
+++ b/p2v/virt-p2v-make-kickstart.in
@@ -23,8 +23,8 @@ program="virt-p2v-make-kickstart"
 version="@PACKAGE_VERSION@"
 
 TEMP=`getopt \
-        -o o:V \
-        --long help,inject-ssh-identity:,output:,proxy:,version \
+        -o o:vV \
+        --long help,inject-ssh-identity:,output:,proxy:,verbose,version \
         -n $program -- "$@"`
 if [ $? != 0 ]; then
     echo "$program: problem parsing the command line arguments"
@@ -44,6 +44,7 @@ usage ()
 output=p2v.ks
 proxy=
 ssh_identity=
+verbose=
 
 while true; do
     case "$1" in
@@ -59,6 +60,10 @@ while true; do
         --repo)
             repo="$2"
             shift 2;;
+        -v|--verbose)
+            set +x
+            verbose=1
+            shift;;
         -V|--version)
             echo "$program $version"
             exit 0;;
diff --git a/p2v/virt-p2v-make-kickstart.pod b/p2v/virt-p2v-make-kickstart.pod
index 6e65c07..cea3787 100644
--- a/p2v/virt-p2v-make-kickstart.pod
+++ b/p2v/virt-p2v-make-kickstart.pod
@@ -254,6 +254,13 @@ F<p2v.ks> in the current directory.
 
 Tell the kickstart to use a proxy server or web cache for downloads.
 
+=item B<-v>
+
+=item B<--verbose>
+
+Enable verbose output.  Use this if you need to debug problems with
+the script or if you are filing a bug.
+
 =item B<-V>
 
 =item B<--version>
-- 
1.8.3.1