Re: [libvirt] [PATCH go-xml] Add support for domain hostdev and test code
On Fri, Sep 15, 2017 at 02:12:44PM +0800, zhenwei.pi wrote: > Signed-off-by: zhenwei.pi> --- > domain.go | 36 > domain_test.go | 44 > 2 files changed, 80 insertions(+) > > diff --git a/domain.go b/domain.go > index bead49a..1bcc9cc 100644 > --- a/domain.go > +++ b/domain.go > @@ -407,6 +407,29 @@ type DomainRNG struct { > Backend *DomainRNGBackend `xml:"backend"` > } > > +type DomainHostdevAdapter struct { > + Name string `xml:"name,attr,omitempty"` > +} > + > +type DomainHostdevSource struct { > + Protocol string`xml:"protocol,attr,omitempty"` > + Name string`xml:"name,attr,omitempty"` > + Wwpn string`xml:"wwpn,attr,omitempty"` This should be WWPN > + Adapter *DomainHostdevAdapter `xml:"adapter"` > + Address *DomainAddress`xml:"address"` > +} > + > +type DomainHostdev struct { > + XMLName xml.Name `xml:"hostdev"` > + Modestring `xml:"mode,attr"` > + Typestring `xml:"type,attr"` > + Sgiostring `xml:"sgio,attr,omitempty"` SGIO > + Rawio string `xml:"rawio,attr,omitempty"` And RawIO > + Managed string `xml:"managed,attr,omitempty"` > + Source *DomainHostdevSource `xml:"source"` > + Address *DomainAddress `xml:"address"` > +} > diff --git a/domain_test.go b/domain_test.go > index d1b107d..73dd47b 100644 > --- a/domain_test.go > +++ b/domain_test.go > @@ -37,6 +37,13 @@ type Address struct { > Function HexUint > } > > +type ScsiAddress struct { Should be SCSI ACK, and I'll fix the capitalization when pushing 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 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH go-xml] Add support for domain hostdev and test code
Signed-off-by: zhenwei.pi--- domain.go | 36 domain_test.go | 44 2 files changed, 80 insertions(+) diff --git a/domain.go b/domain.go index bead49a..1bcc9cc 100644 --- a/domain.go +++ b/domain.go @@ -407,6 +407,29 @@ type DomainRNG struct { Backend *DomainRNGBackend `xml:"backend"` } +type DomainHostdevAdapter struct { + Name string `xml:"name,attr,omitempty"` +} + +type DomainHostdevSource struct { + Protocol string`xml:"protocol,attr,omitempty"` + Name string`xml:"name,attr,omitempty"` + Wwpn string`xml:"wwpn,attr,omitempty"` + Adapter *DomainHostdevAdapter `xml:"adapter"` + Address *DomainAddress`xml:"address"` +} + +type DomainHostdev struct { + XMLName xml.Name `xml:"hostdev"` + Modestring `xml:"mode,attr"` + Typestring `xml:"type,attr"` + Sgiostring `xml:"sgio,attr,omitempty"` + Rawio string `xml:"rawio,attr,omitempty"` + Managed string `xml:"managed,attr,omitempty"` + Source *DomainHostdevSource `xml:"source"` + Address *DomainAddress `xml:"address"` +} + type DomainDeviceList struct { Emulatorstring `xml:"emulator,omitempty"` Controllers []DomainController `xml:"controller"` @@ -422,6 +445,7 @@ type DomainDeviceList struct { MemBalloon *DomainMemBalloon `xml:"memballoon"` Sounds []DomainSound `xml:"sound"` RNGs[]DomainRNG`xml:"rng"` + Hostdevs[]DomainHostdev`xml:"hostdev"` } type DomainMemory struct { @@ -794,6 +818,18 @@ func (d *DomainRNG) Marshal() (string, error) { return string(doc), nil } +func (d *DomainHostdev) Unmarshal(doc string) error { + return xml.Unmarshal([]byte(doc), d) +} + +func (d *DomainHostdev) Marshal() (string, error) { + doc, err := xml.MarshalIndent(d, "", " ") + if err != nil { + return "", err + } + return string(doc), nil +} + type HexUint uint func (h *HexUint) UnmarshalXMLAttr(attr xml.Attr) error { diff --git a/domain_test.go b/domain_test.go index d1b107d..73dd47b 100644 --- a/domain_test.go +++ b/domain_test.go @@ -37,6 +37,13 @@ type Address struct { Function HexUint } +type ScsiAddress struct { + Controller uint + BusHexUint + Target uint + Unit uint +} + var uhciIndex uint = 0 var uhciAddr = Address{0, 0, 1, 2} @@ -46,6 +53,7 @@ var videoAddr = Address{0, 0, 5, 0} var fsAddr = Address{0, 0, 6, 0} var balloonAddr = Address{0, 0, 7, 0} var duplexAddr = Address{0, 0, 8, 0} +var hostdevScsi = ScsiAddress{0, 0, 3, 0} var serialPort uint = 0 var tabletBus HexUint = 0 @@ -1457,6 +1465,42 @@ var domainTestData = []struct { ``, }, }, + { + Object: { + Mode: "subsystem", + Type: "scsi", + Sgio: "unfiltered", + Rawio: "yes", + Source: { + Adapter: { + Name: "scsi_host0", + }, + Address: { + Type: "scsi", + Bus:, + Target: , + Unit: , + }, + }, + Address: { + Type: "drive", + Controller: , + Bus:, + Target: , + Unit: , + }, + }, + + Expected: []string{ + ``, + ` `, + ``, + ``, + ` `, + ` `, + ``, + }, + }, } func TestDomain(t *testing.T) { -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH go-xml] Add support for domain hostdev and test code
Signed-off-by: zhenwei.pi--- domain.go | 36 domain_test.go | 36 2 files changed, 72 insertions(+) diff --git a/domain.go b/domain.go index a5d3203..2c63307 100644 --- a/domain.go +++ b/domain.go @@ -406,6 +406,29 @@ type DomainRNG struct { Backend *DomainRNGBackend `xml:"backend"` } +type DomainHostdevAdapter struct { + Name string `xml:"name,attr,omitempty"` +} + +type DomainHostdevSource struct { + Protocol string`xml:"protocol,attr,omitempty"` + Name string`xml:"name,attr,omitempty"` + Wwpn string`xml:"wwpn,attr,omitempty"` + Adapter *DomainHostdevAdapter `xml:"adapter"` + Address *DomainAddress`xml:"address"` +} + +type DomainHostdev struct { + XMLName xml.Name `xml:"hostdev"` + Modestring `xml:"mode,attr"` + Typestring `xml:"type,attr"` + Sgiostring `xml:"sgio,attr,omitempty"` + Rawio string `xml:"rawio,attr,omitempty"` + Managed string `xml:"managed,attr,omitempty"` + Source *DomainHostdevSource `xml:"source"` + Address *DomainAddress `xml:"address"` +} + type DomainDeviceList struct { Emulatorstring `xml:"emulator,omitempty"` Controllers []DomainController `xml:"controller"` @@ -421,6 +444,7 @@ type DomainDeviceList struct { MemBalloon *DomainMemBalloon `xml:"memballoon"` Sounds []DomainSound `xml:"sound"` RNGs[]DomainRNG`xml:"rng"` + Hostdevs[]DomainHostdev`xml:"hostdev"` } type DomainMemory struct { @@ -792,3 +816,15 @@ func (d *DomainRNG) Marshal() (string, error) { } return string(doc), nil } + +func (d *DomainHostdev) Unmarshal(doc string) error { + return xml.Unmarshal([]byte(doc), d) +} + +func (d *DomainHostdev) Marshal() (string, error) { + doc, err := xml.MarshalIndent(d, "", " ") + if err != nil { + return "", err + } + return string(doc), nil +} diff --git a/domain_test.go b/domain_test.go index 2af451f..e3abbbf 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1457,6 +1457,42 @@ var domainTestData = []struct { ``, }, }, + { + Object: { + Mode: "subsystem", + Type: "scsi", + Sgio: "unfiltered", + Rawio: "yes", + Source: { + Adapter: { + Name: "scsi_host0", + }, + Address: { + Type: "scsi", + Bus:, + Target: , + Unit: , + }, + }, + Address: { + Type: "drive", + Controller: , + Bus:, + Target: , + Unit: , + }, + }, + + Expected: []string{ + ``, + ` `, + ``, + ``, + ` `, + ` `, + ``, + }, + }, } func TestDomain(t *testing.T) { -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH go-xml] Add support for domain hostdev and test code
Signed-off-by: zhenwei.pi--- domain.go | 36 domain_test.go | 36 2 files changed, 72 insertions(+) diff --git a/domain.go b/domain.go index a5d3203..2c63307 100644 --- a/domain.go +++ b/domain.go @@ -406,6 +406,29 @@ type DomainRNG struct { Backend *DomainRNGBackend `xml:"backend"` } +type DomainHostdevAdapter struct { + Name string `xml:"name,attr,omitempty"` +} + +type DomainHostdevSource struct { + Protocol string`xml:"protocol,attr,omitempty"` + Name string`xml:"name,attr,omitempty"` + Wwpn string`xml:"wwpn,attr,omitempty"` + Adapter *DomainHostdevAdapter `xml:"adapter"` + Address *DomainAddress`xml:"address"` +} + +type DomainHostdev struct { + XMLName xml.Name `xml:"hostdev"` + Modestring `xml:"mode,attr"` + Typestring `xml:"type,attr"` + Sgiostring `xml:"sgio,attr,omitempty"` + Rawio string `xml:"rawio,attr,omitempty"` + Managed string `xml:"managed,attr,omitempty"` + Source *DomainHostdevSource `xml:"source"` + Address *DomainAddress `xml:"address"` +} + type DomainDeviceList struct { Emulatorstring `xml:"emulator,omitempty"` Controllers []DomainController `xml:"controller"` @@ -421,6 +444,7 @@ type DomainDeviceList struct { MemBalloon *DomainMemBalloon `xml:"memballoon"` Sounds []DomainSound `xml:"sound"` RNGs[]DomainRNG`xml:"rng"` + Hostdevs[]DomainHostdev`xml:"hostdev"` } type DomainMemory struct { @@ -792,3 +816,15 @@ func (d *DomainRNG) Marshal() (string, error) { } return string(doc), nil } + +func (d *DomainHostdev) Unmarshal(doc string) error { + return xml.Unmarshal([]byte(doc), d) +} + +func (d *DomainHostdev) Marshal() (string, error) { + doc, err := xml.MarshalIndent(d, "", " ") + if err != nil { + return "", err + } + return string(doc), nil +} diff --git a/domain_test.go b/domain_test.go index 2af451f..e3abbbf 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1457,6 +1457,42 @@ var domainTestData = []struct { ``, }, }, + { + Object: { + Mode: "subsystem", + Type: "scsi", + Sgio: "unfiltered", + Rawio: "yes", + Source: { + Adapter: { + Name: "scsi_host0", + }, + Address: { + Type: "scsi", + Bus:, + Target: , + Unit: , + }, + }, + Address: { + Type: "drive", + Controller: , + Bus:, + Target: , + Unit: , + }, + }, + + Expected: []string{ + ``, + ` `, + ``, + ``, + ` `, + ` `, + ``, + }, + }, } func TestDomain(t *testing.T) { -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH go-xml] Add support for domain hostdev and test code
Signed-off-by: zhenwei.pi--- domain.go | 36 domain_test.go | 36 2 files changed, 72 insertions(+) diff --git a/domain.go b/domain.go index a5d3203..2c63307 100644 --- a/domain.go +++ b/domain.go @@ -406,6 +406,29 @@ type DomainRNG struct { Backend *DomainRNGBackend `xml:"backend"` } +type DomainHostdevAdapter struct { + Name string `xml:"name,attr,omitempty"` +} + +type DomainHostdevSource struct { + Protocol string`xml:"protocol,attr,omitempty"` + Name string`xml:"name,attr,omitempty"` + Wwpn string`xml:"wwpn,attr,omitempty"` + Adapter *DomainHostdevAdapter `xml:"adapter"` + Address *DomainAddress`xml:"address"` +} + +type DomainHostdev struct { + XMLName xml.Name `xml:"hostdev"` + Modestring `xml:"mode,attr"` + Typestring `xml:"type,attr"` + Sgiostring `xml:"sgio,attr,omitempty"` + Rawio string `xml:"rawio,attr,omitempty"` + Managed string `xml:"managed,attr,omitempty"` + Source *DomainHostdevSource `xml:"source"` + Address *DomainAddress `xml:"address"` +} + type DomainDeviceList struct { Emulatorstring `xml:"emulator,omitempty"` Controllers []DomainController `xml:"controller"` @@ -421,6 +444,7 @@ type DomainDeviceList struct { MemBalloon *DomainMemBalloon `xml:"memballoon"` Sounds []DomainSound `xml:"sound"` RNGs[]DomainRNG`xml:"rng"` + Hostdevs[]DomainHostdev`xml:"hostdev"` } type DomainMemory struct { @@ -792,3 +816,15 @@ func (d *DomainRNG) Marshal() (string, error) { } return string(doc), nil } + +func (d *DomainHostdev) Unmarshal(doc string) error { + return xml.Unmarshal([]byte(doc), d) +} + +func (d *DomainHostdev) Marshal() (string, error) { + doc, err := xml.MarshalIndent(d, "", " ") + if err != nil { + return "", err + } + return string(doc), nil +} diff --git a/domain_test.go b/domain_test.go index 2af451f..e3abbbf 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1457,6 +1457,42 @@ var domainTestData = []struct { ``, }, }, + { + Object: { + Mode: "subsystem", + Type: "scsi", + Sgio: "unfiltered", + Rawio: "yes", + Source: { + Adapter: { + Name: "scsi_host0", + }, + Address: { + Type: "scsi", + Bus:, + Target: , + Unit: , + }, + }, + Address: { + Type: "drive", + Controller: , + Bus:, + Target: , + Unit: , + }, + }, + + Expected: []string{ + ``, + ` `, + ``, + ``, + ` `, + ` `, + ``, + }, + }, } func TestDomain(t *testing.T) { -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list