File add_verbose_messaging.patch of Package virt-v2v

This patch adds basic verbose messages in the main virt-v2v code. The
usefulness of these messages is limited as the time spent outside of data
copying is trivial. However, when converting smaller guests, these messages
can act as progress markers and show where time is being spent.

---
 virt-v2v.pl |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff -Nurp a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
--- a/v2v/virt-v2v.pl	2013-09-24 08:36:09.676937320 -0600
+++ b/v2v/virt-v2v.pl	2013-09-24 08:35:59.548933189 -0600
@@ -366,6 +366,17 @@ my $list_profiles = 0;
 
 Display a list of target profile names specified in the configuration file.
 
+=cut
+
+my $verbose;
+
+=item B<-v | --verbose>
+
+Enable verbose message logging. Specifying this parameter multiple times
+increases verbosity by adding LIBGUESTFS_TRACE=1, and then LIBGUESTFS_DEBUG=1.
+
+=cut
+
 =item B<--help>
 
 Display brief help.
@@ -400,6 +411,13 @@ GetOptions ("help|?"      => sub {
                 print "$Sys::VirtConvert::VERSION\n";
                 exit(0);
             },
+            "v|verbose+"  => \$verbose,
+            "vv"          => sub {
+                $verbose  += 2;
+            },
+            "vvv"         => sub {
+                $verbose  += 3;
+            },
             "c|connect"   => sub {
                 # -c|--connect is the default for other virt tools. Be nice to
                 # the user and point out that virt-v2v is different.
@@ -449,6 +467,14 @@ GetOptions ("help|?"      => sub {
             "list-profiles" => \$list_profiles
 ) or pod2usage(2);
 
+# Enable higher levels of verbose logging
+if ((defined($verbose)) and ($verbose > 1)) {
+    $ENV{LIBGUESTFS_TRACE} = '1';
+    if ($verbose > 2) {
+        $ENV{LIBGUESTFS_DEBUG} = '1';
+    }
+}
+
 # Set the default configuration files if none are specified
 if (@config_files == 0) {
     push(@config_files, '/etc/virt-v2v.conf') if -r '/etc/virt-v2v.conf';
@@ -533,6 +559,10 @@ else {
 
 # Get an appropriate Source
 my $source;
+if (defined($verbose)) {
+    logmsg NOTICE, __x('Connecting to input '.
+                       '({input})', input => $input_method)
+}
 if ($input_method eq "libvirtxml") {
     my $path = shift(@ARGV) or
         pod2usage({ -message => __"You must specify a filename",
@@ -586,6 +616,10 @@ else {
 
 # Decide the name of the guest target.
 $output_name = $source->get_name() unless defined $output_name;
+if (defined($verbose)) {
+    logmsg NOTICE, __x('Validating guest: {output}',
+                       output => $output_name)
+}
 
 # Check that the guest doesn't already exist on the target
 v2vdie __x('Domain {name} already exists on the target.',
@@ -605,9 +639,14 @@ v2vdie __('Guest doesn\'t define any sto
     unless @{$meta->{disks}} > 0;
 
 # Copy source storage to target
+if (defined($verbose)) {
+    logmsg NOTICE, __x('Copying virtual machine storage to target '.
+                       '({output})', output => $output_method)
+}
 $source->copy_storage($target, $output_format, $output_sparse);
 
 # Open a libguestfs handle on the guest's storage devices
+if (defined($verbose)) { logmsg NOTICE, __x('Starting guestfs') }
 my @disks = map { [ $_->{device},
                     $_->{dst}->get_path(),
                     $_->{dst}->get_format() ] } @{$meta->{disks}};
@@ -635,13 +674,17 @@ my $guestcaps;
 my $root;
 eval {
     # Inspect the guest
+    if (defined($verbose)) { logmsg NOTICE, __x('Inspecting guest') }
     $root = inspect_guest($g, $transferdev);
 
     # Modify the guest and its metadata
+    if (defined($verbose)) { logmsg NOTICE, __x('Converting guest') }
     $guestcaps =
         Sys::VirtConvert::Converter->convert($g, $config, $root, $meta,
                                              \%options);
 
+    # Create the guest
+    if (defined($verbose)) { logmsg NOTICE, __x('Creating guest') }
     $target->create_guest($g, $root, $meta, $config, $guestcaps, $output_name);
 };