mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: always generate the same alias for tls-creds-x509 object
There was inconsistency between alias used to create tls-creds-x509 object and alias used to link that object to chardev while hotpluging. Hotplug ends with this error: error: Failed to detach device from channel-tcp.xml error: internal error: unable to execute QEMU command 'chardev-add': No TLS credentials with id 'objcharchannel3_tls0' In XML we have for example alias "serial0", but on qemu command line we generate "charserial0". The issue was that code, that creates QMP command to hotplug chardev devices uses only the second alias "charserial0" and that alias is also used to link the tls-creds-x509 object. This patch unifies the aliases for tls-creds-x509 to be always generated from "charserial0". Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
635b5ec8e8
commit
df93b5f5f5
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user