[libvirt] [PATCH] chardev: Add function to output -chardev options

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

 



Note that, on its own, this patch will generate a warning about an unused static
function.
---
 src/qemu/qemu_conf.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 2981b51..a9f6885 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1411,6 +1411,74 @@ qemuBuildHostNetStr(virConnectPtr conn,
     return 0;
 }
 
+/* This function outputs a -chardev command line option which describes only the
+ * host side of the character device */
+static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
+                                                  const char *const id,
+                                                  virBufferPtr buf)
+{
+    bool telnet;
+    switch(dev->type) {
+    case VIR_DOMAIN_CHR_TYPE_NULL:
+        virBufferVSprintf(buf, "null,id=%s", id);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_VC:
+        virBufferVSprintf(buf, "vc,id=%s", id);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_PTY:
+        virBufferVSprintf(buf, "pty,id=%s", id);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_DEV:
+        virBufferVSprintf(buf, "tty,id=%s,path=%s", id, dev->data.file.path);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_FILE:
+        virBufferVSprintf(buf, "file,id=%s,path=%s", id, dev->data.file.path);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_PIPE:
+        virBufferVSprintf(buf, "pipe,id=%s,path=%s", id, dev->data.file.path);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_STDIO:
+        virBufferVSprintf(buf, "stdio,id=%s", id);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_UDP:
+        virBufferVSprintf(buf,
+                          "udp,id=%s,host=%s,port=%s,localaddr=%s,localport=%s",
+                          id,
+                          dev->data.udp.connectHost,
+                          dev->data.udp.connectService,
+                          dev->data.udp.bindHost,
+                          dev->data.udp.bindService);
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_TCP:
+        telnet = dev->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
+        virBufferVSprintf(buf,
+                          "socket,id=%s,host=%s,port=%s%s%s",
+                          id,
+                          dev->data.tcp.host,
+                          dev->data.tcp.service,
+                          telnet ? ",telnet" : "",
+                          dev->data.tcp.listen ? ",server,nowait" : "");
+        break;
+
+    case VIR_DOMAIN_CHR_TYPE_UNIX:
+        virBufferVSprintf(buf,
+                          "socket,id=%s,path=%s%s",
+                          id,
+                          dev->data.nix.path,
+                          dev->data.nix.listen ? ",server,nowait" : "");
+        break;
+    }
+}
+
+/* This function outputs an all-in-one character device command line option */
 static int qemudBuildCommandLineChrDevStr(virDomainChrDefPtr dev,
                                           char *buf,
                                           int buflen)
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]