Matthew Booth
2010-May-04 17:16 UTC
[Libguestfs] [PATCH] Config: Don't require all referenced software to be available
Currently virt-v2v attempts to create an iso containing all software referenced in the config file before starting. If any software isn't available it displays an error and exits immediately. With this change it will ignore software which isn't available at iso creation time. Instead, it will only display an error if the unavailable software is actually required. This is much kinder to the casual user using the default configuration file. --- lib/Sys/VirtV2V/Config.pm | 41 ++++++++++++++++++++++++++++++----------- 1 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/Sys/VirtV2V/Config.pm b/lib/Sys/VirtV2V/Config.pm index 117b55b..57bf24a 100644 --- a/lib/Sys/VirtV2V/Config.pm +++ b/lib/Sys/VirtV2V/Config.pm @@ -107,6 +107,7 @@ sub get_transfer_iso # config file # We use a hash here to avoid duplicates my %path_args; + my %paths; foreach my $path ($dom->findnodes('/virt-v2v/app/path/text()')) { $path = $path->getData(); @@ -118,12 +119,10 @@ sub get_transfer_iso $abs = $path; } - # Check the referenced path is accessible - die(user_message(__x("Unable to access {path} referenced in ". - "the config file", - path => $path))) unless (-r $abs); - - $path_args{"$path=$abs"} = 1; + if (-r $abs) { + $path_args{"$path=$abs"} = 1; + $paths{$abs} = 1; + } } # Nothing further to do if there are no paths @@ -140,16 +139,27 @@ sub get_transfer_iso # Check if the transfer iso exists, and is newer than the config file if (-e $iso_path) { my $iso_st = stat($iso_path) - or die(user_message(__x("Unable to stat iso file {path}: {error}", + or die(user_message(__x("Unable to stat {path}: {error}", path => $iso_path, error => $!))); my $config_st = stat($self->{path}) - or die(user_message(__x("Unable to stat config file {path}: ". - "{error}", + or die(user_message(__x("Unable to stat {path}: {error}", path => $self->{path}, error => $!))); - # Don't need to re-create if the iso file is newer than the config file - return $iso_path if ($iso_st->mtime > $config_st->mtime); + if ($iso_st->mtime > $config_st->mtime) { + my $rebuild = 0; + + foreach my $path (keys(%paths)) { + my $path_st = stat($path); + + if ($path_st->mtime > $iso_st->mtime) { + $rebuild = 1; + last; + } + } + + return $iso_path if (!$rebuild); + } } # Re-create the transfer iso @@ -247,6 +257,15 @@ sub match_app xml => $app->toString()))) unless (defined($path)); $path = $path->getData(); + my ($pathroot) = $dom->findnodes('/virt-v2v/path-root/text()'); + my $abs = defined($pathroot) ? $pathroot->getData()."/$path" : $path; + + die(user_message(__x("Matched local file {path} for {search}. ". + "However, this file is not available.", + path => $abs, + search => get_app_search($desc, $name, $arch)))) + unless (-r $abs); + my @deps; foreach my $dep ($app->findnodes('dep/text()')) { push(@deps, $dep->getData()); -- 1.6.6.1
Richard W.M. Jones
2010-May-04 17:39 UTC
[Libguestfs] [PATCH] Config: Don't require all referenced software to be available
On Tue, May 04, 2010 at 06:16:27PM +0100, Matthew Booth wrote:> Currently virt-v2v attempts to create an iso containing all software referenced > in the config file before starting. If any software isn't available it displays > an error and exits immediately. > > With this change it will ignore software which isn't available at iso creation > time. Instead, it will only display an error if the unavailable software is > actually required. This is much kinder to the casual user using the default > configuration file.Looks OK, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Apparently Analagous Threads
- [PATCH] Move all interaction with the config file into Sys::VirtV2V::Config
- [PATCH] Unconditionally always rebuild the transfer iso
- [PATCH] Config: Check timestamps on directories when rebuilding transfer iso
- [PATCH 1/6] Convert config file to XML, and translate networks/bridge for all connections
- [PATCH 1/2] Config: NFC: always create and pass round a Config object