ch_monitor: Add pty json builder function

Add function to build the the json structure to configure a PTY in
cloud-hypervisor.

The devices themselves still aren't allowed in configurations yet
though.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
William Douglas 2021-09-08 11:01:19 -07:00 committed by Daniel P. Berrangé
parent 3b164e6897
commit 93accefd9e

View File

@ -89,6 +89,30 @@ virCHMonitorBuildCPUJson(virJSONValue *content, virDomainDef *vmdef)
return -1;
}
static int
virCHMonitorBuildPTYJson(virJSONValue *content, virDomainDef *vmdef)
{
virJSONValue *ptys = virJSONValueNewObject();
if (vmdef->nconsoles) {
g_autoptr(virJSONValue) pty = virJSONValueNewObject();
if (virJSONValueObjectAppendString(pty, "mode", "Pty") < 0)
return -1;
if (virJSONValueObjectAppend(content, "console", &pty) < 0)
return -1;
}
if (vmdef->nserials) {
g_autoptr(virJSONValue) pty = virJSONValueNewObject();
if (virJSONValueObjectAppendString(ptys, "mode", "Pty") < 0)
return -1;
if (virJSONValueObjectAppend(content, "serial", &pty) < 0)
return -1;
}
return 0;
}
static int
virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vmdef)
{
@ -370,6 +394,9 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef, char **jsonstr)
goto cleanup;
}
if (virCHMonitorBuildPTYJson(content, vmdef) < 0)
goto cleanup;
if (virCHMonitorBuildCPUJson(content, vmdef) < 0)
goto cleanup;