qemu: Prevent crash of libvirtd without guest agent

* src/qemu/qemu_process.c (qemuFindAgentConfig): avoid crash libvirtd due to
deref a NULL pointer.

* How to reproduce?
1. virsh edit the following xml into guest configuration:
    <channel type='pty'>
      <target type='virtio'/>
    </channel>
2. virsh start <domain>

or
% virt-install -n foo -r 1024 --disk path=/var/lib/libvirt/images/foo.img,size=1 \
--channel pty,target_type=virtio -l <installation tree>

Signed-off-by: Alex Jia <ajia@redhat.com>
This commit is contained in:
Alex Jia 2012-02-16 10:32:03 +08:00
parent e0d4b0db9e
commit 18942b9bea

View File

@ -194,7 +194,7 @@ qemuFindAgentConfig(virDomainDefPtr def)
if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
continue;
if (STREQ(channel->target.name, "org.qemu.guest_agent.0")) {
if (STREQ_NULLABLE(channel->target.name, "org.qemu.guest_agent.0")) {
config = &channel->source;
break;
}