[PATCH 5/9] ch_monitor: Add pty json builder function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: William Douglas <william.douglas@xxxxxxxxx>
---
 src/ch/ch_monitor.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index 28c70c7281..a01c031064 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -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;
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux