]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuAssignDeviceChrAlias: Fix a crasher during <console/> hotplug
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 12 Apr 2023 10:20:42 +0000 (12:20 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Apr 2023 14:02:35 +0000 (16:02 +0200)
For a running guest, a <serial/> device can be hotunplugged. This
will then remove also aliased <console/>. Trying to hotplug a
<console/> device then, libvirtd crashed because it dereferences
def->consoles while there's none.

Fixes: 42d53ac799a1d7f1414737caa4deb73871876992
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_alias.c

index 85db7fbfe39a4f842c1362ce671e9f4116d2812b..161d30cf72b52fc11ed7821a4661b255f9ed20fd 100644 (file)
@@ -95,6 +95,7 @@ qemuAssignDeviceChrAlias(virDomainDef *def,
     if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
         chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL &&
         def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
+        def->nconsoles &&
         def->consoles[0] == chr &&
         def->nserials &&
         def->serials[0]->info.alias) {