[libvirt] [PATCH go-xml] extend chardev source to include networking

Jeroen Simonetti posted 1 patch 6 years, 6 months ago
Failed in applying to current master (apply log)
domain.go      | 26 +++++++++++++++++---------
domain_test.go | 20 ++++++++++++++++++++
2 files changed, 37 insertions(+), 9 deletions(-)
[libvirt] [PATCH go-xml] extend chardev source to include networking
Posted by Jeroen Simonetti 6 years, 6 months ago
This will extend the DomainChardevSource to also support
networked backends.

Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl>
---
 domain.go      | 26 +++++++++++++++++---------
 domain_test.go | 20 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/domain.go b/domain.go
index 8c2cc1b..8392322 100644
--- a/domain.go
+++ b/domain.go
@@ -255,9 +255,12 @@ type DomainInterface struct {
 }
 
 type DomainChardevSource struct {
-	Mode   string `xml:"mode,attr,omitempty"`
-	Path   string `xml:"path,attr"`
-	Append string `xml:"append,attr,omitempty"`
+	Mode    string `xml:"mode,attr,omitempty"`
+	Path    string `xml:"path,attr,omitempty"`
+	Append  string `xml:"append,attr,omitempty"`
+	Host    string `xml:"host,attr,omitempty"`
+	Service string `xml:"service,attr,omitempty"`
+	TLS     string `xml:"tls,attr,omitempty"`
 }
 
 type DomainChardevTarget struct {
@@ -309,12 +312,17 @@ type DomainConsole struct {
 }
 
 type DomainSerial struct {
-	XMLName xml.Name             `xml:"serial"`
-	Type    string               `xml:"type,attr"`
-	Source  *DomainChardevSource `xml:"source"`
-	Target  *DomainSerialTarget  `xml:"target"`
-	Alias   *DomainAlias         `xml:"alias"`
-	Address *DomainAddress       `xml:"address"`
+	XMLName  xml.Name              `xml:"serial"`
+	Type     string                `xml:"type,attr"`
+	Source   *DomainChardevSource  `xml:"source"`
+	Protocol *DomainSerialProtocol `xml:"protocol"`
+	Target   *DomainSerialTarget   `xml:"target"`
+	Alias    *DomainAlias          `xml:"alias"`
+	Address  *DomainAddress        `xml:"address"`
+}
+
+type DomainSerialProtocol struct {
+	Type string `xml:"type,attr"`
 }
 
 type DomainChannel struct {
diff --git a/domain_test.go b/domain_test.go
index 4fe6bfe..a7d8348 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -322,6 +322,21 @@ var domainTestData = []struct {
 							Port: &serialPort,
 						},
 					},
+					DomainSerial{
+						Type: "tcp",
+						Source: &DomainChardevSource{
+							Mode:    "bind",
+							Host:    "127.0.0.1",
+							Service: "1234",
+							TLS:     "yes",
+						},
+						Protocol: &DomainSerialProtocol{
+							Type: "telnet",
+						},
+						Target: &DomainSerialTarget{
+							Port: &serialPort,
+						},
+					},
 				},
 				Channels: []DomainChannel{
 					DomainChannel{
@@ -385,6 +400,11 @@ var domainTestData = []struct {
 			`      <source path="/tmp/serial.log" append="off"></source>`,
 			`      <target port="0"></target>`,
 			`    </serial>`,
+			`    <serial type="tcp">`,
+			`      <source mode="bind" host="127.0.0.1" service="1234" tls="yes"></source>`,
+			`      <protocol type="telnet"></protocol>`,
+			`      <target port="0"></target>`,
+			`    </serial>`,
 			`    <console type="pty">`,
 			`      <target type="virtio" port="0"></target>`,
 			`    </console>`,
-- 
2.14.2

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