[libvirt] [PATCH go-xml] qemu: extend serial console source

*Warning* this is a BWC breaking change! This will change the type of `DomainSerial.Source` from `*DomainChardevSource` to a new `*DomainSerialSource`. This is done to add support for networked serial ports and keep the original DomainChardevSource unchanged. DomainSerialSource contains all possible xml variations for a serial device source. Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl> --- domain.go | 32 ++++++++++++++++++++++++++------ domain_test.go | 30 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/domain.go b/domain.go index 8c2cc1b..3221423 100644 --- a/domain.go +++ b/domain.go @@ -309,12 +309,32 @@ 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 *DomainSerialSource `xml:"source"` + Protocol *DomainSerialProtocol `xml:"protocol"` + Target *DomainSerialTarget `xml:"target"` + Alias *DomainAlias `xml:"alias"` + Address *DomainAddress `xml:"address"` +} + +type DomainSerialSource struct { + 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"` + SecLabel *DomainSerialSourceSecLabel `xml:"seclabel"` +} + +type DomainSerialProtocol struct { + Type string `xml:"type,attr"` +} + +type DomainSerialSourceSecLabel struct { + Model string `xml:"model,attr,omitempty"` + Relabel string `xml:"relabel,attr,omitempty"` } type DomainChannel struct { diff --git a/domain_test.go b/domain_test.go index 4fe6bfe..d301ace 100644 --- a/domain_test.go +++ b/domain_test.go @@ -314,9 +314,28 @@ var domainTestData = []struct { }, DomainSerial{ Type: "file", - Source: &DomainChardevSource{ + Source: &DomainSerialSource{ Path: "/tmp/serial.log", Append: "off", + SecLabel: &DomainSerialSourceSecLabel{ + Model: "dac", + Relabel: "no", + }, + }, + Target: &DomainSerialTarget{ + Port: &serialPort, + }, + }, + DomainSerial{ + Type: "tcp", + Source: &DomainSerialSource{ + Mode: "bind", + Host: "127.0.0.1", + Service: "1234", + TLS: "yes", + }, + Protocol: &DomainSerialProtocol{ + Type: "telnet", }, Target: &DomainSerialTarget{ Port: &serialPort, @@ -382,7 +401,14 @@ var domainTestData = []struct { ` <target type="isa" port="0"></target>`, ` </serial>`, ` <serial type="file">`, - ` <source path="/tmp/serial.log" append="off"></source>`, + ` <source path="/tmp/serial.log" append="off">`, + ` <seclabel model="dac" relabel="no"></seclabel>`, + ` </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">`, -- 2.14.2

On Mon, Oct 02, 2017 at 12:10:40PM +0200, Jeroen Simonetti wrote:
*Warning* this is a BWC breaking change!
That's fine - we don't promise API compat for this module.
This will change the type of `DomainSerial.Source` from `*DomainChardevSource` to a new `*DomainSerialSource`.
This is done to add support for networked serial ports and keep the original DomainChardevSource unchanged.
I'm not sure I see the point of this. Any chardev backed device type (parallel, serial, vmchannel) should be allowed to use network backends - there's no restriction that says its only for serial ports.
DomainSerialSource contains all possible xml variations for a serial device source.
Signed-off-by: Jeroen Simonetti <jeroen@simonetti.nl> --- domain.go | 32 ++++++++++++++++++++++++++------ domain_test.go | 30 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/domain.go b/domain.go index 8c2cc1b..3221423 100644 --- a/domain.go +++ b/domain.go @@ -309,12 +309,32 @@ 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 *DomainSerialSource `xml:"source"` + Protocol *DomainSerialProtocol `xml:"protocol"` + Target *DomainSerialTarget `xml:"target"` + Alias *DomainAlias `xml:"alias"` + Address *DomainAddress `xml:"address"` +} + +type DomainSerialSource struct { + 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"` + SecLabel *DomainSerialSourceSecLabel `xml:"seclabel"` +} + +type DomainSerialProtocol struct { + Type string `xml:"type,attr"` +} + +type DomainSerialSourceSecLabel struct { + Model string `xml:"model,attr,omitempty"` + Relabel string `xml:"relabel,attr,omitempty"` }
type DomainChannel struct { diff --git a/domain_test.go b/domain_test.go index 4fe6bfe..d301ace 100644 --- a/domain_test.go +++ b/domain_test.go @@ -314,9 +314,28 @@ var domainTestData = []struct { }, DomainSerial{ Type: "file", - Source: &DomainChardevSource{ + Source: &DomainSerialSource{ Path: "/tmp/serial.log", Append: "off", + SecLabel: &DomainSerialSourceSecLabel{ + Model: "dac", + Relabel: "no", + }, + }, + Target: &DomainSerialTarget{ + Port: &serialPort, + }, + }, + DomainSerial{ + Type: "tcp", + Source: &DomainSerialSource{ + Mode: "bind", + Host: "127.0.0.1", + Service: "1234", + TLS: "yes", + }, + Protocol: &DomainSerialProtocol{ + Type: "telnet", }, Target: &DomainSerialTarget{ Port: &serialPort, @@ -382,7 +401,14 @@ var domainTestData = []struct { ` <target type="isa" port="0"></target>`, ` </serial>`, ` <serial type="file">`, - ` <source path="/tmp/serial.log" append="off"></source>`, + ` <source path="/tmp/serial.log" append="off">`, + ` <seclabel model="dac" relabel="no"></seclabel>`, + ` </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">`, -- 2.14.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

October 2 2017 12:47 PM, "Daniel P. Berrange" <berrange@redhat.com> wrote:
This will change the type of `DomainSerial.Source` from `*DomainChardevSource` to a new `*DomainSerialSource`.
This is done to add support for networked serial ports and keep the original DomainChardevSource unchanged.
I'm not sure I see the point of this. Any chardev backed device type (parallel, serial, vmchannel) should be allowed to use network backends - there's no restriction that says its only for serial ports.
I was not aware that all chardev backed devices should be able to use network backend. Does this mean I can simple extend the DomainChardevSource, add the required options and there will be no naming conflict? If so, this would mean there is no need for a breaking change. If you would be so kind to confirm the above, I will send in a new patch with the additional fields. Kind regards, Jeroen Simonetti

On Mon, Oct 02, 2017 at 11:34:18AM +0000, Jeroen Simonetti wrote:
October 2 2017 12:47 PM, "Daniel P. Berrange" <berrange@redhat.com> wrote:
This will change the type of `DomainSerial.Source` from `*DomainChardevSource` to a new `*DomainSerialSource`.
This is done to add support for networked serial ports and keep the original DomainChardevSource unchanged.
I'm not sure I see the point of this. Any chardev backed device type (parallel, serial, vmchannel) should be allowed to use network backends - there's no restriction that says its only for serial ports.
I was not aware that all chardev backed devices should be able to use network backend. Does this mean I can simple extend the DomainChardevSource, add the required options and there will be no naming conflict?
If so, this would mean there is no need for a breaking change. If you would be so kind to confirm the above, I will send in a new patch with the additional fields.
Yes, just add extra fields to the DomainChardevSource Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrange
-
Jeroen Simonetti