This patch has only slight modifications since originally posted as:
https://www.redhat.com/archives/libguestfs/2013-September/msg00031.html
Although these messages are not always valuable, these changes do show
progress when converting smaller guests. This patch also improves usability
with -vv and -vvv setting LIBGUESTFS_TRACE and LIBGUESTFS_DEBUG automatically.
---
v2v/virt-v2v.pl | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
index 5ae75ed..7a8bca8 100755
--- a/v2v/virt-v2v.pl
+++ b/v2v/virt-v2v.pl
@@ -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 storage devices')
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);
};
--
1.8.1.4