[libvirt] [PATCH go-xml 0/2] DomainAddress parsing fix

*** BLURB HERE *** I have taken Anton Kryukovs fix from #13 on github and am submitting along with addition of 1.8 and 1.9 as travis go version targets Example of failing running on 1.9, which passes on 1.7 can be found at git@github.com:deasmi/libvirt-go-xml.git branch parsefailtest Anton Kryukov (1): Add support for hex values in DomainAddress struct Dean Smith (1): Adding go 1.8 and 1.9 to travis tests .travis.yml | 2 ++ domain.go | 27 ++++++++++++++++++--------- domain_test.go | 10 +++++----- 3 files changed, 25 insertions(+), 14 deletions(-) -- 1.8.3.1

From: Anton Kryukov <kryukov@selectel.ru> Add support for hex values in DomainAddress struct Tests fixed for HexUint
From PR#13 https://github.com/libvirt/libvirt-go-xml/pull/13 on github by Emreu
@deasmi submitting via mail --- domain.go | 27 ++++++++++++++++++--------- domain_test.go | 10 +++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/domain.go b/domain.go index a5d3203..bead49a 100644 --- a/domain.go +++ b/domain.go @@ -27,6 +27,7 @@ package libvirtxml import ( "encoding/xml" + "strconv" ) type DomainController struct { @@ -281,15 +282,15 @@ type DomainAlias struct { } type DomainAddress struct { - Type string `xml:"type,attr"` - Controller *uint `xml:"controller,attr"` - Domain *uint `xml:"domain,attr"` - Bus *uint `xml:"bus,attr"` - Port *uint `xml:"port,attr"` - Slot *uint `xml:"slot,attr"` - Function *uint `xml:"function,attr"` - Target *uint `xml:"target,attr"` - Unit *uint `xml:"unit,attr"` + Type string `xml:"type,attr"` + Controller *uint `xml:"controller,attr"` + Domain *HexUint `xml:"domain,attr"` + Bus *HexUint `xml:"bus,attr"` + Port *uint `xml:"port,attr"` + Slot *HexUint `xml:"slot,attr"` + Function *HexUint `xml:"function,attr"` + Target *uint `xml:"target,attr"` + Unit *uint `xml:"unit,attr"` } type DomainConsole struct { @@ -792,3 +793,11 @@ func (d *DomainRNG) Marshal() (string, error) { } return string(doc), nil } + +type HexUint uint + +func (h *HexUint) UnmarshalXMLAttr(attr xml.Attr) error { + val, err := strconv.ParseUint(attr.Value, 0, 32) + *h = HexUint(val) + return err +} diff --git a/domain_test.go b/domain_test.go index 2af451f..d1b107d 100644 --- a/domain_test.go +++ b/domain_test.go @@ -31,10 +31,10 @@ import ( ) type Address struct { - Domain uint - Bus uint - Slot uint - Function uint + Domain HexUint + Bus HexUint + Slot HexUint + Function HexUint } var uhciIndex uint = 0 @@ -48,7 +48,7 @@ var balloonAddr = Address{0, 0, 7, 0} var duplexAddr = Address{0, 0, 8, 0} var serialPort uint = 0 -var tabletBus uint = 0 +var tabletBus HexUint = 0 var tabletPort uint = 1 var nicAverage int = 1000 -- 1.8.3.1

--- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5e6be77..dd13140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ go: - 1.5 - 1.6 - 1.7 + - 1.8 + - 1.9 script: go test -timeout 1m -v -- 1.8.3.1

On Wed, Sep 13, 2017 at 01:57:44PM +0100, Dean Smith wrote:
*** BLURB HERE *** I have taken Anton Kryukovs fix from #13 on github and am submitting along with addition of 1.8 and 1.9 as travis go version targets
Example of failing running on 1.9, which passes on 1.7 can be found at git@github.com:deasmi/libvirt-go-xml.git branch parsefailtest
Thanks I've pushed these patches 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
-
Dean Smith