v2v: bootloaders: Handle no Bootloader::Tools default section (RHBZ#1472208).

In SUSE guests, handle the case where
Bootloader::Tools::GetDefaultSection () returns undef.

Previously this would return an empty string and cause a bogus error
in subsequent code:

virt-v2v: error: libguestfs error: statns: statns_stub: path must start
with a / character
This commit is contained in:
Richard W.M. Jones
2017-07-18 10:59:34 +01:00
parent 024efc0f2f
commit ba41cf1a51

View File

@@ -287,10 +287,21 @@ object (self)
let cmd =
[| "/usr/bin/perl"; "-MBootloader::Tools"; "-e"; "
InitLibrary();
my $default = Bootloader::Tools::GetDefaultSection();
print $default->{image};
my $default = Bootloader::Tools::GetDefaultSection ();
if (!defined $default) {
print 'NODEFAULTSECTION'
}
elsif (exists $default->{image}) {
print $default->{image}
}
else {
die 'no $default->{image}' # should never happen
}
" |] in
Some (g#command cmd)
let res = g#command cmd in
(match res with
| "NODEFAULTSECTION" -> None
| _ -> Some res)
| MethodNone ->
None in
match res with