summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-05-03 12:25:54 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-05-14 15:41:44 +0100
commit7a17fd86168bc1e35d4817c8aebfb03d71e32d11 (patch)
tree8675a3c65ec23394f6cddacd950b67ab3e4f19ea
parente7120d25ac26dc1d05608310927dc03169547706 (diff)
downloadlibguestfs-7a17fd86168bc1e35d4817c8aebfb03d71e32d11.tar.gz
libguestfs-7a17fd86168bc1e35d4817c8aebfb03d71e32d11.tar.xz
libguestfs-7a17fd86168bc1e35d4817c8aebfb03d71e32d11.zip
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: <disk type='file' device='disk'> <driver name='qemu'/> ... Since the <driver> 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. (cherry picked from commit f072a21f3aef6779aaa77329578ae3677a685d85)
-rw-r--r--perl/lib/Sys/Guestfs/Lib.pm6
1 files changed, 5 insertions, 1 deletions
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 ];
}