From 9129643d26c275a7a25bae8757d7f0d1cd86433c Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 12 Apr 2023 12:41:35 +0200 Subject: [PATCH] qemuDomainChrInsertPreAlloced: Fix adding implicit console MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When hotpluging a device, we might need to add a device with it (because of some crazy backcompat). Now, hotplugging is done in several phases. In one of them, qemuDomainChrPreInsert() allocates space for both devices, and then qemuDomainChrInsertPreAlloced() actually inserts the device into domain definition and sets up the device with it. Except, the condition that checks whether to create the aliased is wrong as it compares nconsoles against 0. Surprisingly, qemuDomainChrInsertPreAllocCleanup() doesn't suffer from the same error. Fixes: daf51be5f1b0f7b41c0813d43d6b66edfbe4f6d9 Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/qemu/qemu_hotplug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3f45a48393..f517646c55 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1875,9 +1875,8 @@ qemuDomainChrInsertPreAlloced(virDomainDef *vmdef, virDomainChrDef *chr) { virDomainChrInsertPreAlloced(vmdef, chr); - if (vmdef->nserials == 1 && vmdef->nconsoles == 0 && + if (vmdef->nserials == 1 && vmdef->nconsoles == 1 && chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { - vmdef->nconsoles = 1; /* Create an console alias for the serial port */ vmdef->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;