]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: cgroup: Fix crash if starting nographics guest
authorCole Robinson <crobinso@redhat.com>
Tue, 1 Oct 2013 11:55:19 +0000 (07:55 -0400)
committerCole Robinson <crobinso@redhat.com>
Tue, 1 Oct 2013 15:22:18 +0000 (11:22 -0400)
We can dereference graphics[0] even if guest has no graphics device
configured. I screwed this up in a216e6487255d3b65d97c7ec1fa5da63dbced902

https://bugzilla.redhat.com/show_bug.cgi?id=1014088

src/qemu/qemu_cgroup.c

index f95c7f2e678f0bc090aa765480c41fa5fa87ce04..ace7e3573a25b2e8c4a1ebbb064a9fe4f033dbc9 100644 (file)
@@ -490,9 +490,10 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
 
     if (vm->def->nsounds &&
         ((!vm->def->ngraphics && cfg->nogfxAllowHostAudio) ||
-         ((vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+         (vm->def->graphics &&
+          ((vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
            cfg->vncAllowHostAudio) ||
-           (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL)))) {
+           (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL))))) {
         rv = virCgroupAllowDeviceMajor(priv->cgroup, 'c', DEVICE_SND_MAJOR,
                                        VIR_CGROUP_DEVICE_RW);
         virDomainAuditCgroupMajor(vm, priv->cgroup, "allow", DEVICE_SND_MAJOR,