diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-05-03 12:25:54 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-05-03 12:30:05 +0100 |
commit | f072a21f3aef6779aaa77329578ae3677a685d85 (patch) | |
tree | e06171c39af7e1576bb1fb18a200d5c1de682a11 | |
parent | 66a525ce5a4e95fb8576ea183e06e1eb730a135d (diff) | |
download | libguestfs-f072a21f3aef6779aaa77329578ae3677a685d85.tar.gz libguestfs-f072a21f3aef6779aaa77329578ae3677a685d85.tar.xz libguestfs-f072a21f3aef6779aaa77329578ae3677a685d85.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.
-rw-r--r-- | perl/lib/Sys/Guestfs/Lib.pm | 6 |
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 ]; } |