As a followup to the discussion on verbose logging for virt-v2v, this patch
adds basic verbose messages in the main virt-v2v code. As Matt pointed out,
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. (As I already
added this code for my testing, I thought it might be worth discussing further
here.)
This patch adds the following startup options:
-v | --verbose
Enables verbose messages logging
-vv
Verbose messages, plus sets LIBGUESTFS_TRACE=1
-vvv
Verbose messages, plus sets LIBGUESTFS_TRACE=1 and LIBGUESTFS_DEBUG=1
---
v2v/virt-v2v.pl | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl
index 3832f67..eddcd16 100755
--- a/v2v/virt-v2v.pl
+++ b/v2v/virt-v2v.pl
@@ -354,6 +354,24 @@ 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.
+
+=item B<-vv>
+
+Verbose messages, plus sets LIBGUESTFS_TRACE=1.
+
+=item B<-vvv>
+
+Verbose messages, plus sets LIBGUESTFS_TRACE=1 and LIBGUESTFS_DEBUG=1.
+
+=cut
+
=item B<--help>
Display brief help.
@@ -388,6 +406,16 @@ GetOptions ("help|?" => sub {
print "$Sys::VirtConvert::VERSION\n";
exit(0);
},
+ "v|verbose" => \$verbose,
+ "vv" => sub {
+ $verbose = 1;
+ $ENV{LIBGUESTFS_TRACE} = '1';
+ },
+ "vvv" => sub {
+ $verbose = 1;
+ $ENV{LIBGUESTFS_TRACE} = '1';
+ $ENV{LIBGUESTFS_DEBUG} = '1';
+ },
"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.
@@ -521,6 +549,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",
@@ -574,6 +606,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.',
@@ -593,9 +629,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}};
@@ -623,13 +664,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