Matthew Booth
2010-May-26 13:08 UTC
[Libguestfs] [PATCH] Windows: Display an error containing all missing when any are missing
Fixes RHBZ#596238 --- lib/Sys/VirtV2V/Converter/Windows.pm | 57 +++++++++++++++------------------ 1 files changed, 26 insertions(+), 31 deletions(-) diff --git a/lib/Sys/VirtV2V/Converter/Windows.pm b/lib/Sys/VirtV2V/Converter/Windows.pm index 8de2bcd..e55d0f3 100644 --- a/lib/Sys/VirtV2V/Converter/Windows.pm +++ b/lib/Sys/VirtV2V/Converter/Windows.pm @@ -181,9 +181,8 @@ sub _preconvert eval { $g->mkdir ("/temp"); }; eval { $g->mkdir ("/temp/v2v"); }; - _upload_viostor ($g, $tmpdir, $desc, $devices, $config); + _upload_files ($g, $tmpdir, $desc, $devices, $config); _add_viostor_to_registry ($g, $tmpdir, $desc, $devices, $config); - _upload_service ($g, $tmpdir, $desc, $devices, $config); _add_service_to_registry ($g, $tmpdir, $desc, $devices, $config); } @@ -343,7 +342,7 @@ sub _add_service_to_registry $g->upload ($tmpdir . "/system", $system_filename); } -sub _upload_viostor +sub _upload_files { my $g = shift; my $tmpdir = shift; @@ -351,39 +350,35 @@ sub _upload_viostor my $devices = shift; my $config = shift; - my $driverpath = "/windows/system32/drivers"; - $driverpath = $g->case_sensitive_path ($driverpath); + # Check we have all required files + my @missing; + my %files; - my ($app, $depnames) = $config->match_app ($desc, "viostor", $desc->{arch}); - $app = $config->get_transfer_path ($g, $app); - $g->cp ($app, $driverpath); -} + for my $file ("viostor", "firstboot", "firstbootapp", "rhsrvany") { + my ($path) = $config->match_app ($desc, $file, $desc->{arch}); + my $local = $config->get_transfer_path ($g, $path); + push (@missing, $path) unless ($g->exists($local)); -sub _upload_service -{ - my $g = shift; - my $tmpdir = shift; - my $desc = shift; - my $devices = shift; - my $config = shift; - - my $path = "/temp/v2v"; - $path = $g->case_sensitive_path ($path); + $files{$file} = $local; + } - my ($app, $depnames) - $config->match_app ($desc, "firstboot", $desc->{arch}); - $app = $config->get_transfer_path ($g, $app); - $g->cp ($app, $path); + # We can't proceed if there are any files missing + die(user_message(__x("Installation failed because the following ". + "files referenced in the configuration file are ". + "required, but missing: {list}", + list => join(' ', @missing)))) if (@missing > 0); - ($app, $depnames) - $config->match_app ($desc, "firstbootapp", $desc->{arch}); - $app = $config->get_transfer_path ($g, $app); - $g->cp ($app, $path); + # Copy viostor into place + my $driverpath = "/windows/system32/drivers"; + $driverpath = $g->case_sensitive_path ($driverpath); + $g->cp ($files{viostor}, $driverpath); - ($app, $depnames) - $config->match_app ($desc, "rhsrvany", $desc->{arch}); - $app = $config->get_transfer_path ($g, $app); - $g->cp ($app, $path); + # Copy other files into a temp directory + my $path = "/temp/v2v"; + $path = $g->case_sensitive_path ($path); + $g->cp ($files{firstboot}, $path); + $g->cp ($files{firstbootapp}, $path); + $g->cp ($files{rhsrvany}, $path); } =back -- 1.7.0.1
Richard W.M. Jones
2010-May-26 14:56 UTC
[Libguestfs] [PATCH] Windows: Display an error containing all missing when any are missing
On Wed, May 26, 2010 at 02:08:02PM +0100, Matthew Booth wrote:> Fixes RHBZ#596238Yup, seems to make sense. 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
Reasonably Related Threads
- [PATCH] Fix error in Converter::Windows when there is no transfer iso
- [PATCH v2v] Pre-convert Windows guests.
- [PATCH] Install VirtIO storage and network drivers in Windows
- [PATCH] Fix a Windows conversion error when C:\Temp exists in the guest
- [PATCH] Use RHN to retrieve replacement packages