[libvirt] [PATCH] qemu: Avoid crash in qemuDiskGetActualType
Peter Krempa
pkrempa at redhat.com
Wed Jan 22 10:42:06 UTC 2014
On 01/22/14 11:30, Osier Yang wrote:
> On 22/01/14 18:18, Peter Krempa wrote:
>> Libvirtd would crash if a domain contained an empty cdrom drive of
>> type='volume' as the disk def->srcpool member would be dereferenced. Fix
>> it by checking if the source pool is present before dereferencing it.
>>
>> Also alter tests to catch this issue in the future.
>>
>> Reported by: Kevin Shanahan
>> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056328
>> ---
>> src/qemu/qemu_conf.c | 2 +-
>> tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args | 2 ++
>> tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml | 6 ++++++
>> 3 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
>> index 4378791..ac53f6d 100644
>> --- a/src/qemu/qemu_conf.c
>> +++ b/src/qemu/qemu_conf.c
>> @@ -1302,7 +1302,7 @@ cleanup:
>> int
>> qemuDiskGetActualType(virDomainDiskDefPtr def)
>> {
>> - if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME)
>> + if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
>> return def->srcpool->actualtype;
>>
>>
>
> Returning the type as "volume" should be fine, since there is no
> "case" statement for "volume" type when building the drive's
> command line, and the "source" is empty anyway.
>
> ACK.
Pushed; Thanks.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140122/466dcc2e/attachment-0001.sig>
More information about the libvir-list
mailing list