diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 848937c66a9cba6cc5f8f0c71c08e6f6a2e73285..828216250777b2ff31461f5587970a1207d1e0c5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4949,10 +4949,10 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir, dev->data.tcp.listen, cfg->chardevTLSx509verify, - alias, qemuCaps) < 0) + charAlias, qemuCaps) < 0) goto error; - if (!(objalias = qemuAliasTLSObjFromChardevAlias(alias))) + if (!(objalias = qemuAliasTLSObjFromChardevAlias(charAlias))) goto error; virBufferAsprintf(&buf, ",tls-creds=%s", objalias); VIR_FREE(objalias); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index af8758115456657e16064bfbc417c8ed2aeeaea2..2cb2267da38d5c9078b5258d0acc10650a67a9a2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1738,7 +1738,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, &tlsProps) < 0) goto cleanup; - if (!(tlsAlias = qemuAliasTLSObjFromChardevAlias(chr->info.alias))) + if (!(tlsAlias = qemuAliasTLSObjFromChardevAlias(charAlias))) goto cleanup; dev->data.tcp.tlscreds = true; } @@ -4387,6 +4387,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, virDomainChrDefPtr tmpChr; char *objAlias = NULL; char *devstr = NULL; + char *charAlias = NULL; if (!(tmpChr = virDomainChrFind(vmdef, chr))) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -4399,9 +4400,12 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, sa_assert(tmpChr->info.alias); + if (!(charAlias = qemuAliasChardevFromDevAlias(tmpChr->info.alias))) + goto cleanup; + if (tmpChr->source.type == VIR_DOMAIN_CHR_TYPE_TCP && cfg->chardevTLS && - !(objAlias = qemuAliasTLSObjFromChardevAlias(tmpChr->info.alias))) + !(objAlias = qemuAliasTLSObjFromChardevAlias(charAlias))) goto cleanup; if (qemuBuildChrDeviceStr(&devstr, vmdef, chr, priv->qemuCaps) < 0) @@ -4427,6 +4431,7 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, cleanup: qemuDomainResetDeviceRemoval(vm); VIR_FREE(devstr); + VIR_FREE(charAlias); virObjectUnref(cfg); return ret; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-verify.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-verify.args index f521e334fcb3e9f03ad352f0847cbf29e695a243..003d11de72be24174014b41a786bf8ce66d47cc5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-verify.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev-verify.args @@ -25,9 +25,9 @@ server,nowait \ -chardev udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,\ localport=1111 \ -device isa-serial,chardev=charserial0,id=serial0 \ --object tls-creds-x509,id=objserial1_tls0,dir=/etc/pki/libvirt-chardev,\ +-object tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,\ endpoint=client,verify-peer=yes \ -chardev socket,id=charserial1,host=127.0.0.1,port=5555,\ -tls-creds=objserial1_tls0 \ +tls-creds=objcharserial1_tls0 \ -device isa-serial,chardev=charserial1,id=serial1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args index 4c8c23eb187c70cfead167be41a56fa88d5a7fc4..b456cce3041782258f74a78e5b5ec27e76652799 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-tlsx509-chardev.args @@ -25,9 +25,9 @@ server,nowait \ -chardev udp,id=charserial0,host=127.0.0.1,port=2222,localaddr=127.0.0.1,\ localport=1111 \ -device isa-serial,chardev=charserial0,id=serial0 \ --object tls-creds-x509,id=objserial1_tls0,dir=/etc/pki/libvirt-chardev,\ +-object tls-creds-x509,id=objcharserial1_tls0,dir=/etc/pki/libvirt-chardev,\ endpoint=client,verify-peer=no \ -chardev socket,id=charserial1,host=127.0.0.1,port=5555,\ -tls-creds=objserial1_tls0 \ +tls-creds=objcharserial1_tls0 \ -device isa-serial,chardev=charserial1,id=serial1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3