mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-08 14:29:56 +00:00
qemu: Add TLS hotplug for qemuDomainAttachRedirdevDevice
Commit id '2c322378' missed the nuance that the redirdev backend could be using a TCP chardev and if TLS is enabled on the host, thus will need to have the TLS object added.
This commit is contained in:
parent
7300ca2134
commit
d27c5c3e0d
@ -1505,11 +1505,16 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainRedirdevDefPtr redirdev)
|
virDomainRedirdevDefPtr redirdev)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
int rc;
|
||||||
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDefPtr def = vm->def;
|
virDomainDefPtr def = vm->def;
|
||||||
char *charAlias = NULL;
|
char *charAlias = NULL;
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
bool chardevAdded = false;
|
bool chardevAdded = false;
|
||||||
|
bool tlsobjAdded = false;
|
||||||
|
virJSONValuePtr tlsProps = NULL;
|
||||||
|
char *tlsAlias = NULL;
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
|
|
||||||
if (qemuAssignDeviceRedirdevAlias(def, redirdev, -1) < 0)
|
if (qemuAssignDeviceRedirdevAlias(def, redirdev, -1) < 0)
|
||||||
@ -1524,7 +1529,20 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
if (VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1) < 0)
|
if (VIR_REALLOC_N(def->redirdevs, def->nredirdevs+1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainGetChardevTLSObjects(cfg, priv, redirdev->source.chr,
|
||||||
|
charAlias, &tlsProps, &tlsAlias) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
if (tlsAlias) {
|
||||||
|
rc = qemuMonitorAddObject(priv->mon, "tls-creds-x509",
|
||||||
|
tlsAlias, tlsProps);
|
||||||
|
tlsProps = NULL; /* qemuMonitorAddObject consumes */
|
||||||
|
if (rc < 0)
|
||||||
|
goto exit_monitor;
|
||||||
|
tlsobjAdded = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemuMonitorAttachCharDev(priv->mon,
|
if (qemuMonitorAttachCharDev(priv->mon,
|
||||||
charAlias,
|
charAlias,
|
||||||
redirdev->source.chr) < 0)
|
redirdev->source.chr) < 0)
|
||||||
@ -1542,12 +1560,17 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
audit:
|
audit:
|
||||||
virDomainAuditRedirdev(vm, redirdev, "attach", ret == 0);
|
virDomainAuditRedirdev(vm, redirdev, "attach", ret == 0);
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(tlsAlias);
|
||||||
|
virJSONValueFree(tlsProps);
|
||||||
VIR_FREE(charAlias);
|
VIR_FREE(charAlias);
|
||||||
VIR_FREE(devstr);
|
VIR_FREE(devstr);
|
||||||
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
orig_err = virSaveLastError();
|
orig_err = virSaveLastError();
|
||||||
|
if (tlsobjAdded)
|
||||||
|
ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias));
|
||||||
/* detach associated chardev on error */
|
/* detach associated chardev on error */
|
||||||
if (chardevAdded)
|
if (chardevAdded)
|
||||||
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
|
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
|
||||||
|
Loading…
Reference in New Issue
Block a user