Signed-off-by: Jeroen Simonetti <jeroen@xxxxxxxxxxxx> --- domain.go | 22 ++++++++++++++-------- domain_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/domain.go b/domain.go index 3ab54a1..805909f 100644 --- a/domain.go +++ b/domain.go @@ -178,16 +178,22 @@ type DomainInterfaceModel struct { } type DomainInterfaceSource struct { - Bridge string `xml:"bridge,attr,omitempty"` - Dev string `xml:"dev,attr,omitempty"` - Network string `xml:"network,attr,omitempty"` + Bridge string `xml:"bridge,attr,omitempty"` + Dev string `xml:"dev,attr,omitempty"` + Network string `xml:"network,attr,omitempty"` + Address string `xml:"address,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Path string `xml:"path,attr,omitempty"` + Mode string `xml:"mode,attr,omitempty"` + Port uint `xml:"port,attr,omitempty"` + Service string `xml:"service,attr,omitempty"` + Host string `xml:"host,attr,omitempty"` + Local *DomainInterfaceSourceLocal `xml:"local"` +} + +type DomainInterfaceSourceLocal struct { Address string `xml:"address,attr,omitempty"` - Type string `xml:"type,attr,omitempty"` - Path string `xml:"path,attr,omitempty"` - Mode string `xml:"mode,attr,omitempty"` Port uint `xml:"port,attr,omitempty"` - Service string `xml:"service,attr,omitempty"` - Host string `xml:"host,attr,omitempty"` } type DomainInterfaceTarget struct { diff --git a/domain_test.go b/domain_test.go index 0ae9594..163661f 100644 --- a/domain_test.go +++ b/domain_test.go @@ -867,6 +867,47 @@ var domainTestData = []struct { `</domain>`, }, }, + { + Object: &Domain{ + Type: "kvm", + Name: "test", + Devices: &DomainDeviceList{ + Interfaces: []DomainInterface{ + DomainInterface{ + Type: "udp", + MAC: &DomainInterfaceMAC{ + Address: "52:54:00:39:97:ac", + }, + Model: &DomainInterfaceModel{ + Type: "virtio", + }, + Source: &DomainInterfaceSource{ + Address: "127.0.0.1", + Port: 1234, + Local: &DomainInterfaceSourceLocal{ + Address: "127.0.0.1", + Port: 1235, + }, + }, + }, + }, + }, + }, + Expected: []string{ + `<domain type="kvm">`, + ` <name>test</name>`, + ` <devices>`, + ` <interface type="udp">`, + ` <mac address="52:54:00:39:97:ac"></mac>`, + ` <model type="virtio"></model>`, + ` <source address="127.0.0.1" port="1234">`, + ` <local address="127.0.0.1" port="1235"></local>`, + ` </source>`, + ` </interface>`, + ` </devices>`, + `</domain>`, + }, + }, { Object: &Domain{ Type: "kvm", -- 2.14.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list