When adding the aliased serial stub console, the structure wasn't
properly allocated (VIR_ALLOC instead of virDomainChrDefNew) which then
resulted in SIGSEGV in virDomainChrSourceIsEqual during a serial device
coldplug.
https://bugzilla.redhat.com/show_bug.cgi?id=1434278
Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
src/qemu/qemu_hotplug.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4a7d99725..6701bd9bc 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1802,15 +1802,17 @@ qemuDomainChrPreInsert(virDomainDefPtr vmdef,
if (virDomainChrPreAlloc(vmdef, chr) < 0)
return -1;
- /* Due to some crazy backcompat stuff, the first serial device is an alias
- * to the first console too. If this is the case, the definition must be
- * duplicated as first console device. */
+ /* Due to historical reasons, the first console is an alias to the
+ * first serial device (if such exists). If this is the case, we need to
+ * create an object for the first console as well.
+ */
if (vmdef->nserials == 0 && vmdef->nconsoles == 0 &&
chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
if (!vmdef->consoles && VIR_ALLOC(vmdef->consoles) < 0)
return -1;
- if (VIR_ALLOC(vmdef->consoles[0]) < 0) {
+ /* We'll be dealing with serials[0] directly, so NULL is fine here. */
+ if (!(vmdef->consoles[0] = virDomainChrDefNew(NULL))) {
VIR_FREE(vmdef->consoles);
return -1;
}
@@ -1841,7 +1843,7 @@ qemuDomainChrInsertPreAllocCleanup(virDomainDefPtr vmdef,
/* Remove the stub console added by qemuDomainChrPreInsert */
if (vmdef->nserials == 0 && vmdef->nconsoles == 1 &&
chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) {
- VIR_FREE(vmdef->consoles[0]);
+ virDomainChrDefFree(vmdef->consoles[0]);
VIR_FREE(vmdef->consoles);
vmdef->nconsoles = 0;
}
--
2.13.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Jun 01, 2017 at 02:57:59PM +0200, Erik Skultety wrote: > When adding the aliased serial stub console, the structure wasn't > properly allocated (VIR_ALLOC instead of virDomainChrDefNew) which then > resulted in SIGSEGV in virDomainChrSourceIsEqual during a serial device > coldplug. > > https://bugzilla.redhat.com/show_bug.cgi?id=1434278 > > Signed-off-by: Erik Skultety <eskultet@redhat.com> > --- > src/qemu/qemu_hotplug.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > ping Erik -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Jun 01, 2017 at 14:57:59 +0200, Erik Skultety wrote: > When adding the aliased serial stub console, the structure wasn't > properly allocated (VIR_ALLOC instead of virDomainChrDefNew) which then > resulted in SIGSEGV in virDomainChrSourceIsEqual during a serial device > coldplug. > > https://bugzilla.redhat.com/show_bug.cgi?id=1434278 > > Signed-off-by: Erik Skultety <eskultet@redhat.com> > --- > src/qemu/qemu_hotplug.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) ACK, we do the same (crazy) thing in virDomainDefAddConsoleCompat -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.