From f072a21f3aef6779aaa77329578ae3677a685d85 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 3 May 2012 12:25:54 +0100 Subject: perl: Don't fail if 'type' (disk format) attribute is missing in libvirt XML (RHBZ#701814). Old versions of libvirt allowed you to define disks like this: ... Since the element does not have a 'type' attribute (which defines the format), we are supposed to do autodetection, so the format should be undefined. However what actually happened was that the code in Sys::Guestfs::Lib::open_guest received format as an empty string from the xpath query, causing libguestfs to give an error. If the xpath query returns the format as an empty string, undefine it. --- perl/lib/Sys/Guestfs/Lib.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'perl') diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 42d2e819..2ccc09af 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -234,7 +234,11 @@ sub open_guest # Get the disk format (may not be set). my $format = $p->find ('./driver/@type', $node); - $format = $format->to_literal if $format; + if ($format) { + $format = $format->to_literal; + } else { + undef $format; # RHBZ#701814. + } push @disks, [ $filename, $format ]; } -- cgit