From: Michal Privoznik Date: Wed, 12 Apr 2023 10:20:42 +0000 (+0200) Subject: qemuAssignDeviceChrAlias: Fix a crasher during hotplug X-Git-Tag: v9.3.0-rc1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc8320faef32e08a5ea70a1537c90f90fee8b04f;p=thirdparty%2Flibvirt.git qemuAssignDeviceChrAlias: Fix a crasher during hotplug For a running guest, a device can be hotunplugged. This will then remove also aliased . Trying to hotplug a device then, libvirtd crashed because it dereferences def->consoles while there's none. Fixes: 42d53ac799a1d7f1414737caa4deb73871876992 Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 85db7fbfe3..161d30cf72 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -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) {