libvirtxml unmarshaling of SystemInfo seems missing/broken
Hello,
I am trying to get the SystemInfo using the Go API, similarly to what I do for example when getting capabilities.
Getting capabilities is as easy as doing:
var (
err error
xmldata string
caps libvirtxml.Caps
)
xmldata, err = hv.conn.GetCapabilities()
err = caps.Unmarshal(xmldata)
Instead, there is no SystemInfo.Unmarshal(), so one is left attempting to use libvirtxml.DomainSysInfo , which contains similar information, but the only APIs I could find require roughly this mess:
var (
smbios libvirtxml.DomainSysInfo
r io.Reader
decoder *xml.Decoder
start xml.StartElement
attr xml.Attr
)
xmldata, err = hv.conn.GetSysinfo(0)
r = strings.NewReader(xmldata)
decoder = xml.NewDecoder(r)
attr = xml.Attr {
Name: xml.Name { Local: "type" },
Value: "smbios",
}
start = xml.StartElement {
Name: xml.Name { Local: "sysinfo" },
Attr: []xml.Attr { attr },
}
err = smbios.UnmarshalXML(decoder, start)
/* I get err="EOF" here! */
The issues I see are:
-
It is cumbersome not to have a SysInfo type with the .Unmarshal() method, just like Caps for capabilities, to avoid all the error-prone stuff above.
-
I still do not get it to parse the XML correctly, I keep getting err=="EOF". I am trying to get the SMBIOS part of the structure filled, and it is not evident to me what is going wrong.