[libvirt] [PATCH] qemu_hotplug: fix crash in hot(un)plugging chardev devices

We need to make sure that the chardev is serial and TCP. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14af4e1..1003d50 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1729,7 +1729,9 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, if (qemuDomainChrPreInsert(vmdef, chr) < 0) goto cleanup; - if (cfg->chardevTLS) { + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + dev->type == VIR_DOMAIN_CHR_TYPE_TCP && + cfg->chardevTLS) { if (qemuBuildTLSx509BackendProps(cfg->chardevTLSx509certdir, dev->data.tcp.listen, cfg->chardevTLSx509verify, @@ -4398,7 +4400,9 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, sa_assert(tmpChr->info.alias); - if (cfg->chardevTLS && + if (tmpChr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + tmpChr->source.type == VIR_DOMAIN_CHR_TYPE_TCP && + cfg->chardevTLS && !(objAlias = qemuAliasTLSObjFromChardevAlias(tmpChr->info.alias))) goto cleanup; -- 2.10.1

On Tue, Oct 18, 2016 at 13:20:01 +0200, Pavel Hrdina wrote:
We need to make sure that the chardev is serial and TCP.
Note that it corrupts pointers in a different part of the union.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14af4e1..1003d50 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1729,7 +1729,9 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, if (qemuDomainChrPreInsert(vmdef, chr) < 0) goto cleanup;
- if (cfg->chardevTLS) { + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
This is relevant for all chardevs that have TCP transport not just the serial ones, thus only the actual backend dev should matter. ACK with that

On Tue, Oct 18, 2016 at 01:26:55PM +0200, Peter Krempa wrote:
On Tue, Oct 18, 2016 at 13:20:01 +0200, Pavel Hrdina wrote:
We need to make sure that the chardev is serial and TCP.
Note that it corrupts pointers in a different part of the union.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 14af4e1..1003d50 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1729,7 +1729,9 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, if (qemuDomainChrPreInsert(vmdef, chr) < 0) goto cleanup;
- if (cfg->chardevTLS) { + if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
This is relevant for all chardevs that have TCP transport not just the serial ones, thus only the actual backend dev should matter.
Right, I didn't realize that, thanks, I'll push it shortly.

On 10/18/2016 07:20 AM, Pavel Hrdina wrote:
We need to make sure that the chardev is serial and TCP.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
ACK - although you could put a few more details in the commit message and perhaps a short stack trace... John
participants (3)
-
John Ferlan
-
Pavel Hrdina
-
Peter Krempa