X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs%2FLib.pm;h=bdc788e8cf924fa467eda6cf8ace94999a3f048b;hb=321ca1ef91a90cec5b94058b84420e8018e3f1d8;hp=fc3163f104d94f4f28d40ed6ae3d81452d17feb0;hpb=72324580801f2c0e2b702b430b90eb141618c7f4;p=libguestfs.git diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index fc3163f..bdc788e 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -25,7 +25,7 @@ use warnings; # make a change which is not backwards compatible. It is not related # to the libguestfs version number. use vars qw($VERSION); -$VERSION = '0.1'; +$VERSION = '0.2'; use Carp qw(croak); @@ -152,6 +152,13 @@ sub open_guest croak __"open_guest: first parameter must be a string or an arrayref" } + # Check each element of @images is defined. + # (See https://bugzilla.redhat.com/show_bug.cgi?id=601092#c3). + foreach (@images) { + croak __"open_guest: first argument contains undefined element" + unless defined $_; + } + my ($conn, $dom); if (-e $images[0]) { @@ -1119,7 +1126,8 @@ like: '/dev/VG/Root' => \%os, } -(There can be multiple roots for a multi-boot VM). +There can be multiple roots for a multi-boot VM, but this function +will throw an error if no roots (ie. OSes) could be found. The C<\%os> hash contains the following keys (any can be omitted): @@ -1202,6 +1210,11 @@ sub inspect_operating_systems } } + # If we didn't find any operating systems then it's an error (RHBZ#591142). + if (0 == keys %oses) { + die __"No operating system could be detected inside this disk image.\n\nThis may be because the file is not a disk image, or is not a virtual machine\nimage, or because the OS type is not understood by virt-inspector.\n\nIf you feel this is an error, please file a bug report including as much\ninformation about the disk image as possible.\n"; + } + return \%oses; } @@ -1814,13 +1827,6 @@ sub _find_modprobe_aliases # Initialise augeas $g->aug_init("/", 16); - # Register additional paths to the Modprobe lens - $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/modules.conf"); - $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/conf.modules"); - - # Make augeas reload - $g->aug_load(); - my %modprobe_aliases; for my $pattern qw(/files/etc/conf.modules/alias