<div dir="ltr">Hi Daniel!<div><br></div><div>Thank you for review, you're absolutely right about omitempty on structures, sorry for that. Will rename DomainEntry as well.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 1:58 PM, Daniel P. Berrange <span dir="ltr"><<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Jan 05, 2017 at 09:54:25AM +0100, Alexey Slaykovsky wrote:<br>
> Signed-off-by: Alexey Slaykovsky <<a href="mailto:aslaikov@redhat.com">aslaikov@redhat.com</a>><br>
> ---<br>
> domain.go | 68 ++++++++++++++++++++++++<br>
> domain_test.go | 164 ++++++++++++++++++++++++++++++<wbr>+++++++++++++++++++++++++++<br>
> 2 files changed, 232 insertions(+)<br>
><br>
> diff --git a/domain.go b/domain.go<br>
> index c98908e..25155ee 100644<br>
> --- a/domain.go<br>
> +++ b/domain.go<br>
> @@ -126,6 +126,69 @@ type DomainMemory struct {<br>
> Unit string `xml:"unit,attr"`<br>
> }<br>
><br>
> +type DomainOSType struct {<br>
> + Arch string `xml:"arch,attr"`<br>
> + Machine string `xml:"machine,attr"`<br>
> + Type string `xml:",chardata"`<br>
> +}<br>
> +<br>
> +type DomainSMBios struct {<br>
> + Mode string `xml:"mode,attr"`<br>
> +}<br>
> +<br>
> +type DomainNVRam struct {<br>
> + NVRam string `xml:",chardata"`<br>
> + Template string `xml:"template,attr,omitempty"<wbr>`<br>
> +}<br>
> +<br>
> +type DomainBootDevice struct {<br>
> + Dev string `xml:"dev,attr"`<br>
> +}<br>
> +<br>
> +type DomainBootMenu struct {<br>
> + Enabled string `xml:"enabled,attr"`<br>
> + Timeout string `xml:"timeout,attr,omitempty"`<br>
> +}<br>
> +<br>
> +type DomainSysInfo struct {<br>
> + Type string `xml:"type,attr"`<br>
> + System []DomainEntry `xml:"system>entry"`<br>
> + BIOS []DomainEntry `xml:"bios>entry"`<br>
> + BaseBoard []DomainEntry `xml:"baseBoard>entry"`<br>
> +}<br>
> +<br>
> +type DomainEntry struct {<br>
> + Name string `xml:"name,attr"`<br>
> + Value string `xml:",chardata"`<br>
> +}<br>
<br>
</div></div>Can you call this "DomainSysInfoEntry" so its more tightly scoped.<br>
<span class=""><br>
> +<br>
> +type DomainBIOS struct {<br>
> + UseSerial string `xml:"useserial,attr"`<br>
> + RebootTimeout string `xml:"rebootTimeout,attr"`<br>
> +}<br>
> +<br>
> +type DomainLoader struct {<br>
> + Path string `xml:",chardata"`<br>
> + Readonly string `xml:"readonly,attr"`<br>
> + Secure string `xml:"secure,attr"`<br>
> + Type string `xml:"type,attr"`<br>
> +}<br>
> +<br>
> +type DomainOS struct {<br>
> + Type *DomainOSType `xml:"type"`<br>
> + Loader *DomainLoader `xml:"loader,omitempty"`<br>
> + NVRam *DomainNVRam `xml:"nvram"`<br>
<br>
</span>I'm curious why we need 'omitempty' on "Loader" and a few<br>
others below, but don't need it on "NVRam". Based on your<br>
test case it seems the formatter omits NVRam automatically<br>
when it is nil, which would suggest we don't need omitempty<br>
on the other struct fields either - just need it on the<br>
string fields.<br>
<span class=""><br>
> + Kernel string `xml:"kernel,omitempty"`<br>
> + Initrd string `xml:"initrd,omitempty"`<br>
> + KernelArgs string `xml:"cmdline,omitempty"`<br>
> + BootDevices []DomainBootDevice `xml:"boot"`<br>
> + BootMenu *DomainBootMenu `xml:"bootmenu,omitempty"`<br>
> + SMBios *DomainSMBios `xml:"smbios,omitempty"`<br>
> + BIOS *DomainBIOS `xml:"bios,omitempty"`<br>
> + Init string `xml:"init,omitempty"`<br>
> + InitArgs []string `xml:"initarg,omitempty"`<br>
> +}<br>
<br>
</span>Looks good apart from this two nitpicks.<br>
<br>
Regards,<br>
Daniel<br>
<span class="HOEnZb"><font color="#888888">--<br>
|: <a href="http://berrange.com" rel="noreferrer" target="_blank">http://berrange.com</a> -o- <a href="http://www.flickr.com/photos/dberrange/" rel="noreferrer" target="_blank">http://www.flickr.com/photos/<wbr>dberrange/</a> :|<br>
|: <a href="http://libvirt.org" rel="noreferrer" target="_blank">http://libvirt.org</a> -o- <a href="http://virt-manager.org" rel="noreferrer" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://entangle-photo.org" rel="noreferrer" target="_blank">http://entangle-photo.org</a> -o- <a href="http://search.cpan.org/~danberr/" rel="noreferrer" target="_blank">http://search.cpan.org/~<wbr>danberr/</a> :|<br>
</font></span></blockquote></div><br></div>