Mailing List Archive

[PATCH 5/9] go/xenlight: More informative error messages
If an error is encountered deep in a complicated data structure, it's
often difficult to tell where the error actually is. Make the error
message from the generated toC() and fromC() structures more
informative by tagging which field being converted encountered the
error. This will have the effect of giving a "stack trace" of the
failure inside a nested data structure.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
---
CC: Nick Rosbrook <rosbrookn@ainfosec.com>
---
tools/golang/xenlight/gengotypes.py | 10 +-
tools/golang/xenlight/helpers.gen.go | 456 +++++++++++++--------------
2 files changed, 233 insertions(+), 233 deletions(-)

diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
index e4ed4d50f5..48e3d86f70 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -314,7 +314,7 @@ def xenlight_golang_convert_from_C(ty = None, outer_name = None, cvarname = None
# If the type is not castable, we need to call its fromC
# function.
s += 'if err := x.{}.fromC(&{}.{});'.format(goname,cvarname,cname)
- s += 'err != nil {\n return err \n}\n'
+ s += 'err != nil {{\nreturn fmt.Errorf("Converting field {}: %v", err) \n}}\n'.format(goname)

elif gotypename == 'string':
# Use the cgo helper for converting C strings.
@@ -389,7 +389,7 @@ def xenlight_golang_union_from_C(ty = None, union_name = '', struct_name = ''):

s += 'var {} {}\n'.format(goname, gotype)
s += 'if err := {}.fromC(xc);'.format(goname)
- s += 'err != nil {\n return err \n}\n'
+ s += 'err != nil {{\n return fmt.Errorf("Converting field {}: %v", err) \n}}\n'.format(goname)

field_name = xenlight_golang_fmt_name('{}_union'.format(keyname))
s += 'x.{} = {}\n'.format(field_name, goname)
@@ -432,7 +432,7 @@ def xenlight_golang_array_from_C(ty = None):
s += 'x.{}[i] = {}(v)\n'.format(goname, gotypename)
else:
s += 'if err := x.{}[i].fromC(&v); err != nil {{\n'.format(goname)
- s += 'return err }\n'
+ s += 'return fmt.Errorf("Converting field {}: %v", err) }}\n'.format(goname)

s += '}\n}\n'

@@ -497,7 +497,7 @@ def xenlight_golang_define_to_C(ty = None, typename = None, nested = False):
s += 'xc.{}, err = x.{}.toC()\n'.format(cname,goname)
s += 'if err != nil {\n'
s += 'C.{}(&xc)\n'.format(ty.dispose_fn)
- s += 'return xc, err\n'
+ s += 'return xc, fmt.Errorf("Converting field {}: %v", err)\n'.format(goname)
s += '}\n'

elif isinstance(f.type, idl.Struct):
@@ -567,7 +567,7 @@ def xenlight_golang_union_to_C(ty = None, union_name = '',
s += '{}.{}, err = tmp.{}.toC()\n'.format(f.name,uf.name,gofname)
s += 'if err != nil {\n'
s += 'C.{}(&xc)\n'.format(dispose_fn)
- s += 'return xc,err \n}\n'
+ s += 'return xc,fmt.Errorf("Converting field {}: %v", err) \n}}\n'.format(gofname)

elif gotypename == 'string':
s += 'if tmp.{} != "" {{\n'.format(gofname)
diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 2236222cc2..f165968fd9 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -74,13 +74,13 @@ func (x *VgaInterfaceInfo) toC() (xc C.libxl_vga_interface_info, err error) {

func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error {
if err := x.Enable.fromC(&xc.enable); err != nil {
- return err
+ return fmt.Errorf("Converting field Enable: %v", err)
}
x.Listen = C.GoString(xc.listen)
x.Passwd = C.GoString(xc.passwd)
x.Display = int(xc.display)
if err := x.Findunused.fromC(&xc.findunused); err != nil {
- return err
+ return fmt.Errorf("Converting field Findunused: %v", err)
}

return nil
@@ -91,7 +91,7 @@ func (x *VncInfo) toC() (xc C.libxl_vnc_info, err error) {
xc.enable, err = x.Enable.toC()
if err != nil {
C.libxl_vnc_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Enable: %v", err)
}
if x.Listen != "" {
xc.listen = C.CString(x.Listen)
@@ -103,30 +103,30 @@ func (x *VncInfo) toC() (xc C.libxl_vnc_info, err error) {
xc.findunused, err = x.Findunused.toC()
if err != nil {
C.libxl_vnc_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Findunused: %v", err)
}
return xc, nil
}

func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error {
if err := x.Enable.fromC(&xc.enable); err != nil {
- return err
+ return fmt.Errorf("Converting field Enable: %v", err)
}
x.Port = int(xc.port)
x.TlsPort = int(xc.tls_port)
x.Host = C.GoString(xc.host)
if err := x.DisableTicketing.fromC(&xc.disable_ticketing); err != nil {
- return err
+ return fmt.Errorf("Converting field DisableTicketing: %v", err)
}
x.Passwd = C.GoString(xc.passwd)
if err := x.AgentMouse.fromC(&xc.agent_mouse); err != nil {
- return err
+ return fmt.Errorf("Converting field AgentMouse: %v", err)
}
if err := x.Vdagent.fromC(&xc.vdagent); err != nil {
- return err
+ return fmt.Errorf("Converting field Vdagent: %v", err)
}
if err := x.ClipboardSharing.fromC(&xc.clipboard_sharing); err != nil {
- return err
+ return fmt.Errorf("Converting field ClipboardSharing: %v", err)
}
x.Usbredirection = int(xc.usbredirection)
x.ImageCompression = C.GoString(xc.image_compression)
@@ -140,7 +140,7 @@ func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) {
xc.enable, err = x.Enable.toC()
if err != nil {
C.libxl_spice_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Enable: %v", err)
}
xc.port = C.int(x.Port)
xc.tls_port = C.int(x.TlsPort)
@@ -150,7 +150,7 @@ func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) {
xc.disable_ticketing, err = x.DisableTicketing.toC()
if err != nil {
C.libxl_spice_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DisableTicketing: %v", err)
}
if x.Passwd != "" {
xc.passwd = C.CString(x.Passwd)
@@ -158,17 +158,17 @@ func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) {
xc.agent_mouse, err = x.AgentMouse.toC()
if err != nil {
C.libxl_spice_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AgentMouse: %v", err)
}
xc.vdagent, err = x.Vdagent.toC()
if err != nil {
C.libxl_spice_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Vdagent: %v", err)
}
xc.clipboard_sharing, err = x.ClipboardSharing.toC()
if err != nil {
C.libxl_spice_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ClipboardSharing: %v", err)
}
xc.usbredirection = C.int(x.Usbredirection)
if x.ImageCompression != "" {
@@ -182,10 +182,10 @@ func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) {

func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error {
if err := x.Enable.fromC(&xc.enable); err != nil {
- return err
+ return fmt.Errorf("Converting field Enable: %v", err)
}
if err := x.Opengl.fromC(&xc.opengl); err != nil {
- return err
+ return fmt.Errorf("Converting field Opengl: %v", err)
}
x.Display = C.GoString(xc.display)
x.Xauthority = C.GoString(xc.xauthority)
@@ -198,12 +198,12 @@ func (x *SdlInfo) toC() (xc C.libxl_sdl_info, err error) {
xc.enable, err = x.Enable.toC()
if err != nil {
C.libxl_sdl_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Enable: %v", err)
}
xc.opengl, err = x.Opengl.toC()
if err != nil {
C.libxl_sdl_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Opengl: %v", err)
}
if x.Display != "" {
xc.display = C.CString(x.Display)
@@ -216,7 +216,7 @@ func (x *SdlInfo) toC() (xc C.libxl_sdl_info, err error) {

func (x *Dominfo) fromC(xc *C.libxl_dominfo) error {
if err := x.Uuid.fromC(&xc.uuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Uuid: %v", err)
}
x.Domid = Domid(xc.domid)
x.Ssidref = uint32(xc.ssidref)
@@ -247,7 +247,7 @@ func (x *Dominfo) toC() (xc C.libxl_dominfo, err error) {
xc.uuid, err = x.Uuid.toC()
if err != nil {
C.libxl_dominfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Uuid: %v", err)
}
xc.domid = C.libxl_domid(x.Domid)
xc.ssidref = C.uint32_t(x.Ssidref)
@@ -280,7 +280,7 @@ func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error {
x.Sched = Scheduler(xc.sched)
x.NDom = uint32(xc.n_dom)
if err := x.Cpumap.fromC(&xc.cpumap); err != nil {
- return err
+ return fmt.Errorf("Converting field Cpumap: %v", err)
}

return nil
@@ -297,7 +297,7 @@ func (x *Cpupoolinfo) toC() (xc C.libxl_cpupoolinfo, err error) {
xc.cpumap, err = x.Cpumap.toC()
if err != nil {
C.libxl_cpupoolinfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Cpumap: %v", err)
}
return xc, nil
}
@@ -316,7 +316,7 @@ func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error {
case ChannelConnectionPty:
var connectionPty ChannelinfoConnectionUnionPty
if err := connectionPty.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field connectionPty: %v", err)
}
x.ConnectionUnion = connectionPty
default:
@@ -372,7 +372,7 @@ func (x *Channelinfo) toC() (xc C.libxl_channelinfo, err error) {

func (x *Vminfo) fromC(xc *C.libxl_vminfo) error {
if err := x.Uuid.fromC(&xc.uuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Uuid: %v", err)
}
x.Domid = Domid(xc.domid)

@@ -384,7 +384,7 @@ func (x *Vminfo) toC() (xc C.libxl_vminfo, err error) {
xc.uuid, err = x.Uuid.toC()
if err != nil {
C.libxl_vminfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Uuid: %v", err)
}
xc.domid = C.libxl_domid(x.Domid)
return xc, nil
@@ -447,30 +447,30 @@ func (x *VersionInfo) toC() (xc C.libxl_version_info, err error) {
func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_create_info) error {
x.Type = DomainType(xc._type)
if err := x.Hap.fromC(&xc.hap); err != nil {
- return err
+ return fmt.Errorf("Converting field Hap: %v", err)
}
if err := x.Oos.fromC(&xc.oos); err != nil {
- return err
+ return fmt.Errorf("Converting field Oos: %v", err)
}
x.Ssidref = uint32(xc.ssidref)
x.SsidLabel = C.GoString(xc.ssid_label)
x.Name = C.GoString(xc.name)
if err := x.Uuid.fromC(&xc.uuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Uuid: %v", err)
}
if err := x.Xsdata.fromC(&xc.xsdata); err != nil {
- return err
+ return fmt.Errorf("Converting field Xsdata: %v", err)
}
if err := x.Platformdata.fromC(&xc.platformdata); err != nil {
- return err
+ return fmt.Errorf("Converting field Platformdata: %v", err)
}
x.Poolid = uint32(xc.poolid)
x.PoolName = C.GoString(xc.pool_name)
if err := x.RunHotplugScripts.fromC(&xc.run_hotplug_scripts); err != nil {
- return err
+ return fmt.Errorf("Converting field RunHotplugScripts: %v", err)
}
if err := x.DriverDomain.fromC(&xc.driver_domain); err != nil {
- return err
+ return fmt.Errorf("Converting field DriverDomain: %v", err)
}
x.Passthrough = Passthrough(xc.passthrough)

@@ -483,12 +483,12 @@ func (x *DomainCreateInfo) toC() (xc C.libxl_domain_create_info, err error) {
xc.hap, err = x.Hap.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Hap: %v", err)
}
xc.oos, err = x.Oos.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Oos: %v", err)
}
xc.ssidref = C.uint32_t(x.Ssidref)
if x.SsidLabel != "" {
@@ -500,17 +500,17 @@ func (x *DomainCreateInfo) toC() (xc C.libxl_domain_create_info, err error) {
xc.uuid, err = x.Uuid.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Uuid: %v", err)
}
xc.xsdata, err = x.Xsdata.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Xsdata: %v", err)
}
xc.platformdata, err = x.Platformdata.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Platformdata: %v", err)
}
xc.poolid = C.uint32_t(x.Poolid)
if x.PoolName != "" {
@@ -519,12 +519,12 @@ func (x *DomainCreateInfo) toC() (xc C.libxl_domain_create_info, err error) {
xc.run_hotplug_scripts, err = x.RunHotplugScripts.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field RunHotplugScripts: %v", err)
}
xc.driver_domain, err = x.DriverDomain.toC()
if err != nil {
C.libxl_domain_create_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DriverDomain: %v", err)
}
xc.passthrough = C.libxl_passthrough(x.Passthrough)
return xc, nil
@@ -535,7 +535,7 @@ func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) error {
x.StreamVersion = uint32(xc.stream_version)
x.ColoProxyScript = C.GoString(xc.colo_proxy_script)
if err := x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != nil {
- return err
+ return fmt.Errorf("Converting field UserspaceColoProxy: %v", err)
}

return nil
@@ -551,7 +551,7 @@ func (x *DomainRestoreParams) toC() (xc C.libxl_domain_restore_params, err error
xc.userspace_colo_proxy, err = x.UserspaceColoProxy.toC()
if err != nil {
C.libxl_domain_restore_params_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field UserspaceColoProxy: %v", err)
}
return xc, nil
}
@@ -586,7 +586,7 @@ func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error {
x.Vcpus = make([]SchedParams, numVcpus)
for i, v := range cVcpus {
if err := x.Vcpus[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vcpus: %v", err)
}
}
}
@@ -651,7 +651,7 @@ func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error {
}
x.Pnode = uint32(xc.pnode)
if err := x.Vcpus.fromC(&xc.vcpus); err != nil {
- return err
+ return fmt.Errorf("Converting field Vcpus: %v", err)
}

return nil
@@ -672,7 +672,7 @@ func (x *VnodeInfo) toC() (xc C.libxl_vnode_info, err error) {
xc.vcpus, err = x.Vcpus.toC()
if err != nil {
C.libxl_vnode_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Vcpus: %v", err)
}
return xc, nil
}
@@ -694,13 +694,13 @@ func (x *RdmReserve) toC() (xc C.libxl_rdm_reserve, err error) {
func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.MaxVcpus = int(xc.max_vcpus)
if err := x.AvailVcpus.fromC(&xc.avail_vcpus); err != nil {
- return err
+ return fmt.Errorf("Converting field AvailVcpus: %v", err)
}
if err := x.Cpumap.fromC(&xc.cpumap); err != nil {
- return err
+ return fmt.Errorf("Converting field Cpumap: %v", err)
}
if err := x.Nodemap.fromC(&xc.nodemap); err != nil {
- return err
+ return fmt.Errorf("Converting field Nodemap: %v", err)
}
x.VcpuHardAffinity = nil
if numVcpuHardAffinity := int(xc.num_vcpu_hard_affinity); numVcpuHardAffinity > 0 {
@@ -708,7 +708,7 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.VcpuHardAffinity = make([]Bitmap, numVcpuHardAffinity)
for i, v := range cVcpuHardAffinity {
if err := x.VcpuHardAffinity[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field VcpuHardAffinity: %v", err)
}
}
}
@@ -718,12 +718,12 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.VcpuSoftAffinity = make([]Bitmap, numVcpuSoftAffinity)
for i, v := range cVcpuSoftAffinity {
if err := x.VcpuSoftAffinity[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field VcpuSoftAffinity: %v", err)
}
}
}
if err := x.NumaPlacement.fromC(&xc.numa_placement); err != nil {
- return err
+ return fmt.Errorf("Converting field NumaPlacement: %v", err)
}
x.TscMode = TscMode(xc.tsc_mode)
x.MaxMemkb = uint64(xc.max_memkb)
@@ -735,13 +735,13 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.ExecSsidref = uint32(xc.exec_ssidref)
x.ExecSsidLabel = C.GoString(xc.exec_ssid_label)
if err := x.Localtime.fromC(&xc.localtime); err != nil {
- return err
+ return fmt.Errorf("Converting field Localtime: %v", err)
}
if err := x.DisableMigrate.fromC(&xc.disable_migrate); err != nil {
- return err
+ return fmt.Errorf("Converting field DisableMigrate: %v", err)
}
if err := x.Cpuid.fromC(&xc.cpuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Cpuid: %v", err)
}
x.BlkdevStart = C.GoString(xc.blkdev_start)
x.VnumaNodes = nil
@@ -750,7 +750,7 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.VnumaNodes = make([]VnodeInfo, numVnumaNodes)
for i, v := range cVnumaNodes {
if err := x.VnumaNodes[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field VnumaNodes: %v", err)
}
}
}
@@ -758,23 +758,23 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.MaxMaptrackFrames = uint32(xc.max_maptrack_frames)
x.DeviceModelVersion = DeviceModelVersion(xc.device_model_version)
if err := x.DeviceModelStubdomain.fromC(&xc.device_model_stubdomain); err != nil {
- return err
+ return fmt.Errorf("Converting field DeviceModelStubdomain: %v", err)
}
x.DeviceModel = C.GoString(xc.device_model)
x.DeviceModelSsidref = uint32(xc.device_model_ssidref)
x.DeviceModelSsidLabel = C.GoString(xc.device_model_ssid_label)
x.DeviceModelUser = C.GoString(xc.device_model_user)
if err := x.Extra.fromC(&xc.extra); err != nil {
- return err
+ return fmt.Errorf("Converting field Extra: %v", err)
}
if err := x.ExtraPv.fromC(&xc.extra_pv); err != nil {
- return err
+ return fmt.Errorf("Converting field ExtraPv: %v", err)
}
if err := x.ExtraHvm.fromC(&xc.extra_hvm); err != nil {
- return err
+ return fmt.Errorf("Converting field ExtraHvm: %v", err)
}
if err := x.SchedParams.fromC(&xc.sched_params); err != nil {
- return err
+ return fmt.Errorf("Converting field SchedParams: %v", err)
}
x.Ioports = nil
if numIoports := int(xc.num_ioports); numIoports > 0 {
@@ -782,7 +782,7 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.Ioports = make([]IoportRange, numIoports)
for i, v := range cIoports {
if err := x.Ioports[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Ioports: %v", err)
}
}
}
@@ -800,12 +800,12 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.Iomem = make([]IomemRange, numIomem)
for i, v := range cIomem {
if err := x.Iomem[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Iomem: %v", err)
}
}
}
if err := x.ClaimMode.fromC(&xc.claim_mode); err != nil {
- return err
+ return fmt.Errorf("Converting field ClaimMode: %v", err)
}
x.EventChannels = uint32(xc.event_channels)
x.Kernel = C.GoString(xc.kernel)
@@ -813,21 +813,21 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
x.Ramdisk = C.GoString(xc.ramdisk)
x.DeviceTree = C.GoString(xc.device_tree)
if err := x.Acpi.fromC(&xc.acpi); err != nil {
- return err
+ return fmt.Errorf("Converting field Acpi: %v", err)
}
x.Bootloader = C.GoString(xc.bootloader)
if err := x.BootloaderArgs.fromC(&xc.bootloader_args); err != nil {
- return err
+ return fmt.Errorf("Converting field BootloaderArgs: %v", err)
}
x.TimerMode = TimerMode(xc.timer_mode)
if err := x.NestedHvm.fromC(&xc.nested_hvm); err != nil {
- return err
+ return fmt.Errorf("Converting field NestedHvm: %v", err)
}
if err := x.Apic.fromC(&xc.apic); err != nil {
- return err
+ return fmt.Errorf("Converting field Apic: %v", err)
}
if err := x.DmRestrict.fromC(&xc.dm_restrict); err != nil {
- return err
+ return fmt.Errorf("Converting field DmRestrict: %v", err)
}
x.Tee = TeeType(xc.tee)
x.Type = DomainType(xc._type)
@@ -835,19 +835,19 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
case DomainTypeHvm:
var typeHvm DomainBuildInfoTypeUnionHvm
if err := typeHvm.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeHvm: %v", err)
}
x.TypeUnion = typeHvm
case DomainTypePv:
var typePv DomainBuildInfoTypeUnionPv
if err := typePv.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typePv: %v", err)
}
x.TypeUnion = typePv
case DomainTypePvh:
var typePvh DomainBuildInfoTypeUnionPvh
if err := typePvh.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typePvh: %v", err)
}
x.TypeUnion = typePvh
default:
@@ -869,100 +869,100 @@ func (x *DomainBuildInfoTypeUnionHvm) fromC(xc *C.libxl_domain_build_info) error
x.Firmware = C.GoString(tmp.firmware)
x.Bios = BiosType(tmp.bios)
if err := x.Pae.fromC(&tmp.pae); err != nil {
- return err
+ return fmt.Errorf("Converting field Pae: %v", err)
}
if err := x.Apic.fromC(&tmp.apic); err != nil {
- return err
+ return fmt.Errorf("Converting field Apic: %v", err)
}
if err := x.Acpi.fromC(&tmp.acpi); err != nil {
- return err
+ return fmt.Errorf("Converting field Acpi: %v", err)
}
if err := x.AcpiS3.fromC(&tmp.acpi_s3); err != nil {
- return err
+ return fmt.Errorf("Converting field AcpiS3: %v", err)
}
if err := x.AcpiS4.fromC(&tmp.acpi_s4); err != nil {
- return err
+ return fmt.Errorf("Converting field AcpiS4: %v", err)
}
if err := x.AcpiLaptopSlate.fromC(&tmp.acpi_laptop_slate); err != nil {
- return err
+ return fmt.Errorf("Converting field AcpiLaptopSlate: %v", err)
}
if err := x.Nx.fromC(&tmp.nx); err != nil {
- return err
+ return fmt.Errorf("Converting field Nx: %v", err)
}
if err := x.Viridian.fromC(&tmp.viridian); err != nil {
- return err
+ return fmt.Errorf("Converting field Viridian: %v", err)
}
if err := x.ViridianEnable.fromC(&tmp.viridian_enable); err != nil {
- return err
+ return fmt.Errorf("Converting field ViridianEnable: %v", err)
}
if err := x.ViridianDisable.fromC(&tmp.viridian_disable); err != nil {
- return err
+ return fmt.Errorf("Converting field ViridianDisable: %v", err)
}
x.Timeoffset = C.GoString(tmp.timeoffset)
if err := x.Hpet.fromC(&tmp.hpet); err != nil {
- return err
+ return fmt.Errorf("Converting field Hpet: %v", err)
}
if err := x.VptAlign.fromC(&tmp.vpt_align); err != nil {
- return err
+ return fmt.Errorf("Converting field VptAlign: %v", err)
}
x.MmioHoleMemkb = uint64(tmp.mmio_hole_memkb)
x.TimerMode = TimerMode(tmp.timer_mode)
if err := x.NestedHvm.fromC(&tmp.nested_hvm); err != nil {
- return err
+ return fmt.Errorf("Converting field NestedHvm: %v", err)
}
if err := x.Altp2M.fromC(&tmp.altp2m); err != nil {
- return err
+ return fmt.Errorf("Converting field Altp2M: %v", err)
}
x.SystemFirmware = C.GoString(tmp.system_firmware)
x.SmbiosFirmware = C.GoString(tmp.smbios_firmware)
x.AcpiFirmware = C.GoString(tmp.acpi_firmware)
x.Hdtype = Hdtype(tmp.hdtype)
if err := x.Nographic.fromC(&tmp.nographic); err != nil {
- return err
+ return fmt.Errorf("Converting field Nographic: %v", err)
}
if err := x.Vga.fromC(&tmp.vga); err != nil {
- return err
+ return fmt.Errorf("Converting field Vga: %v", err)
}
if err := x.Vnc.fromC(&tmp.vnc); err != nil {
- return err
+ return fmt.Errorf("Converting field Vnc: %v", err)
}
x.Keymap = C.GoString(tmp.keymap)
if err := x.Sdl.fromC(&tmp.sdl); err != nil {
- return err
+ return fmt.Errorf("Converting field Sdl: %v", err)
}
if err := x.Spice.fromC(&tmp.spice); err != nil {
- return err
+ return fmt.Errorf("Converting field Spice: %v", err)
}
if err := x.GfxPassthru.fromC(&tmp.gfx_passthru); err != nil {
- return err
+ return fmt.Errorf("Converting field GfxPassthru: %v", err)
}
x.GfxPassthruKind = GfxPassthruKind(tmp.gfx_passthru_kind)
x.Serial = C.GoString(tmp.serial)
x.Boot = C.GoString(tmp.boot)
if err := x.Usb.fromC(&tmp.usb); err != nil {
- return err
+ return fmt.Errorf("Converting field Usb: %v", err)
}
x.Usbversion = int(tmp.usbversion)
x.Usbdevice = C.GoString(tmp.usbdevice)
if err := x.VkbDevice.fromC(&tmp.vkb_device); err != nil {
- return err
+ return fmt.Errorf("Converting field VkbDevice: %v", err)
}
x.Soundhw = C.GoString(tmp.soundhw)
if err := x.XenPlatformPci.fromC(&tmp.xen_platform_pci); err != nil {
- return err
+ return fmt.Errorf("Converting field XenPlatformPci: %v", err)
}
if err := x.UsbdeviceList.fromC(&tmp.usbdevice_list); err != nil {
- return err
+ return fmt.Errorf("Converting field UsbdeviceList: %v", err)
}
x.VendorDevice = VendorDevice(tmp.vendor_device)
if err := x.MsVmGenid.fromC(&tmp.ms_vm_genid); err != nil {
- return err
+ return fmt.Errorf("Converting field MsVmGenid: %v", err)
}
if err := x.SerialList.fromC(&tmp.serial_list); err != nil {
- return err
+ return fmt.Errorf("Converting field SerialList: %v", err)
}
if err := x.Rdm.fromC(&tmp.rdm); err != nil {
- return err
+ return fmt.Errorf("Converting field Rdm: %v", err)
}
x.RdmMemBoundaryMemkb = uint64(tmp.rdm_mem_boundary_memkb)
x.McaCaps = uint64(tmp.mca_caps)
@@ -979,13 +979,13 @@ func (x *DomainBuildInfoTypeUnionPv) fromC(xc *C.libxl_domain_build_info) error
x.SlackMemkb = uint64(tmp.slack_memkb)
x.Bootloader = C.GoString(tmp.bootloader)
if err := x.BootloaderArgs.fromC(&tmp.bootloader_args); err != nil {
- return err
+ return fmt.Errorf("Converting field BootloaderArgs: %v", err)
}
x.Cmdline = C.GoString(tmp.cmdline)
x.Ramdisk = C.GoString(tmp.ramdisk)
x.Features = C.GoString(tmp.features)
if err := x.E820Host.fromC(&tmp.e820_host); err != nil {
- return err
+ return fmt.Errorf("Converting field E820Host: %v", err)
}
return nil
}
@@ -997,7 +997,7 @@ func (x *DomainBuildInfoTypeUnionPvh) fromC(xc *C.libxl_domain_build_info) error

tmp := (*C.libxl_domain_build_info_type_union_pvh)(unsafe.Pointer(&xc.u[0]))
if err := x.Pvshim.fromC(&tmp.pvshim); err != nil {
- return err
+ return fmt.Errorf("Converting field Pvshim: %v", err)
}
x.PvshimPath = C.GoString(tmp.pvshim_path)
x.PvshimCmdline = C.GoString(tmp.pvshim_cmdline)
@@ -1011,17 +1011,17 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.avail_vcpus, err = x.AvailVcpus.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AvailVcpus: %v", err)
}
xc.cpumap, err = x.Cpumap.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Cpumap: %v", err)
}
xc.nodemap, err = x.Nodemap.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Nodemap: %v", err)
}
if numVcpuHardAffinity := len(x.VcpuHardAffinity); numVcpuHardAffinity > 0 {
xc.vcpu_hard_affinity = (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuHardAffinity) * C.sizeof_libxl_bitmap))
@@ -1052,7 +1052,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.numa_placement, err = x.NumaPlacement.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field NumaPlacement: %v", err)
}
xc.tsc_mode = C.libxl_tsc_mode(x.TscMode)
xc.max_memkb = C.uint64_t(x.MaxMemkb)
@@ -1068,17 +1068,17 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.localtime, err = x.Localtime.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Localtime: %v", err)
}
xc.disable_migrate, err = x.DisableMigrate.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DisableMigrate: %v", err)
}
xc.cpuid, err = x.Cpuid.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Cpuid: %v", err)
}
if x.BlkdevStart != "" {
xc.blkdev_start = C.CString(x.BlkdevStart)
@@ -1102,7 +1102,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.device_model_stubdomain, err = x.DeviceModelStubdomain.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DeviceModelStubdomain: %v", err)
}
if x.DeviceModel != "" {
xc.device_model = C.CString(x.DeviceModel)
@@ -1117,22 +1117,22 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.extra, err = x.Extra.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Extra: %v", err)
}
xc.extra_pv, err = x.ExtraPv.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ExtraPv: %v", err)
}
xc.extra_hvm, err = x.ExtraHvm.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ExtraHvm: %v", err)
}
xc.sched_params, err = x.SchedParams.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field SchedParams: %v", err)
}
if numIoports := len(x.Ioports); numIoports > 0 {
xc.ioports = (*C.libxl_ioport_range)(C.malloc(C.ulong(numIoports) * C.sizeof_libxl_ioport_range))
@@ -1171,7 +1171,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.claim_mode, err = x.ClaimMode.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ClaimMode: %v", err)
}
xc.event_channels = C.uint32_t(x.EventChannels)
if x.Kernel != "" {
@@ -1189,7 +1189,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.acpi, err = x.Acpi.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Acpi: %v", err)
}
if x.Bootloader != "" {
xc.bootloader = C.CString(x.Bootloader)
@@ -1197,23 +1197,23 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
xc.bootloader_args, err = x.BootloaderArgs.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field BootloaderArgs: %v", err)
}
xc.timer_mode = C.libxl_timer_mode(x.TimerMode)
xc.nested_hvm, err = x.NestedHvm.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field NestedHvm: %v", err)
}
xc.apic, err = x.Apic.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Apic: %v", err)
}
xc.dm_restrict, err = x.DmRestrict.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DmRestrict: %v", err)
}
xc.tee = C.libxl_tee_type(x.Tee)
xc._type = C.libxl_domain_type(x.Type)
@@ -1232,52 +1232,52 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.pae, err = tmp.Pae.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Pae: %v", err)
}
hvm.apic, err = tmp.Apic.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Apic: %v", err)
}
hvm.acpi, err = tmp.Acpi.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Acpi: %v", err)
}
hvm.acpi_s3, err = tmp.AcpiS3.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AcpiS3: %v", err)
}
hvm.acpi_s4, err = tmp.AcpiS4.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AcpiS4: %v", err)
}
hvm.acpi_laptop_slate, err = tmp.AcpiLaptopSlate.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AcpiLaptopSlate: %v", err)
}
hvm.nx, err = tmp.Nx.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Nx: %v", err)
}
hvm.viridian, err = tmp.Viridian.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Viridian: %v", err)
}
hvm.viridian_enable, err = tmp.ViridianEnable.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ViridianEnable: %v", err)
}
hvm.viridian_disable, err = tmp.ViridianDisable.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ViridianDisable: %v", err)
}
if tmp.Timeoffset != "" {
hvm.timeoffset = C.CString(tmp.Timeoffset)
@@ -1285,24 +1285,24 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.hpet, err = tmp.Hpet.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Hpet: %v", err)
}
hvm.vpt_align, err = tmp.VptAlign.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field VptAlign: %v", err)
}
hvm.mmio_hole_memkb = C.uint64_t(tmp.MmioHoleMemkb)
hvm.timer_mode = C.libxl_timer_mode(tmp.TimerMode)
hvm.nested_hvm, err = tmp.NestedHvm.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field NestedHvm: %v", err)
}
hvm.altp2m, err = tmp.Altp2M.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Altp2M: %v", err)
}
if tmp.SystemFirmware != "" {
hvm.system_firmware = C.CString(tmp.SystemFirmware)
@@ -1317,17 +1317,17 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.nographic, err = tmp.Nographic.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Nographic: %v", err)
}
hvm.vga, err = tmp.Vga.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Vga: %v", err)
}
hvm.vnc, err = tmp.Vnc.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Vnc: %v", err)
}
if tmp.Keymap != "" {
hvm.keymap = C.CString(tmp.Keymap)
@@ -1335,17 +1335,17 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.sdl, err = tmp.Sdl.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Sdl: %v", err)
}
hvm.spice, err = tmp.Spice.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Spice: %v", err)
}
hvm.gfx_passthru, err = tmp.GfxPassthru.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field GfxPassthru: %v", err)
}
hvm.gfx_passthru_kind = C.libxl_gfx_passthru_kind(tmp.GfxPassthruKind)
if tmp.Serial != "" {
@@ -1357,7 +1357,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.usb, err = tmp.Usb.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Usb: %v", err)
}
hvm.usbversion = C.int(tmp.Usbversion)
if tmp.Usbdevice != "" {
@@ -1366,7 +1366,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.vkb_device, err = tmp.VkbDevice.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field VkbDevice: %v", err)
}
if tmp.Soundhw != "" {
hvm.soundhw = C.CString(tmp.Soundhw)
@@ -1374,28 +1374,28 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
hvm.xen_platform_pci, err = tmp.XenPlatformPci.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field XenPlatformPci: %v", err)
}
hvm.usbdevice_list, err = tmp.UsbdeviceList.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field UsbdeviceList: %v", err)
}
hvm.vendor_device = C.libxl_vendor_device(tmp.VendorDevice)
hvm.ms_vm_genid, err = tmp.MsVmGenid.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field MsVmGenid: %v", err)
}
hvm.serial_list, err = tmp.SerialList.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field SerialList: %v", err)
}
hvm.rdm, err = tmp.Rdm.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Rdm: %v", err)
}
hvm.rdm_mem_boundary_memkb = C.uint64_t(tmp.RdmMemBoundaryMemkb)
hvm.mca_caps = C.uint64_t(tmp.McaCaps)
@@ -1418,7 +1418,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
pv.bootloader_args, err = tmp.BootloaderArgs.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field BootloaderArgs: %v", err)
}
if tmp.Cmdline != "" {
pv.cmdline = C.CString(tmp.Cmdline)
@@ -1432,7 +1432,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
pv.e820_host, err = tmp.E820Host.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field E820Host: %v", err)
}
pvBytes := C.GoBytes(unsafe.Pointer(&pv), C.sizeof_libxl_domain_build_info_type_union_pv)
copy(xc.u[:], pvBytes)
@@ -1446,7 +1446,7 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) {
pvh.pvshim, err = tmp.Pvshim.toC()
if err != nil {
C.libxl_domain_build_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Pvshim: %v", err)
}
if tmp.PvshimPath != "" {
pvh.pvshim_path = C.CString(tmp.PvshimPath)
@@ -1473,10 +1473,10 @@ func (x *DeviceVfb) fromC(xc *C.libxl_device_vfb) error {
x.BackendDomname = C.GoString(xc.backend_domname)
x.Devid = Devid(xc.devid)
if err := x.Vnc.fromC(&xc.vnc); err != nil {
- return err
+ return fmt.Errorf("Converting field Vnc: %v", err)
}
if err := x.Sdl.fromC(&xc.sdl); err != nil {
- return err
+ return fmt.Errorf("Converting field Sdl: %v", err)
}
x.Keymap = C.GoString(xc.keymap)

@@ -1493,12 +1493,12 @@ func (x *DeviceVfb) toC() (xc C.libxl_device_vfb, err error) {
xc.vnc, err = x.Vnc.toC()
if err != nil {
C.libxl_device_vfb_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Vnc: %v", err)
}
xc.sdl, err = x.Sdl.toC()
if err != nil {
C.libxl_device_vfb_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Sdl: %v", err)
}
if x.Keymap != "" {
xc.keymap = C.CString(x.Keymap)
@@ -1563,13 +1563,13 @@ func (x *DeviceDisk) fromC(xc *C.libxl_device_disk) error {
x.IsCdrom = int(xc.is_cdrom)
x.DirectIoSafe = bool(xc.direct_io_safe)
if err := x.DiscardEnable.fromC(&xc.discard_enable); err != nil {
- return err
+ return fmt.Errorf("Converting field DiscardEnable: %v", err)
}
if err := x.ColoEnable.fromC(&xc.colo_enable); err != nil {
- return err
+ return fmt.Errorf("Converting field ColoEnable: %v", err)
}
if err := x.ColoRestoreEnable.fromC(&xc.colo_restore_enable); err != nil {
- return err
+ return fmt.Errorf("Converting field ColoRestoreEnable: %v", err)
}
x.ColoHost = C.GoString(xc.colo_host)
x.ColoPort = int(xc.colo_port)
@@ -1604,17 +1604,17 @@ func (x *DeviceDisk) toC() (xc C.libxl_device_disk, err error) {
xc.discard_enable, err = x.DiscardEnable.toC()
if err != nil {
C.libxl_device_disk_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field DiscardEnable: %v", err)
}
xc.colo_enable, err = x.ColoEnable.toC()
if err != nil {
C.libxl_device_disk_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ColoEnable: %v", err)
}
xc.colo_restore_enable, err = x.ColoRestoreEnable.toC()
if err != nil {
C.libxl_device_disk_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field ColoRestoreEnable: %v", err)
}
if x.ColoHost != "" {
xc.colo_host = C.CString(x.ColoHost)
@@ -1639,7 +1639,7 @@ func (x *DeviceNic) fromC(xc *C.libxl_device_nic) error {
x.Mtu = int(xc.mtu)
x.Model = C.GoString(xc.model)
if err := x.Mac.fromC(&xc.mac); err != nil {
- return err
+ return fmt.Errorf("Converting field Mac: %v", err)
}
x.Ip = C.GoString(xc.ip)
x.Bridge = C.GoString(xc.bridge)
@@ -1716,7 +1716,7 @@ func (x *DeviceNic) toC() (xc C.libxl_device_nic, err error) {
xc.mac, err = x.Mac.toC()
if err != nil {
C.libxl_device_nic_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Mac: %v", err)
}
if x.Ip != "" {
xc.ip = C.CString(x.Ip)
@@ -1966,7 +1966,7 @@ func (x *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error {
case UsbdevTypeHostdev:
var typeHostdev DeviceUsbdevTypeUnionHostdev
if err := typeHostdev.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeHostdev: %v", err)
}
x.TypeUnion = typeHostdev
default:
@@ -2029,7 +2029,7 @@ func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) error {
x.BackendDomname = C.GoString(xc.backend_domname)
x.Devid = Devid(xc.devid)
if err := x.Uuid.fromC(&xc.uuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Uuid: %v", err)
}

return nil
@@ -2045,7 +2045,7 @@ func (x *DeviceVtpm) toC() (xc C.libxl_device_vtpm, err error) {
xc.uuid, err = x.Uuid.toC()
if err != nil {
C.libxl_device_vtpm_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Uuid: %v", err)
}
return xc, nil
}
@@ -2108,7 +2108,7 @@ func (x *DeviceChannel) fromC(xc *C.libxl_device_channel) error {
case ChannelConnectionSocket:
var connectionSocket DeviceChannelConnectionUnionSocket
if err := connectionSocket.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field connectionSocket: %v", err)
}
x.ConnectionUnion = connectionSocket
default:
@@ -2187,7 +2187,7 @@ func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdispl) error {
x.Connectors = make([]ConnectorParam, numConnectors)
for i, v := range cConnectors {
if err := x.Connectors[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Connectors: %v", err)
}
}
}
@@ -2271,7 +2271,7 @@ func (x *VsndStream) fromC(xc *C.libxl_vsnd_stream) error {
x.UniqueId = C.GoString(xc.unique_id)
x.Type = VsndStreamType(xc._type)
if err := x.Params.fromC(&xc.params); err != nil {
- return err
+ return fmt.Errorf("Converting field Params: %v", err)
}

return nil
@@ -2286,7 +2286,7 @@ func (x *VsndStream) toC() (xc C.libxl_vsnd_stream, err error) {
xc.params, err = x.Params.toC()
if err != nil {
C.libxl_vsnd_stream_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Params: %v", err)
}
return xc, nil
}
@@ -2294,7 +2294,7 @@ func (x *VsndStream) toC() (xc C.libxl_vsnd_stream, err error) {
func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error {
x.Name = C.GoString(xc.name)
if err := x.Params.fromC(&xc.params); err != nil {
- return err
+ return fmt.Errorf("Converting field Params: %v", err)
}
x.Streams = nil
if numVsndStreams := int(xc.num_vsnd_streams); numVsndStreams > 0 {
@@ -2302,7 +2302,7 @@ func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error {
x.Streams = make([]VsndStream, numVsndStreams)
for i, v := range cStreams {
if err := x.Streams[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Streams: %v", err)
}
}
}
@@ -2318,7 +2318,7 @@ func (x *VsndPcm) toC() (xc C.libxl_vsnd_pcm, err error) {
xc.params, err = x.Params.toC()
if err != nil {
C.libxl_vsnd_pcm_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Params: %v", err)
}
if numVsndStreams := len(x.Streams); numVsndStreams > 0 {
xc.streams = (*C.libxl_vsnd_stream)(C.malloc(C.ulong(numVsndStreams) * C.sizeof_libxl_vsnd_stream))
@@ -2343,7 +2343,7 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error {
x.ShortName = C.GoString(xc.short_name)
x.LongName = C.GoString(xc.long_name)
if err := x.Params.fromC(&xc.params); err != nil {
- return err
+ return fmt.Errorf("Converting field Params: %v", err)
}
x.Pcms = nil
if numVsndPcms := int(xc.num_vsnd_pcms); numVsndPcms > 0 {
@@ -2351,7 +2351,7 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error {
x.Pcms = make([]VsndPcm, numVsndPcms)
for i, v := range cPcms {
if err := x.Pcms[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Pcms: %v", err)
}
}
}
@@ -2375,7 +2375,7 @@ func (x *DeviceVsnd) toC() (xc C.libxl_device_vsnd, err error) {
xc.params, err = x.Params.toC()
if err != nil {
C.libxl_device_vsnd_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Params: %v", err)
}
if numVsndPcms := len(x.Pcms); numVsndPcms > 0 {
xc.pcms = (*C.libxl_vsnd_pcm)(C.malloc(C.ulong(numVsndPcms) * C.sizeof_libxl_vsnd_pcm))
@@ -2395,10 +2395,10 @@ func (x *DeviceVsnd) toC() (xc C.libxl_device_vsnd, err error) {

func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
if err := x.CInfo.fromC(&xc.c_info); err != nil {
- return err
+ return fmt.Errorf("Converting field CInfo: %v", err)
}
if err := x.BInfo.fromC(&xc.b_info); err != nil {
- return err
+ return fmt.Errorf("Converting field BInfo: %v", err)
}
x.Disks = nil
if numDisks := int(xc.num_disks); numDisks > 0 {
@@ -2406,7 +2406,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Disks = make([]DeviceDisk, numDisks)
for i, v := range cDisks {
if err := x.Disks[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Disks: %v", err)
}
}
}
@@ -2416,7 +2416,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Nics = make([]DeviceNic, numNics)
for i, v := range cNics {
if err := x.Nics[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Nics: %v", err)
}
}
}
@@ -2426,7 +2426,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Pcidevs = make([]DevicePci, numPcidevs)
for i, v := range cPcidevs {
if err := x.Pcidevs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Pcidevs: %v", err)
}
}
}
@@ -2436,7 +2436,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Rdms = make([]DeviceRdm, numRdms)
for i, v := range cRdms {
if err := x.Rdms[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Rdms: %v", err)
}
}
}
@@ -2446,7 +2446,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Dtdevs = make([]DeviceDtdev, numDtdevs)
for i, v := range cDtdevs {
if err := x.Dtdevs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Dtdevs: %v", err)
}
}
}
@@ -2456,7 +2456,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Vfbs = make([]DeviceVfb, numVfbs)
for i, v := range cVfbs {
if err := x.Vfbs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vfbs: %v", err)
}
}
}
@@ -2466,7 +2466,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Vkbs = make([]DeviceVkb, numVkbs)
for i, v := range cVkbs {
if err := x.Vkbs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vkbs: %v", err)
}
}
}
@@ -2476,7 +2476,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Vtpms = make([]DeviceVtpm, numVtpms)
for i, v := range cVtpms {
if err := x.Vtpms[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vtpms: %v", err)
}
}
}
@@ -2486,7 +2486,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.P9S = make([]DeviceP9, numP9S)
for i, v := range cP9S {
if err := x.P9S[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field P9S: %v", err)
}
}
}
@@ -2496,7 +2496,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Pvcallsifs = make([]DevicePvcallsif, numPvcallsifs)
for i, v := range cPvcallsifs {
if err := x.Pvcallsifs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Pvcallsifs: %v", err)
}
}
}
@@ -2506,7 +2506,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Vdispls = make([]DeviceVdispl, numVdispls)
for i, v := range cVdispls {
if err := x.Vdispls[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vdispls: %v", err)
}
}
}
@@ -2516,7 +2516,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Vsnds = make([]DeviceVsnd, numVsnds)
for i, v := range cVsnds {
if err := x.Vsnds[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Vsnds: %v", err)
}
}
}
@@ -2526,7 +2526,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Channels = make([]DeviceChannel, numChannels)
for i, v := range cChannels {
if err := x.Channels[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Channels: %v", err)
}
}
}
@@ -2536,7 +2536,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Usbctrls = make([]DeviceUsbctrl, numUsbctrls)
for i, v := range cUsbctrls {
if err := x.Usbctrls[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Usbctrls: %v", err)
}
}
}
@@ -2546,7 +2546,7 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
x.Usbdevs = make([]DeviceUsbdev, numUsbdevs)
for i, v := range cUsbdevs {
if err := x.Usbdevs[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Usbdevs: %v", err)
}
}
}
@@ -2564,12 +2564,12 @@ func (x *DomainConfig) toC() (xc C.libxl_domain_config, err error) {
xc.c_info, err = x.CInfo.toC()
if err != nil {
C.libxl_domain_config_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field CInfo: %v", err)
}
xc.b_info, err = x.BInfo.toC()
if err != nil {
C.libxl_domain_config_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field BInfo: %v", err)
}
if numDisks := len(x.Disks); numDisks > 0 {
xc.disks = (*C.libxl_device_disk)(C.malloc(C.ulong(numDisks) * C.sizeof_libxl_device_disk))
@@ -2846,7 +2846,7 @@ func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error {
x.Evtch = int(xc.evtch)
x.Rref = int(xc.rref)
if err := x.Uuid.fromC(&xc.uuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Uuid: %v", err)
}

return nil
@@ -2869,7 +2869,7 @@ func (x *Vtpminfo) toC() (xc C.libxl_vtpminfo, err error) {
xc.uuid, err = x.Uuid.toC()
if err != nil {
C.libxl_vtpminfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Uuid: %v", err)
}
return xc, nil
}
@@ -2920,10 +2920,10 @@ func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error {
x.Running = bool(xc.running)
x.VcpuTime = uint64(xc.vcpu_time)
if err := x.Cpumap.fromC(&xc.cpumap); err != nil {
- return err
+ return fmt.Errorf("Converting field Cpumap: %v", err)
}
if err := x.CpumapSoft.fromC(&xc.cpumap_soft); err != nil {
- return err
+ return fmt.Errorf("Converting field CpumapSoft: %v", err)
}

return nil
@@ -2940,12 +2940,12 @@ func (x *Vcpuinfo) toC() (xc C.libxl_vcpuinfo, err error) {
xc.cpumap, err = x.Cpumap.toC()
if err != nil {
C.libxl_vcpuinfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Cpumap: %v", err)
}
xc.cpumap_soft, err = x.CpumapSoft.toC()
if err != nil {
C.libxl_vcpuinfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field CpumapSoft: %v", err)
}
return xc, nil
}
@@ -2965,7 +2965,7 @@ func (x *Physinfo) fromC(xc *C.libxl_physinfo) error {
x.MaxPossibleMfn = uint64(xc.max_possible_mfn)
x.NrNodes = uint32(xc.nr_nodes)
if err := x.HwCap.fromC(&xc.hw_cap); err != nil {
- return err
+ return fmt.Errorf("Converting field HwCap: %v", err)
}
x.CapHvm = bool(xc.cap_hvm)
x.CapPv = bool(xc.cap_pv)
@@ -2995,7 +2995,7 @@ func (x *Physinfo) toC() (xc C.libxl_physinfo, err error) {
xc.hw_cap, err = x.HwCap.toC()
if err != nil {
C.libxl_physinfo_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field HwCap: %v", err)
}
xc.cap_hvm = C.bool(x.CapHvm)
xc.cap_pv = C.bool(x.CapPv)
@@ -3046,7 +3046,7 @@ func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error {
x.Connectors = make([]Connectorinfo, numConnectors)
for i, v := range cConnectors {
if err := x.Connectors[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Connectors: %v", err)
}
}
}
@@ -3104,7 +3104,7 @@ func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error {
x.Streams = make([]Streaminfo, numVsndStreams)
for i, v := range cStreams {
if err := x.Streams[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Streams: %v", err)
}
}
}
@@ -3143,7 +3143,7 @@ func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error {
x.Pcms = make([]Pcminfo, numVsndPcms)
for i, v := range cPcms {
if err := x.Pcms[i].fromC(&v); err != nil {
- return err
+ return fmt.Errorf("Converting field Pcms: %v", err)
}
}
}
@@ -3304,26 +3304,26 @@ func (x *SchedCredit2Params) toC() (xc C.libxl_sched_credit2_params, err error)
func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_remus_info) error {
x.Interval = int(xc.interval)
if err := x.AllowUnsafe.fromC(&xc.allow_unsafe); err != nil {
- return err
+ return fmt.Errorf("Converting field AllowUnsafe: %v", err)
}
if err := x.Blackhole.fromC(&xc.blackhole); err != nil {
- return err
+ return fmt.Errorf("Converting field Blackhole: %v", err)
}
if err := x.Compression.fromC(&xc.compression); err != nil {
- return err
+ return fmt.Errorf("Converting field Compression: %v", err)
}
if err := x.Netbuf.fromC(&xc.netbuf); err != nil {
- return err
+ return fmt.Errorf("Converting field Netbuf: %v", err)
}
x.Netbufscript = C.GoString(xc.netbufscript)
if err := x.Diskbuf.fromC(&xc.diskbuf); err != nil {
- return err
+ return fmt.Errorf("Converting field Diskbuf: %v", err)
}
if err := x.Colo.fromC(&xc.colo); err != nil {
- return err
+ return fmt.Errorf("Converting field Colo: %v", err)
}
if err := x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != nil {
- return err
+ return fmt.Errorf("Converting field UserspaceColoProxy: %v", err)
}

return nil
@@ -3335,22 +3335,22 @@ func (x *DomainRemusInfo) toC() (xc C.libxl_domain_remus_info, err error) {
xc.allow_unsafe, err = x.AllowUnsafe.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field AllowUnsafe: %v", err)
}
xc.blackhole, err = x.Blackhole.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Blackhole: %v", err)
}
xc.compression, err = x.Compression.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Compression: %v", err)
}
xc.netbuf, err = x.Netbuf.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Netbuf: %v", err)
}
if x.Netbufscript != "" {
xc.netbufscript = C.CString(x.Netbufscript)
@@ -3358,28 +3358,28 @@ func (x *DomainRemusInfo) toC() (xc C.libxl_domain_remus_info, err error) {
xc.diskbuf, err = x.Diskbuf.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Diskbuf: %v", err)
}
xc.colo, err = x.Colo.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Colo: %v", err)
}
xc.userspace_colo_proxy, err = x.UserspaceColoProxy.toC()
if err != nil {
C.libxl_domain_remus_info_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field UserspaceColoProxy: %v", err)
}
return xc, nil
}

func (x *Event) fromC(xc *C.libxl_event) error {
if err := x.Link.fromC(&xc.link); err != nil {
- return err
+ return fmt.Errorf("Converting field Link: %v", err)
}
x.Domid = Domid(xc.domid)
if err := x.Domuuid.fromC(&xc.domuuid); err != nil {
- return err
+ return fmt.Errorf("Converting field Domuuid: %v", err)
}
x.ForUser = uint64(xc.for_user)
x.Type = EventType(xc._type)
@@ -3387,19 +3387,19 @@ func (x *Event) fromC(xc *C.libxl_event) error {
case EventTypeDomainShutdown:
var typeDomainShutdown EventTypeUnionDomainShutdown
if err := typeDomainShutdown.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeDomainShutdown: %v", err)
}
x.TypeUnion = typeDomainShutdown
case EventTypeDiskEject:
var typeDiskEject EventTypeUnionDiskEject
if err := typeDiskEject.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeDiskEject: %v", err)
}
x.TypeUnion = typeDiskEject
case EventTypeOperationComplete:
var typeOperationComplete EventTypeUnionOperationComplete
if err := typeOperationComplete.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeOperationComplete: %v", err)
}
x.TypeUnion = typeOperationComplete
default:
@@ -3427,7 +3427,7 @@ func (x *EventTypeUnionDiskEject) fromC(xc *C.libxl_event) error {
tmp := (*C.libxl_event_type_union_disk_eject)(unsafe.Pointer(&xc.u[0]))
x.Vdev = C.GoString(tmp.vdev)
if err := x.Disk.fromC(&tmp.disk); err != nil {
- return err
+ return fmt.Errorf("Converting field Disk: %v", err)
}
return nil
}
@@ -3447,13 +3447,13 @@ func (x *Event) toC() (xc C.libxl_event, err error) {
xc.link, err = x.Link.toC()
if err != nil {
C.libxl_event_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Link: %v", err)
}
xc.domid = C.libxl_domid(x.Domid)
xc.domuuid, err = x.Domuuid.toC()
if err != nil {
C.libxl_event_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Domuuid: %v", err)
}
xc.for_user = C.uint64_t(x.ForUser)
xc._type = C.libxl_event_type(x.Type)
@@ -3481,7 +3481,7 @@ func (x *Event) toC() (xc C.libxl_event, err error) {
disk_eject.disk, err = tmp.Disk.toC()
if err != nil {
C.libxl_event_dispose(&xc)
- return xc, err
+ return xc, fmt.Errorf("Converting field Disk: %v", err)
}
disk_ejectBytes := C.GoBytes(unsafe.Pointer(&disk_eject), C.sizeof_libxl_event_type_union_disk_eject)
copy(xc.u[:], disk_ejectBytes)
@@ -3526,13 +3526,13 @@ func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error {
case PsrFeatTypeCat:
var typeCat PsrHwInfoTypeUnionCat
if err := typeCat.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeCat: %v", err)
}
x.TypeUnion = typeCat
case PsrFeatTypeMba:
var typeMba PsrHwInfoTypeUnionMba
if err := typeMba.fromC(xc); err != nil {
- return err
+ return fmt.Errorf("Converting field typeMba: %v", err)
}
x.TypeUnion = typeMba
default:
--
2.24.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] go/xenlight: More informative error messages [ In reply to ]
On Fri, Dec 27, 2019 at 11:33 AM George Dunlap <george.dunlap@citrix.com> wrote:
>
> If an error is encountered deep in a complicated data structure, it's
> often difficult to tell where the error actually is. Make the error
> message from the generated toC() and fromC() structures more
> informative by tagging which field being converted encountered the
> error. This will have the effect of giving a "stack trace" of the
> failure inside a nested data structure.
>
> Signed-off-by: George Dunlap <george.dunlap@citrix.com>

Looks good, just one nit-picky comment:

> diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
> index e4ed4d50f5..48e3d86f70 100644
> --- a/tools/golang/xenlight/gengotypes.py
> +++ b/tools/golang/xenlight/gengotypes.py
> @@ -314,7 +314,7 @@ def xenlight_golang_convert_from_C(ty = None, outer_name = None, cvarname = None
> # If the type is not castable, we need to call its fromC
> # function.
> s += 'if err := x.{}.fromC(&{}.{});'.format(goname,cvarname,cname)
> - s += 'err != nil {\n return err \n}\n'
> + s += 'err != nil {{\nreturn fmt.Errorf("Converting field {}: %v", err) \n}}\n'.format(goname)

It's preferred style to keep error messages lowercase, unless a proper
noun or acronym is used (the field names would be considered proper
nouns).

-NR

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH 5/9] go/xenlight: More informative error messages [ In reply to ]
On 1/4/20 7:06 PM, Nick Rosbrook wrote:
> On Fri, Dec 27, 2019 at 11:33 AM George Dunlap <george.dunlap@citrix.com> wrote:
>>
>> If an error is encountered deep in a complicated data structure, it's
>> often difficult to tell where the error actually is. Make the error
>> message from the generated toC() and fromC() structures more
>> informative by tagging which field being converted encountered the
>> error. This will have the effect of giving a "stack trace" of the
>> failure inside a nested data structure.
>>
>> Signed-off-by: George Dunlap <george.dunlap@citrix.com>
>
> Looks good, just one nit-picky comment:
>
>> diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
>> index e4ed4d50f5..48e3d86f70 100644
>> --- a/tools/golang/xenlight/gengotypes.py
>> +++ b/tools/golang/xenlight/gengotypes.py
>> @@ -314,7 +314,7 @@ def xenlight_golang_convert_from_C(ty = None, outer_name = None, cvarname = None
>> # If the type is not castable, we need to call its fromC
>> # function.
>> s += 'if err := x.{}.fromC(&{}.{});'.format(goname,cvarname,cname)
>> - s += 'err != nil {\n return err \n}\n'
>> + s += 'err != nil {{\nreturn fmt.Errorf("Converting field {}: %v", err) \n}}\n'.format(goname)
>
> It's preferred style to keep error messages lowercase, unless a proper
> noun or acronym is used (the field names would be considered proper
> nouns).

Ack.

-George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel