mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: monitor: Remove the old chardev backend generator
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e352a692a7
commit
2256466f70
@ -6173,22 +6173,6 @@ qemuMonitorJSONBuildUnixSocketAddress(const char *path)
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
|
||||
const virStorageNetHostDef *server,
|
||||
@ -6342,233 +6326,6 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitor *mon,
|
||||
}
|
||||
|
||||
|
||||
static G_GNUC_UNUSED virJSONValue *
|
||||
qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
||||
const virDomainChrSourceDef *chr)
|
||||
{
|
||||
qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chr);
|
||||
g_autoptr(virJSONValue) props = NULL;
|
||||
g_autoptr(virJSONValue) backend = NULL;
|
||||
g_autoptr(virJSONValue) backendData = virJSONValueNewObject();
|
||||
const char *backendType = NULL;
|
||||
|
||||
switch ((virDomainChrType)chr->type) {
|
||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||
case VIR_DOMAIN_CHR_TYPE_VC:
|
||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||
backendType = virDomainChrTypeToString(chr->type);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE: {
|
||||
const char *path = chr->data.file.path;
|
||||
virTristateSwitch append = chr->data.file.append;
|
||||
backendType = "file";
|
||||
|
||||
if (chrSourcePriv->sourcefd) {
|
||||
path = qemuFDPassGetPath(chrSourcePriv->sourcefd);
|
||||
append = VIR_TRISTATE_SWITCH_ON;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"s:out", path,
|
||||
"T:append", append,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_DEV:
|
||||
if (STRPREFIX(chrID, "parallel"))
|
||||
backendType = "parallel";
|
||||
else
|
||||
backendType = "serial";
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"s:device", chr->data.file.path,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
case VIR_DOMAIN_CHR_TYPE_TCP: {
|
||||
const char *tlsalias = NULL;
|
||||
g_autoptr(virJSONValue) addr = NULL;
|
||||
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
||||
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
||||
bool server = false;
|
||||
int reconnect = -1;
|
||||
|
||||
backendType = "socket";
|
||||
|
||||
if (chr->type == VIR_DOMAIN_CHR_TYPE_TCP) {
|
||||
telnet = virTristateBoolFromBool(chr->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET);
|
||||
|
||||
if (chr->data.tcp.listen) {
|
||||
server = true;
|
||||
waitval = VIR_TRISTATE_BOOL_NO;
|
||||
}
|
||||
|
||||
tlsalias = chrSourcePriv->tlsCredsAlias;
|
||||
|
||||
if (!(addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.tcp.host,
|
||||
chr->data.tcp.service)))
|
||||
return NULL;
|
||||
|
||||
if (chr->data.tcp.reconnect.enabled == VIR_TRISTATE_BOOL_YES)
|
||||
reconnect = chr->data.tcp.reconnect.timeout;
|
||||
else if (chr->data.tcp.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
||||
reconnect = 0;
|
||||
} else {
|
||||
if (chr->data.nix.listen) {
|
||||
server = true;
|
||||
waitval = VIR_TRISTATE_BOOL_NO;
|
||||
}
|
||||
|
||||
if (chrSourcePriv->directfd) {
|
||||
if (!(addr = qemuMonitorJSONBuildFDSocketAddress(qemuFDPassDirectGetPath(chrSourcePriv->directfd))))
|
||||
return NULL;
|
||||
} else {
|
||||
if (!(addr = qemuMonitorJSONBuildUnixSocketAddress(chr->data.nix.path)))
|
||||
return NULL;
|
||||
|
||||
if (chr->data.nix.reconnect.enabled == VIR_TRISTATE_BOOL_YES)
|
||||
reconnect = chr->data.nix.reconnect.timeout;
|
||||
else if (chr->data.nix.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
||||
reconnect = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"a:addr", &addr,
|
||||
"T:wait", waitval,
|
||||
"T:telnet", telnet,
|
||||
"b:server", server,
|
||||
"S:tls-creds", tlsalias,
|
||||
"k:reconnect", reconnect,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UDP: {
|
||||
g_autoptr(virJSONValue) local = NULL;
|
||||
g_autoptr(virJSONValue) remote = NULL;
|
||||
|
||||
backendType = "udp";
|
||||
|
||||
if (!(remote = qemuMonitorJSONBuildInetSocketAddress(NULLSTR_EMPTY(chr->data.udp.connectHost),
|
||||
chr->data.udp.connectService)))
|
||||
return NULL;
|
||||
|
||||
if (chr->data.udp.bindHost || chr->data.udp.bindService) {
|
||||
if (!(local = qemuMonitorJSONBuildInetSocketAddress(NULLSTR_EMPTY(chr->data.udp.bindHost),
|
||||
NULLSTR_EMPTY(chr->data.udp.bindService))))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"a:remote", &remote,
|
||||
"A:local", &local,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
|
||||
backendType = "spicevmc";
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"s:type", virDomainChrSpicevmcTypeToString(chr->data.spicevmc),
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT: {
|
||||
virTristateBool mouse = VIR_TRISTATE_BOOL_ABSENT;
|
||||
switch (chr->data.qemuVdagent.mouse) {
|
||||
case VIR_DOMAIN_MOUSE_MODE_CLIENT:
|
||||
mouse = VIR_TRISTATE_BOOL_YES;
|
||||
break;
|
||||
case VIR_DOMAIN_MOUSE_MODE_SERVER:
|
||||
mouse = VIR_TRISTATE_BOOL_NO;
|
||||
break;
|
||||
case VIR_DOMAIN_MOUSE_MODE_DEFAULT:
|
||||
break;
|
||||
case VIR_DOMAIN_MOUSE_MODE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainMouseMode,
|
||||
chr->data.qemuVdagent.mouse);
|
||||
return NULL;
|
||||
}
|
||||
backendType = "qemu-vdagent";
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"T:clipboard", chr->data.qemuVdagent.clipboard,
|
||||
"T:mouse", mouse,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_DBUS:
|
||||
backendType = "dbus";
|
||||
|
||||
if (virJSONValueObjectAdd(&backendData,
|
||||
"s:name", chr->data.dbus.channel,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
|
||||
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
||||
case VIR_DOMAIN_CHR_TYPE_STDIO:
|
||||
case VIR_DOMAIN_CHR_TYPE_NMDM:
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("Hotplug unsupported for char device type '%1$s'"),
|
||||
virDomainChrTypeToString(chr->type));
|
||||
return NULL;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainChrType, chr->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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,
|
||||
"s:logfile", path,
|
||||
"T:logappend", append,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(&backend,
|
||||
"s:type", backendType,
|
||||
"A:data", &backendData,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
if (virJSONValueObjectAdd(&props,
|
||||
"s:id", chrID,
|
||||
"a:backend", &backend,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
return g_steal_pointer(&props);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONAttachCharDev(qemuMonitor *mon,
|
||||
virJSONValue **props,
|
||||
|
Loading…
Reference in New Issue
Block a user