mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
qemuMonitorJSONAttachCharDevGetProps: Properly handle private data
FD passing and TLS is normally setup via private data for the chardev source. The monitor implementation didn't support it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
52d38e3274
commit
9eed144c50
@ -6527,6 +6527,23 @@ qemuMonitorJSONBuildUnixSocketAddress(const char *path)
|
|||||||
return g_steal_pointer(&addr);
|
return g_steal_pointer(&addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virJSONValue *
|
||||||
|
qemuMonitorJSONBuildFDSocketAddress(const char *fdname)
|
||||||
|
{
|
||||||
|
g_autoptr(virJSONValue) addr = NULL;
|
||||||
|
g_autoptr(virJSONValue) data = NULL;
|
||||||
|
|
||||||
|
if (virJSONValueObjectAdd(&data, "s:str", fdname, NULL) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (virJSONValueObjectAdd(&addr,
|
||||||
|
"s:type", "fd",
|
||||||
|
"a:data", &data, NULL) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_steal_pointer(&addr);
|
||||||
|
}
|
||||||
int
|
int
|
||||||
qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
|
qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
|
||||||
const virStorageNetHostDef *server,
|
const virStorageNetHostDef *server,
|
||||||
@ -6683,6 +6700,7 @@ static virJSONValue *
|
|||||||
qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
||||||
const virDomainChrSourceDef *chr)
|
const virDomainChrSourceDef *chr)
|
||||||
{
|
{
|
||||||
|
qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chr);
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
g_autoptr(virJSONValue) backend = NULL;
|
g_autoptr(virJSONValue) backend = NULL;
|
||||||
g_autoptr(virJSONValue) backendData = virJSONValueNewObject();
|
g_autoptr(virJSONValue) backendData = virJSONValueNewObject();
|
||||||
@ -6695,14 +6713,22 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
backendType = virDomainChrTypeToString(chr->type);
|
backendType = virDomainChrTypeToString(chr->type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
case VIR_DOMAIN_CHR_TYPE_FILE: {
|
||||||
|
const char *path = chr->data.file.path;
|
||||||
|
virTristateSwitch append = chr->data.file.append;
|
||||||
backendType = "file";
|
backendType = "file";
|
||||||
|
|
||||||
|
if (chrSourcePriv->sourcefd) {
|
||||||
|
path = qemuFDPassGetPath(chrSourcePriv->sourcefd);
|
||||||
|
append = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&backendData,
|
if (virJSONValueObjectAdd(&backendData,
|
||||||
"s:out", chr->data.file.path,
|
"s:out", path,
|
||||||
"T:append", chr->data.file.append,
|
"T:append", append,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_DEV:
|
case VIR_DOMAIN_CHR_TYPE_DEV:
|
||||||
@ -6720,7 +6746,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
case VIR_DOMAIN_CHR_TYPE_TCP: {
|
case VIR_DOMAIN_CHR_TYPE_TCP: {
|
||||||
g_autofree char *tlsalias = NULL;
|
const char *tlsalias = NULL;
|
||||||
g_autoptr(virJSONValue) addr = NULL;
|
g_autoptr(virJSONValue) addr = NULL;
|
||||||
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
@ -6737,9 +6763,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
waitval = VIR_TRISTATE_BOOL_NO;
|
waitval = VIR_TRISTATE_BOOL_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chr->data.tcp.tlscreds &&
|
tlsalias = chrSourcePriv->tlsCredsAlias;
|
||||||
!(tlsalias = qemuAliasTLSObjFromSrcAlias(chrID)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!(addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.tcp.host,
|
if (!(addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.tcp.host,
|
||||||
chr->data.tcp.service)))
|
chr->data.tcp.service)))
|
||||||
@ -6755,6 +6779,10 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
waitval = VIR_TRISTATE_BOOL_NO;
|
waitval = VIR_TRISTATE_BOOL_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chrSourcePriv->sourcefd) {
|
||||||
|
if (!(addr = qemuMonitorJSONBuildFDSocketAddress(qemuFDPassGetPath(chrSourcePriv->sourcefd))))
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
if (!(addr = qemuMonitorJSONBuildUnixSocketAddress(chr->data.nix.path)))
|
if (!(addr = qemuMonitorJSONBuildUnixSocketAddress(chr->data.nix.path)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -6763,6 +6791,7 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
else if (chr->data.nix.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
else if (chr->data.nix.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
||||||
reconnect = 0;
|
reconnect = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&backendData,
|
if (virJSONValueObjectAdd(&backendData,
|
||||||
"a:addr", &addr,
|
"a:addr", &addr,
|
||||||
@ -6826,9 +6855,17 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chr->logfile) {
|
if (chr->logfile) {
|
||||||
|
const char *path = chr->logfile;
|
||||||
|
virTristateSwitch append = chr->logappend;
|
||||||
|
|
||||||
|
if (chrSourcePriv->logfd) {
|
||||||
|
path = qemuFDPassGetPath(chrSourcePriv->logfd);
|
||||||
|
append = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&backendData,
|
if (virJSONValueObjectAdd(&backendData,
|
||||||
"s:logfile", chr->logfile,
|
"s:logfile", path,
|
||||||
"T:logappend", chr->logappend,
|
"T:logappend", append,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user