[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] golang/xenlight: remove call to go fmt in gengotypes.py
commit 16c36d27f2644737c34d4a0fc1de525d0ee185ad Author: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx> AuthorDate: Mon Jun 8 17:10:39 2020 +0100 Commit: George Dunlap <george.dunlap@xxxxxxxxxx> CommitDate: Mon Jun 8 17:11:38 2020 +0100 golang/xenlight: remove call to go fmt in gengotypes.py Since the golang bindings are now set to be re-generated whenever a change is made to tools/libxl/libxl_types.idl, the call to go fmt in gengotypes.py results in a dirty git tree for users without go installed. As an immediate fix, just remove the call to go fmt from gengotypes.py. While here, make sure the DO NOT EDIT comment and package declaration remain formatted correctly. All other generated code is left un-formatted for now. Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> Remove trailing whitespace. Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- tools/golang/xenlight/gengotypes.py | 34 +- tools/golang/xenlight/helpers.gen.go | 7647 ++++++++++++++++------------------ tools/golang/xenlight/types.gen.go | 1708 ++++---- 3 files changed, 4394 insertions(+), 4995 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index 2b71aa1ea8..ecca59745f 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -39,7 +39,7 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None): with open(path, 'w') as f: if comment is not None: f.write(comment) - f.write('package xenlight\n') + f.write('package xenlight\n\n') for ty in types: (tdef, extras) = xenlight_golang_type_define(ty) @@ -52,8 +52,6 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None): f.write(extra) f.write('\n') - go_fmt(path) - def xenlight_golang_type_define(ty = None): """ Generate the Go type definition of ty. @@ -205,7 +203,7 @@ def xenlight_golang_generate_helpers(path = None, types = None, comment = None): with open(path, 'w') as f: if comment is not None: f.write(comment) - f.write('package xenlight\n') + f.write('package xenlight\n\n') f.write('import (\n"unsafe"\n"errors"\n"fmt"\n)\n') # Cgo preamble @@ -240,14 +238,12 @@ def xenlight_golang_generate_helpers(path = None, types = None, comment = None): f.write(xenlight_golang_define_to_C(ty)) f.write('\n') - go_fmt(path) - def xenlight_golang_define_from_C(ty = None): """ Define the fromC marshaling function for the type represented by ty. """ - func = 'func (x *{}) fromC(xc *C.{}) error {{\n {} \n return nil}}\n' + func = 'func (x *{}) fromC(xc *C.{}) error {{\n {}\n return nil}}\n' goname = xenlight_golang_fmt_name(ty.typename) cname = ty.typename @@ -317,7 +313,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 {{\nreturn fmt.Errorf("converting field {}: %v", err) \n}}\n'.format(goname) + 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. @@ -399,7 +395,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 fmt.Errorf("converting field {}: %v", err) \n}}\n'.format(goname) + s += 'err != nil {{\n return fmt.Errorf("converting field {}: %v", err)\n}}\n'.format(goname) s += 'x.{} = {}\n'.format(field_name, goname) @@ -450,7 +446,7 @@ def xenlight_golang_define_to_C(ty = None, typename = None, nested = False): Define the toC marshaling function for the type represented by ty. """ - func = 'func (x *{}) toC(xc *C.{}) (err error){{{}\n return nil \n }}\n' + func = 'func (x *{}) toC(xc *C.{}) (err error){{{}\n return nil\n }}\n' body = '' if ty.dispose_fn is not None: @@ -520,7 +516,7 @@ def xenlight_golang_convert_to_C(ty = None, outer_name = None, if not is_castable: s += 'if err := {}.{}.toC(&{}.{}); err != nil {{\n'.format(govarname,goname, cvarname,cname) - s += 'return fmt.Errorf("converting field {}: %v", err) \n}}\n'.format(goname) + s += 'return fmt.Errorf("converting field {}: %v", err)\n}}\n'.format(goname) elif gotypename == 'string': # Use the cgo helper for converting C strings. @@ -625,7 +621,7 @@ def xenlight_golang_array_to_C(ty = None): golenvar,golenvar) s += 'for i,v := range x.{} {{\n'.format(goname) s += 'if err := v.toC(&c{}[i]); err != nil {{\n'.format(goname) - s += 'return fmt.Errorf("converting field {}: %v", err) \n'.format(goname) + s += 'return fmt.Errorf("converting field {}: %v", err)\n'.format(goname) s += '}\n}\n}\n' return s @@ -719,10 +715,6 @@ def xenlight_golang_fmt_name(name, exported = True): return words[0] + ''.join(x.title() for x in words[1:]) -def go_fmt(path): - """ Call go fmt on the given path. """ - os.system('go fmt {}'.format(path)) - if __name__ == '__main__': idlname = sys.argv[1] @@ -733,12 +725,12 @@ if __name__ == '__main__': builtin_type_names[name] = xenlight_golang_fmt_name(name) header_comment="""// DO NOT EDIT. - // - // This file is generated by: - // {} - // +// +// This file is generated by: +// {} +// - """.format(' '.join(sys.argv)) +""".format(' '.join(sys.argv)) xenlight_golang_generate_types(types=types, comment=header_comment) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index 1e58ebbab2..935d3bc50a 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -7,11 +7,10 @@ package xenlight import ( - "errors" - "fmt" - "unsafe" +"unsafe" +"errors" +"fmt" ) - /* #cgo LDFLAGS: -lxenlight #include <stdlib.h> @@ -30,4710 +29,4154 @@ typedef typeof(((struct libxl_psr_hw_info *)NULL)->u.cat)libxl_psr_hw_info_type_ typedef typeof(((struct libxl_psr_hw_info *)NULL)->u.mba)libxl_psr_hw_info_type_union_mba; */ import "C" - // NewIoportRange returns an instance of IoportRange initialized with defaults. func NewIoportRange() (*IoportRange, error) { - var ( - x IoportRange - xc C.libxl_ioport_range - ) +var ( +x IoportRange +xc C.libxl_ioport_range) - C.libxl_ioport_range_init(&xc) - defer C.libxl_ioport_range_dispose(&xc) +C.libxl_ioport_range_init(&xc) +defer C.libxl_ioport_range_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *IoportRange) fromC(xc *C.libxl_ioport_range) error { - x.First = uint32(xc.first) - x.Number = uint32(xc.number) + x.First = uint32(xc.first) +x.Number = uint32(xc.number) - return nil -} + return nil} -func (x *IoportRange) toC(xc *C.libxl_ioport_range) (err error) { - defer func() { - if err != nil { - C.libxl_ioport_range_dispose(xc) - } - }() +func (x *IoportRange) toC(xc *C.libxl_ioport_range) (err error){defer func(){ +if err != nil{ +C.libxl_ioport_range_dispose(xc)} +}() - xc.first = C.uint32_t(x.First) - xc.number = C.uint32_t(x.Number) +xc.first = C.uint32_t(x.First) +xc.number = C.uint32_t(x.Number) - return nil -} + return nil + } // NewIomemRange returns an instance of IomemRange initialized with defaults. func NewIomemRange() (*IomemRange, error) { - var ( - x IomemRange - xc C.libxl_iomem_range - ) +var ( +x IomemRange +xc C.libxl_iomem_range) - C.libxl_iomem_range_init(&xc) - defer C.libxl_iomem_range_dispose(&xc) +C.libxl_iomem_range_init(&xc) +defer C.libxl_iomem_range_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *IomemRange) fromC(xc *C.libxl_iomem_range) error { - x.Start = uint64(xc.start) - x.Number = uint64(xc.number) - x.Gfn = uint64(xc.gfn) + x.Start = uint64(xc.start) +x.Number = uint64(xc.number) +x.Gfn = uint64(xc.gfn) - return nil -} + return nil} -func (x *IomemRange) toC(xc *C.libxl_iomem_range) (err error) { - defer func() { - if err != nil { - C.libxl_iomem_range_dispose(xc) - } - }() +func (x *IomemRange) toC(xc *C.libxl_iomem_range) (err error){defer func(){ +if err != nil{ +C.libxl_iomem_range_dispose(xc)} +}() - xc.start = C.uint64_t(x.Start) - xc.number = C.uint64_t(x.Number) - xc.gfn = C.uint64_t(x.Gfn) +xc.start = C.uint64_t(x.Start) +xc.number = C.uint64_t(x.Number) +xc.gfn = C.uint64_t(x.Gfn) - return nil -} + return nil + } // NewVgaInterfaceInfo returns an instance of VgaInterfaceInfo initialized with defaults. func NewVgaInterfaceInfo() (*VgaInterfaceInfo, error) { - var ( - x VgaInterfaceInfo - xc C.libxl_vga_interface_info - ) +var ( +x VgaInterfaceInfo +xc C.libxl_vga_interface_info) - C.libxl_vga_interface_info_init(&xc) - defer C.libxl_vga_interface_info_dispose(&xc) +C.libxl_vga_interface_info_init(&xc) +defer C.libxl_vga_interface_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error { - x.Kind = VgaInterfaceType(xc.kind) + x.Kind = VgaInterfaceType(xc.kind) - return nil -} + return nil} -func (x *VgaInterfaceInfo) toC(xc *C.libxl_vga_interface_info) (err error) { - defer func() { - if err != nil { - C.libxl_vga_interface_info_dispose(xc) - } - }() +func (x *VgaInterfaceInfo) toC(xc *C.libxl_vga_interface_info) (err error){defer func(){ +if err != nil{ +C.libxl_vga_interface_info_dispose(xc)} +}() - xc.kind = C.libxl_vga_interface_type(x.Kind) +xc.kind = C.libxl_vga_interface_type(x.Kind) - return nil -} + return nil + } // NewVncInfo returns an instance of VncInfo initialized with defaults. func NewVncInfo() (*VncInfo, error) { - var ( - x VncInfo - xc C.libxl_vnc_info - ) +var ( +x VncInfo +xc C.libxl_vnc_info) - C.libxl_vnc_info_init(&xc) - defer C.libxl_vnc_info_dispose(&xc) +C.libxl_vnc_info_init(&xc) +defer C.libxl_vnc_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { - if err := x.Enable.fromC(&xc.enable); err != nil { - 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 fmt.Errorf("converting field Findunused: %v", err) - } - - return nil -} - -func (x *VncInfo) toC(xc *C.libxl_vnc_info) (err error) { - defer func() { - if err != nil { - C.libxl_vnc_info_dispose(xc) - } - }() - - if err := x.Enable.toC(&xc.enable); err != nil { - return fmt.Errorf("converting field Enable: %v", err) - } - if x.Listen != "" { - xc.listen = C.CString(x.Listen) - } - if x.Passwd != "" { - xc.passwd = C.CString(x.Passwd) - } - xc.display = C.int(x.Display) - if err := x.Findunused.toC(&xc.findunused); err != nil { - return fmt.Errorf("converting field Findunused: %v", err) - } - - return nil + if err := x.Enable.fromC(&xc.enable);err != nil { +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 fmt.Errorf("converting field Findunused: %v", err) } + return nil} + +func (x *VncInfo) toC(xc *C.libxl_vnc_info) (err error){defer func(){ +if err != nil{ +C.libxl_vnc_info_dispose(xc)} +}() + +if err := x.Enable.toC(&xc.enable); err != nil { +return fmt.Errorf("converting field Enable: %v", err) +} +if x.Listen != "" { +xc.listen = C.CString(x.Listen)} +if x.Passwd != "" { +xc.passwd = C.CString(x.Passwd)} +xc.display = C.int(x.Display) +if err := x.Findunused.toC(&xc.findunused); err != nil { +return fmt.Errorf("converting field Findunused: %v", err) +} + + return nil + } + // NewSpiceInfo returns an instance of SpiceInfo initialized with defaults. func NewSpiceInfo() (*SpiceInfo, error) { - var ( - x SpiceInfo - xc C.libxl_spice_info - ) +var ( +x SpiceInfo +xc C.libxl_spice_info) - C.libxl_spice_info_init(&xc) - defer C.libxl_spice_info_dispose(&xc) +C.libxl_spice_info_init(&xc) +defer C.libxl_spice_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error { - if err := x.Enable.fromC(&xc.enable); err != nil { - 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 fmt.Errorf("converting field DisableTicketing: %v", err) - } - x.Passwd = C.GoString(xc.passwd) - if err := x.AgentMouse.fromC(&xc.agent_mouse); err != nil { - return fmt.Errorf("converting field AgentMouse: %v", err) - } - if err := x.Vdagent.fromC(&xc.vdagent); err != nil { - return fmt.Errorf("converting field Vdagent: %v", err) - } - if err := x.ClipboardSharing.fromC(&xc.clipboard_sharing); err != nil { - return fmt.Errorf("converting field ClipboardSharing: %v", err) - } - x.Usbredirection = int(xc.usbredirection) - x.ImageCompression = C.GoString(xc.image_compression) - x.StreamingVideo = C.GoString(xc.streaming_video) - - return nil -} - -func (x *SpiceInfo) toC(xc *C.libxl_spice_info) (err error) { - defer func() { - if err != nil { - C.libxl_spice_info_dispose(xc) - } - }() - - if err := x.Enable.toC(&xc.enable); err != nil { - return fmt.Errorf("converting field Enable: %v", err) - } - xc.port = C.int(x.Port) - xc.tls_port = C.int(x.TlsPort) - if x.Host != "" { - xc.host = C.CString(x.Host) - } - if err := x.DisableTicketing.toC(&xc.disable_ticketing); err != nil { - return fmt.Errorf("converting field DisableTicketing: %v", err) - } - if x.Passwd != "" { - xc.passwd = C.CString(x.Passwd) - } - if err := x.AgentMouse.toC(&xc.agent_mouse); err != nil { - return fmt.Errorf("converting field AgentMouse: %v", err) - } - if err := x.Vdagent.toC(&xc.vdagent); err != nil { - return fmt.Errorf("converting field Vdagent: %v", err) - } - if err := x.ClipboardSharing.toC(&xc.clipboard_sharing); err != nil { - return fmt.Errorf("converting field ClipboardSharing: %v", err) - } - xc.usbredirection = C.int(x.Usbredirection) - if x.ImageCompression != "" { - xc.image_compression = C.CString(x.ImageCompression) - } - if x.StreamingVideo != "" { - xc.streaming_video = C.CString(x.StreamingVideo) - } - - return nil + if err := x.Enable.fromC(&xc.enable);err != nil { +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 fmt.Errorf("converting field DisableTicketing: %v", err) +} +x.Passwd = C.GoString(xc.passwd) +if err := x.AgentMouse.fromC(&xc.agent_mouse);err != nil { +return fmt.Errorf("converting field AgentMouse: %v", err) +} +if err := x.Vdagent.fromC(&xc.vdagent);err != nil { +return fmt.Errorf("converting field Vdagent: %v", err) +} +if err := x.ClipboardSharing.fromC(&xc.clipboard_sharing);err != nil { +return fmt.Errorf("converting field ClipboardSharing: %v", err) +} +x.Usbredirection = int(xc.usbredirection) +x.ImageCompression = C.GoString(xc.image_compression) +x.StreamingVideo = C.GoString(xc.streaming_video) + + return nil} + +func (x *SpiceInfo) toC(xc *C.libxl_spice_info) (err error){defer func(){ +if err != nil{ +C.libxl_spice_info_dispose(xc)} +}() + +if err := x.Enable.toC(&xc.enable); err != nil { +return fmt.Errorf("converting field Enable: %v", err) +} +xc.port = C.int(x.Port) +xc.tls_port = C.int(x.TlsPort) +if x.Host != "" { +xc.host = C.CString(x.Host)} +if err := x.DisableTicketing.toC(&xc.disable_ticketing); err != nil { +return fmt.Errorf("converting field DisableTicketing: %v", err) +} +if x.Passwd != "" { +xc.passwd = C.CString(x.Passwd)} +if err := x.AgentMouse.toC(&xc.agent_mouse); err != nil { +return fmt.Errorf("converting field AgentMouse: %v", err) +} +if err := x.Vdagent.toC(&xc.vdagent); err != nil { +return fmt.Errorf("converting field Vdagent: %v", err) +} +if err := x.ClipboardSharing.toC(&xc.clipboard_sharing); err != nil { +return fmt.Errorf("converting field ClipboardSharing: %v", err) } +xc.usbredirection = C.int(x.Usbredirection) +if x.ImageCompression != "" { +xc.image_compression = C.CString(x.ImageCompression)} +if x.StreamingVideo != "" { +xc.streaming_video = C.CString(x.StreamingVideo)} + + return nil + } // NewSdlInfo returns an instance of SdlInfo initialized with defaults. func NewSdlInfo() (*SdlInfo, error) { - var ( - x SdlInfo - xc C.libxl_sdl_info - ) +var ( +x SdlInfo +xc C.libxl_sdl_info) - C.libxl_sdl_info_init(&xc) - defer C.libxl_sdl_info_dispose(&xc) +C.libxl_sdl_info_init(&xc) +defer C.libxl_sdl_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { - if err := x.Enable.fromC(&xc.enable); err != nil { - return fmt.Errorf("converting field Enable: %v", err) - } - if err := x.Opengl.fromC(&xc.opengl); err != nil { - return fmt.Errorf("converting field Opengl: %v", err) - } - x.Display = C.GoString(xc.display) - x.Xauthority = C.GoString(xc.xauthority) - - return nil -} - -func (x *SdlInfo) toC(xc *C.libxl_sdl_info) (err error) { - defer func() { - if err != nil { - C.libxl_sdl_info_dispose(xc) - } - }() - - if err := x.Enable.toC(&xc.enable); err != nil { - return fmt.Errorf("converting field Enable: %v", err) - } - if err := x.Opengl.toC(&xc.opengl); err != nil { - return fmt.Errorf("converting field Opengl: %v", err) - } - if x.Display != "" { - xc.display = C.CString(x.Display) - } - if x.Xauthority != "" { - xc.xauthority = C.CString(x.Xauthority) - } - - return nil + if err := x.Enable.fromC(&xc.enable);err != nil { +return fmt.Errorf("converting field Enable: %v", err) +} +if err := x.Opengl.fromC(&xc.opengl);err != nil { +return fmt.Errorf("converting field Opengl: %v", err) } +x.Display = C.GoString(xc.display) +x.Xauthority = C.GoString(xc.xauthority) + + return nil} + +func (x *SdlInfo) toC(xc *C.libxl_sdl_info) (err error){defer func(){ +if err != nil{ +C.libxl_sdl_info_dispose(xc)} +}() + +if err := x.Enable.toC(&xc.enable); err != nil { +return fmt.Errorf("converting field Enable: %v", err) +} +if err := x.Opengl.toC(&xc.opengl); err != nil { +return fmt.Errorf("converting field Opengl: %v", err) +} +if x.Display != "" { +xc.display = C.CString(x.Display)} +if x.Xauthority != "" { +xc.xauthority = C.CString(x.Xauthority)} + + return nil + } // NewDominfo returns an instance of Dominfo initialized with defaults. func NewDominfo() (*Dominfo, error) { - var ( - x Dominfo - xc C.libxl_dominfo - ) +var ( +x Dominfo +xc C.libxl_dominfo) - C.libxl_dominfo_init(&xc) - defer C.libxl_dominfo_dispose(&xc) +C.libxl_dominfo_init(&xc) +defer C.libxl_dominfo_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { - if err := x.Uuid.fromC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - x.Domid = Domid(xc.domid) - x.Ssidref = uint32(xc.ssidref) - x.SsidLabel = C.GoString(xc.ssid_label) - x.Running = bool(xc.running) - x.Blocked = bool(xc.blocked) - x.Paused = bool(xc.paused) - x.Shutdown = bool(xc.shutdown) - x.Dying = bool(xc.dying) - x.NeverStop = bool(xc.never_stop) - x.ShutdownReason = ShutdownReason(xc.shutdown_reason) - x.OutstandingMemkb = uint64(xc.outstanding_memkb) - x.CurrentMemkb = uint64(xc.current_memkb) - x.SharedMemkb = uint64(xc.shared_memkb) - x.PagedMemkb = uint64(xc.paged_memkb) - x.MaxMemkb = uint64(xc.max_memkb) - x.CpuTime = uint64(xc.cpu_time) - x.VcpuMaxId = uint32(xc.vcpu_max_id) - x.VcpuOnline = uint32(xc.vcpu_online) - x.Cpupool = uint32(xc.cpupool) - x.DomainType = DomainType(xc.domain_type) - - return nil -} - -func (x *Dominfo) toC(xc *C.libxl_dominfo) (err error) { - defer func() { - if err != nil { - C.libxl_dominfo_dispose(xc) - } - }() - - if err := x.Uuid.toC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - xc.domid = C.libxl_domid(x.Domid) - xc.ssidref = C.uint32_t(x.Ssidref) - if x.SsidLabel != "" { - xc.ssid_label = C.CString(x.SsidLabel) - } - xc.running = C.bool(x.Running) - xc.blocked = C.bool(x.Blocked) - xc.paused = C.bool(x.Paused) - xc.shutdown = C.bool(x.Shutdown) - xc.dying = C.bool(x.Dying) - xc.never_stop = C.bool(x.NeverStop) - xc.shutdown_reason = C.libxl_shutdown_reason(x.ShutdownReason) - xc.outstanding_memkb = C.uint64_t(x.OutstandingMemkb) - xc.current_memkb = C.uint64_t(x.CurrentMemkb) - xc.shared_memkb = C.uint64_t(x.SharedMemkb) - xc.paged_memkb = C.uint64_t(x.PagedMemkb) - xc.max_memkb = C.uint64_t(x.MaxMemkb) - xc.cpu_time = C.uint64_t(x.CpuTime) - xc.vcpu_max_id = C.uint32_t(x.VcpuMaxId) - xc.vcpu_online = C.uint32_t(x.VcpuOnline) - xc.cpupool = C.uint32_t(x.Cpupool) - xc.domain_type = C.libxl_domain_type(x.DomainType) - - return nil -} + if err := x.Uuid.fromC(&xc.uuid);err != nil { +return fmt.Errorf("converting field Uuid: %v", err) +} +x.Domid = Domid(xc.domid) +x.Ssidref = uint32(xc.ssidref) +x.SsidLabel = C.GoString(xc.ssid_label) +x.Running = bool(xc.running) +x.Blocked = bool(xc.blocked) +x.Paused = bool(xc.paused) +x.Shutdown = bool(xc.shutdown) +x.Dying = bool(xc.dying) +x.NeverStop = bool(xc.never_stop) +x.ShutdownReason = ShutdownReason(xc.shutdown_reason) +x.OutstandingMemkb = uint64(xc.outstanding_memkb) +x.CurrentMemkb = uint64(xc.current_memkb) +x.SharedMemkb = uint64(xc.shared_memkb) +x.PagedMemkb = uint64(xc.paged_memkb) +x.MaxMemkb = uint64(xc.max_memkb) +x.CpuTime = uint64(xc.cpu_time) +x.VcpuMaxId = uint32(xc.vcpu_max_id) +x.VcpuOnline = uint32(xc.vcpu_online) +x.Cpupool = uint32(xc.cpupool) +x.DomainType = DomainType(xc.domain_type) + + return nil} + +func (x *Dominfo) toC(xc *C.libxl_dominfo) (err error){defer func(){ +if err != nil{ +C.libxl_dominfo_dispose(xc)} +}() + +if err := x.Uuid.toC(&xc.uuid); err != nil { +return fmt.Errorf("converting field Uuid: %v", err) +} +xc.domid = C.libxl_domid(x.Domid) +xc.ssidref = C.uint32_t(x.Ssidref) +if x.SsidLabel != "" { +xc.ssid_label = C.CString(x.SsidLabel)} +xc.running = C.bool(x.Running) +xc.blocked = C.bool(x.Blocked) +xc.paused = C.bool(x.Paused) +xc.shutdown = C.bool(x.Shutdown) +xc.dying = C.bool(x.Dying) +xc.never_stop = C.bool(x.NeverStop) +xc.shutdown_reason = C.libxl_shutdown_reason(x.ShutdownReason) +xc.outstanding_memkb = C.uint64_t(x.OutstandingMemkb) +xc.current_memkb = C.uint64_t(x.CurrentMemkb) +xc.shared_memkb = C.uint64_t(x.SharedMemkb) +xc.paged_memkb = C.uint64_t(x.PagedMemkb) +xc.max_memkb = C.uint64_t(x.MaxMemkb) +xc.cpu_time = C.uint64_t(x.CpuTime) +xc.vcpu_max_id = C.uint32_t(x.VcpuMaxId) +xc.vcpu_online = C.uint32_t(x.VcpuOnline) +xc.cpupool = C.uint32_t(x.Cpupool) +xc.domain_type = C.libxl_domain_type(x.DomainType) + + return nil + } // NewCpupoolinfo returns an instance of Cpupoolinfo initialized with defaults. func NewCpupoolinfo() (*Cpupoolinfo, error) { - var ( - x Cpupoolinfo - xc C.libxl_cpupoolinfo - ) +var ( +x Cpupoolinfo +xc C.libxl_cpupoolinfo) - C.libxl_cpupoolinfo_init(&xc) - defer C.libxl_cpupoolinfo_dispose(&xc) +C.libxl_cpupoolinfo_init(&xc) +defer C.libxl_cpupoolinfo_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error { - x.Poolid = uint32(xc.poolid) - x.PoolName = C.GoString(xc.pool_name) - x.Sched = Scheduler(xc.sched) - x.NDom = uint32(xc.n_dom) - if err := x.Cpumap.fromC(&xc.cpumap); err != nil { - return fmt.Errorf("converting field Cpumap: %v", err) - } - - return nil + x.Poolid = uint32(xc.poolid) +x.PoolName = C.GoString(xc.pool_name) +x.Sched = Scheduler(xc.sched) +x.NDom = uint32(xc.n_dom) +if err := x.Cpumap.fromC(&xc.cpumap);err != nil { +return fmt.Errorf("converting field Cpumap: %v", err) } -func (x *Cpupoolinfo) toC(xc *C.libxl_cpupoolinfo) (err error) { - defer func() { - if err != nil { - C.libxl_cpupoolinfo_dispose(xc) - } - }() + return nil} - xc.poolid = C.uint32_t(x.Poolid) - if x.PoolName != "" { - xc.pool_name = C.CString(x.PoolName) - } - xc.sched = C.libxl_scheduler(x.Sched) - xc.n_dom = C.uint32_t(x.NDom) - if err := x.Cpumap.toC(&xc.cpumap); err != nil { - return fmt.Errorf("converting field Cpumap: %v", err) - } +func (x *Cpupoolinfo) toC(xc *C.libxl_cpupoolinfo) (err error){defer func(){ +if err != nil{ +C.libxl_cpupoolinfo_dispose(xc)} +}() - return nil +xc.poolid = C.uint32_t(x.Poolid) +if x.PoolName != "" { +xc.pool_name = C.CString(x.PoolName)} +xc.sched = C.libxl_scheduler(x.Sched) +xc.n_dom = C.uint32_t(x.NDom) +if err := x.Cpumap.toC(&xc.cpumap); err != nil { +return fmt.Errorf("converting field Cpumap: %v", err) } + return nil + } + // NewChannelinfo returns an instance of Channelinfo initialized with defaults. func NewChannelinfo(connection ChannelConnection) (*Channelinfo, error) { - var ( - x Channelinfo - xc C.libxl_channelinfo - ) +var ( +x Channelinfo +xc C.libxl_channelinfo) - C.libxl_channelinfo_init(&xc) - C.libxl_channelinfo_init_connection(&xc, C.libxl_channel_connection(connection)) - defer C.libxl_channelinfo_dispose(&xc) +C.libxl_channelinfo_init(&xc) +C.libxl_channelinfo_init_connection(&xc, C.libxl_channel_connection(connection)) +defer C.libxl_channelinfo_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error { - x.Backend = C.GoString(xc.backend) - x.BackendId = uint32(xc.backend_id) - x.Frontend = C.GoString(xc.frontend) - x.FrontendId = uint32(xc.frontend_id) - x.Devid = Devid(xc.devid) - x.State = int(xc.state) - x.Evtch = int(xc.evtch) - x.Rref = int(xc.rref) - x.Connection = ChannelConnection(xc.connection) - switch x.Connection { - case ChannelConnectionUnknown: - x.ConnectionUnion = nil - case ChannelConnectionPty: - var connectionPty ChannelinfoConnectionUnionPty - if err := connectionPty.fromC(xc); err != nil { - return fmt.Errorf("converting field connectionPty: %v", err) - } - x.ConnectionUnion = connectionPty - case ChannelConnectionSocket: - x.ConnectionUnion = nil - default: - return fmt.Errorf("invalid union key '%v'", x.Connection) - } - - return nil -} + x.Backend = C.GoString(xc.backend) +x.BackendId = uint32(xc.backend_id) +x.Frontend = C.GoString(xc.frontend) +x.FrontendId = uint32(xc.frontend_id) +x.Devid = Devid(xc.devid) +x.State = int(xc.state) +x.Evtch = int(xc.evtch) +x.Rref = int(xc.rref) +x.Connection = ChannelConnection(xc.connection) +switch x.Connection{ +case ChannelConnectionUnknown: +x.ConnectionUnion = nil +case ChannelConnectionPty: +var connectionPty ChannelinfoConnectionUnionPty +if err := connectionPty.fromC(xc);err != nil { + return fmt.Errorf("converting field connectionPty: %v", err) +} +x.ConnectionUnion = connectionPty +case ChannelConnectionSocket: +x.ConnectionUnion = nil +default: +return fmt.Errorf("invalid union key '%v'", x.Connection)} + + return nil} func (x *ChannelinfoConnectionUnionPty) fromC(xc *C.libxl_channelinfo) error { - if ChannelConnection(xc.connection) != ChannelConnectionPty { - return errors.New("expected union key ChannelConnectionPty") - } - - tmp := (*C.libxl_channelinfo_connection_union_pty)(unsafe.Pointer(&xc.u[0])) - x.Path = C.GoString(tmp.path) - return nil -} - -func (x *Channelinfo) toC(xc *C.libxl_channelinfo) (err error) { - defer func() { - if err != nil { - C.libxl_channelinfo_dispose(xc) - } - }() - - if x.Backend != "" { - xc.backend = C.CString(x.Backend) - } - xc.backend_id = C.uint32_t(x.BackendId) - if x.Frontend != "" { - xc.frontend = C.CString(x.Frontend) - } - xc.frontend_id = C.uint32_t(x.FrontendId) - xc.devid = C.libxl_devid(x.Devid) - xc.state = C.int(x.State) - xc.evtch = C.int(x.Evtch) - xc.rref = C.int(x.Rref) - xc.connection = C.libxl_channel_connection(x.Connection) - switch x.Connection { - case ChannelConnectionUnknown: - break - case ChannelConnectionPty: - tmp, ok := x.ConnectionUnion.(ChannelinfoConnectionUnionPty) - if !ok { - return errors.New("wrong type for union key connection") - } - var pty C.libxl_channelinfo_connection_union_pty - if tmp.Path != "" { - pty.path = C.CString(tmp.Path) - } - ptyBytes := C.GoBytes(unsafe.Pointer(&pty), C.sizeof_libxl_channelinfo_connection_union_pty) - copy(xc.u[:], ptyBytes) - case ChannelConnectionSocket: - break - default: - return fmt.Errorf("invalid union key '%v'", x.Connection) - } - - return nil -} +if ChannelConnection(xc.connection) != ChannelConnectionPty { +return errors.New("expected union key ChannelConnectionPty") +} + +tmp := (*C.libxl_channelinfo_connection_union_pty)(unsafe.Pointer(&xc.u[0])) +x.Path = C.GoString(tmp.path) +return nil +} + +func (x *Channelinfo) toC(xc *C.libxl_channelinfo) (err error){defer func(){ +if err != nil{ +C.libxl_channelinfo_dispose(xc)} +}() + +if x.Backend != "" { +xc.backend = C.CString(x.Backend)} +xc.backend_id = C.uint32_t(x.BackendId) +if x.Frontend != "" { +xc.frontend = C.CString(x.Frontend)} +xc.frontend_id = C.uint32_t(x.FrontendId) +xc.devid = C.libxl_devid(x.Devid) +xc.state = C.int(x.State) +xc.evtch = C.int(x.Evtch) +xc.rref = C.int(x.Rref) +xc.connection = C.libxl_channel_connection(x.Connection) +switch x.Connection{ +case ChannelConnectionUnknown: +break +case ChannelConnectionPty: +tmp, ok := x.ConnectionUnion.(ChannelinfoConnectionUnionPty) +if !ok { +return errors.New("wrong type for union key connection") +} +var pty C.libxl_channelinfo_connection_union_pty +if tmp.Path != "" { +pty.path = C.CString(tmp.Path)} +ptyBytes := C.GoBytes(unsafe.Pointer(&pty),C.sizeof_libxl_channelinfo_connection_union_pty) +copy(xc.u[:],ptyBytes) +case ChannelConnectionSocket: +break +default: +return fmt.Errorf("invalid union key '%v'", x.Connection)} + + return nil + } // NewVminfo returns an instance of Vminfo initialized with defaults. func NewVminfo() (*Vminfo, error) { - var ( - x Vminfo - xc C.libxl_vminfo - ) +var ( +x Vminfo +xc C.libxl_vminfo) - C.libxl_vminfo_init(&xc) - defer C.libxl_vminfo_dispose(&xc) +C.libxl_vminfo_init(&xc) +defer C.libxl_vminfo_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { - if err := x.Uuid.fromC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - x.Domid = Domid(xc.domid) - - return nil + if err := x.Uuid.fromC(&xc.uuid);err != nil { +return fmt.Errorf("converting field Uuid: %v", err) } +x.Domid = Domid(xc.domid) -func (x *Vminfo) toC(xc *C.libxl_vminfo) (err error) { - defer func() { - if err != nil { - C.libxl_vminfo_dispose(xc) - } - }() + return nil} - if err := x.Uuid.toC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - xc.domid = C.libxl_domid(x.Domid) +func (x *Vminfo) toC(xc *C.libxl_vminfo) (err error){defer func(){ +if err != nil{ +C.libxl_vminfo_dispose(xc)} +}() - return nil +if err := x.Uuid.toC(&xc.uuid); err != nil { +return fmt.Errorf("converting field Uuid: %v", err) } +xc.domid = C.libxl_domid(x.Domid) + + return nil + } // NewVersionInfo returns an instance of VersionInfo initialized with defaults. func NewVersionInfo() (*VersionInfo, error) { - var ( - x VersionInfo - xc C.libxl_version_info - ) +var ( +x VersionInfo +xc C.libxl_version_info) - C.libxl_version_info_init(&xc) - defer C.libxl_version_info_dispose(&xc) +C.libxl_version_info_init(&xc) +defer C.libxl_version_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *VersionInfo) fromC(xc *C.libxl_version_info) error { - x.XenVersionMajor = int(xc.xen_version_major) - x.XenVersionMinor = int(xc.xen_version_minor) - x.XenVersionExtra = C.GoString(xc.xen_version_extra) - x.Compiler = C.GoString(xc.compiler) - x.CompileBy = C.GoString(xc.compile_by) - x.CompileDomain = C.GoString(xc.compile_domain) - x.CompileDate = C.GoString(xc.compile_date) - x.Capabilities = C.GoString(xc.capabilities) - x.Changeset = C.GoString(xc.changeset) - x.VirtStart = uint64(xc.virt_start) - x.Pagesize = int(xc.pagesize) - x.Commandline = C.GoString(xc.commandline) - x.BuildId = C.GoString(xc.build_id) - - return nil -} - -func (x *VersionInfo) toC(xc *C.libxl_version_info) (err error) { - defer func() { - if err != nil { - C.libxl_version_info_dispose(xc) - } - }() - - xc.xen_version_major = C.int(x.XenVersionMajor) - xc.xen_version_minor = C.int(x.XenVersionMinor) - if x.XenVersionExtra != "" { - xc.xen_version_extra = C.CString(x.XenVersionExtra) - } - if x.Compiler != "" { - xc.compiler = C.CString(x.Compiler) - } - if x.CompileBy != "" { - xc.compile_by = C.CString(x.CompileBy) - } - if x.CompileDomain != "" { - xc.compile_domain = C.CString(x.CompileDomain) - } - if x.CompileDate != "" { - xc.compile_date = C.CString(x.CompileDate) - } - if x.Capabilities != "" { - xc.capabilities = C.CString(x.Capabilities) - } - if x.Changeset != "" { - xc.changeset = C.CString(x.Changeset) - } - xc.virt_start = C.uint64_t(x.VirtStart) - xc.pagesize = C.int(x.Pagesize) - if x.Commandline != "" { - xc.commandline = C.CString(x.Commandline) - } - if x.BuildId != "" { - xc.build_id = C.CString(x.BuildId) - } - - return nil -} + x.XenVersionMajor = int(xc.xen_version_major) +x.XenVersionMinor = int(xc.xen_version_minor) +x.XenVersionExtra = C.GoString(xc.xen_version_extra) +x.Compiler = C.GoString(xc.compiler) +x.CompileBy = C.GoString(xc.compile_by) +x.CompileDomain = C.GoString(xc.compile_domain) +x.CompileDate = C.GoString(xc.compile_date) +x.Capabilities = C.GoString(xc.capabilities) +x.Changeset = C.GoString(xc.changeset) +x.VirtStart = uint64(xc.virt_start) +x.Pagesize = int(xc.pagesize) +x.Commandline = C.GoString(xc.commandline) +x.BuildId = C.GoString(xc.build_id) + + return nil} + +func (x *VersionInfo) toC(xc *C.libxl_version_info) (err error){defer func(){ +if err != nil{ +C.libxl_version_info_dispose(xc)} +}() + +xc.xen_version_major = C.int(x.XenVersionMajor) +xc.xen_version_minor = C.int(x.XenVersionMinor) +if x.XenVersionExtra != "" { +xc.xen_version_extra = C.CString(x.XenVersionExtra)} +if x.Compiler != "" { +xc.compiler = C.CString(x.Compiler)} +if x.CompileBy != "" { +xc.compile_by = C.CString(x.CompileBy)} +if x.CompileDomain != "" { +xc.compile_domain = C.CString(x.CompileDomain)} +if x.CompileDate != "" { +xc.compile_date = C.CString(x.CompileDate)} +if x.Capabilities != "" { +xc.capabilities = C.CString(x.Capabilities)} +if x.Changeset != "" { +xc.changeset = C.CString(x.Changeset)} +xc.virt_start = C.uint64_t(x.VirtStart) +xc.pagesize = C.int(x.Pagesize) +if x.Commandline != "" { +xc.commandline = C.CString(x.Commandline)} +if x.BuildId != "" { +xc.build_id = C.CString(x.BuildId)} + + return nil + } // NewDomainCreateInfo returns an instance of DomainCreateInfo initialized with defaults. func NewDomainCreateInfo() (*DomainCreateInfo, error) { - var ( - x DomainCreateInfo - xc C.libxl_domain_create_info - ) +var ( +x DomainCreateInfo +xc C.libxl_domain_create_info) - C.libxl_domain_create_info_init(&xc) - defer C.libxl_domain_create_info_dispose(&xc) +C.libxl_domain_create_info_init(&xc) +defer C.libxl_domain_create_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} 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 fmt.Errorf("converting field Hap: %v", err) - } - if err := x.Oos.fromC(&xc.oos); err != nil { - 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) - x.Domid = Domid(xc.domid) - if err := x.Uuid.fromC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - if err := x.Xsdata.fromC(&xc.xsdata); err != nil { - return fmt.Errorf("converting field Xsdata: %v", err) - } - if err := x.Platformdata.fromC(&xc.platformdata); err != nil { - 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 fmt.Errorf("converting field RunHotplugScripts: %v", err) - } - if err := x.DriverDomain.fromC(&xc.driver_domain); err != nil { - return fmt.Errorf("converting field DriverDomain: %v", err) - } - x.Passthrough = Passthrough(xc.passthrough) - if err := x.XendSuspendEvtchnCompat.fromC(&xc.xend_suspend_evtchn_compat); err != nil { - return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) - } - - return nil -} - -func (x *DomainCreateInfo) toC(xc *C.libxl_domain_create_info) (err error) { - defer func() { - if err != nil { - C.libxl_domain_create_info_dispose(xc) - } - }() - - xc._type = C.libxl_domain_type(x.Type) - if err := x.Hap.toC(&xc.hap); err != nil { - return fmt.Errorf("converting field Hap: %v", err) - } - if err := x.Oos.toC(&xc.oos); err != nil { - return fmt.Errorf("converting field Oos: %v", err) - } - xc.ssidref = C.uint32_t(x.Ssidref) - if x.SsidLabel != "" { - xc.ssid_label = C.CString(x.SsidLabel) - } - if x.Name != "" { - xc.name = C.CString(x.Name) - } - xc.domid = C.libxl_domid(x.Domid) - if err := x.Uuid.toC(&xc.uuid); err != nil { - return fmt.Errorf("converting field Uuid: %v", err) - } - if err := x.Xsdata.toC(&xc.xsdata); err != nil { - return fmt.Errorf("converting field Xsdata: %v", err) - } - if err := x.Platformdata.toC(&xc.platformdata); err != nil { - return fmt.Errorf("converting field Platformdata: %v", err) - } - xc.poolid = C.uint32_t(x.Poolid) - if x.PoolName != "" { - xc.pool_name = C.CString(x.PoolName) - } - if err := x.RunHotplugScripts.toC(&xc.run_hotplug_scripts); err != nil { - return fmt.Errorf("converting field RunHotplugScripts: %v", err) - } - if err := x.DriverDomain.toC(&xc.driver_domain); err != nil { - return fmt.Errorf("converting field DriverDomain: %v", err) - } - xc.passthrough = C.libxl_passthrough(x.Passthrough) - if err := x.XendSuspendEvtchnCompat.toC(&xc.xend_suspend_evtchn_compat); err != nil { - return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) - } - - return nil + x.Type = DomainType(xc._type) +if err := x.Hap.fromC(&xc.hap);err != nil { +return fmt.Errorf("converting field Hap: %v", err) +} +if err := x.Oos.fromC(&xc.oos);err != nil { +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) +x.Domid = Domid(xc.domid) +if err := x.Uuid.fromC(&xc.uuid);err != nil { +return fmt.Errorf("converting field Uuid: %v", err) } +if err := x.Xsdata.fromC(&xc.xsdata);err != nil { +return fmt.Errorf("converting field Xsdata: %v", err) +} +if err := x.Platformdata.fromC(&xc.platformdata);err != nil { +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 fmt.Errorf("converting field RunHotplugScripts: %v", err) +} +if err := x.DriverDomain.fromC(&xc.driver_domain);err != nil { +return fmt.Errorf("converting field DriverDomain: %v", err) +} +x.Passthrough = Passthrough(xc.passthrough) +if err := x.XendSuspendEvtchnCompat.fromC(&xc.xend_suspend_evtchn_compat);err != nil { +return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) +} + + return nil} + +func (x *DomainCreateInfo) toC(xc *C.libxl_domain_create_info) (err error){defer func(){ +if err != nil{ +C.libxl_domain_create_info_dispose(xc)} +}() + +xc._type = C.libxl_domain_type(x.Type) +if err := x.Hap.toC(&xc.hap); err != nil { +return fmt.Errorf("converting field Hap: %v", err) +} +if err := x.Oos.toC(&xc.oos); err != nil { +return fmt.Errorf("converting field Oos: %v", err) +} +xc.ssidref = C.uint32_t(x.Ssidref) +if x.SsidLabel != "" { +xc.ssid_label = C.CString(x.SsidLabel)} +if x.Name != "" { +xc.name = C.CString(x.Name)} +xc.domid = C.libxl_domid(x.Domid) +if err := x.Uuid.toC(&xc.uuid); err != nil { +return fmt.Errorf("converting field Uuid: %v", err) +} +if err := x.Xsdata.toC(&xc.xsdata); err != nil { +return fmt.Errorf("converting field Xsdata: %v", err) +} +if err := x.Platformdata.toC(&xc.platformdata); err != nil { +return fmt.Errorf("converting field Platformdata: %v", err) +} +xc.poolid = C.uint32_t(x.Poolid) +if x.PoolName != "" { +xc.pool_name = C.CString(x.PoolName)} +if err := x.RunHotplugScripts.toC(&xc.run_hotplug_scripts); err != nil { +return fmt.Errorf("converting field RunHotplugScripts: %v", err) +} +if err := x.DriverDomain.toC(&xc.driver_domain); err != nil { +return fmt.Errorf("converting field DriverDomain: %v", err) +} +xc.passthrough = C.libxl_passthrough(x.Passthrough) +if err := x.XendSuspendEvtchnCompat.toC(&xc.xend_suspend_evtchn_compat); err != nil { +return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) +} + + return nil + } // NewDomainRestoreParams returns an instance of DomainRestoreParams initialized with defaults. func NewDomainRestoreParams() (*DomainRestoreParams, error) { - var ( - x DomainRestoreParams - xc C.libxl_domain_restore_params - ) +var ( +x DomainRestoreParams +xc C.libxl_domain_restore_params) - C.libxl_domain_restore_params_init(&xc) - defer C.libxl_domain_restore_params_dispose(&xc) +C.libxl_domain_restore_params_init(&xc) +defer C.libxl_domain_restore_params_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) error { - x.CheckpointedStream = int(xc.checkpointed_stream) - 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 fmt.Errorf("converting field UserspaceColoProxy: %v", err) - } - - return nil + x.CheckpointedStream = int(xc.checkpointed_stream) +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 fmt.Errorf("converting field UserspaceColoProxy: %v", err) } -func (x *DomainRestoreParams) toC(xc *C.libxl_domain_restore_params) (err error) { - defer func() { - if err != nil { - C.libxl_domain_restore_params_dispose(xc) - } - }() + return nil} - xc.checkpointed_stream = C.int(x.CheckpointedStream) - xc.stream_version = C.uint32_t(x.StreamVersion) - if x.ColoProxyScript != "" { - xc.colo_proxy_script = C.CString(x.ColoProxyScript) - } - if err := x.UserspaceColoProxy.toC(&xc.userspace_colo_proxy); err != nil { - return fmt.Errorf("converting field UserspaceColoProxy: %v", err) - } +func (x *DomainRestoreParams) toC(xc *C.libxl_domain_restore_params) (err error){defer func(){ +if err != nil{ +C.libxl_domain_restore_params_dispose(xc)} +}() - return nil +xc.checkpointed_stream = C.int(x.CheckpointedStream) +xc.stream_version = C.uint32_t(x.StreamVersion) +if x.ColoProxyScript != "" { +xc.colo_proxy_script = C.CString(x.ColoProxyScript)} +if err := x.UserspaceColoProxy.toC(&xc.userspace_colo_proxy); err != nil { +return fmt.Errorf("converting field UserspaceColoProxy: %v", err) } + return nil + } + // NewSchedParams returns an instance of SchedParams initialized with defaults. func NewSchedParams() (*SchedParams, error) { - var ( - x SchedParams - xc C.libxl_sched_params - ) +var ( +x SchedParams +xc C.libxl_sched_params) - C.libxl_sched_params_init(&xc) - defer C.libxl_sched_params_dispose(&xc) +C.libxl_sched_params_init(&xc) +defer C.libxl_sched_params_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { - x.Vcpuid = int(xc.vcpuid) - x.Weight = int(xc.weight) - x.Cap = int(xc.cap) - x.Period = int(xc.period) - x.Extratime = int(xc.extratime) - x.Budget = int(xc.budget) + x.Vcpuid = int(xc.vcpuid) +x.Weight = int(xc.weight) +x.Cap = int(xc.cap) +x.Period = int(xc.period) +x.Extratime = int(xc.extratime) +x.Budget = int(xc.budget) + + return nil} + +func (x *SchedParams) toC(xc *C.libxl_sched_params) (err error){defer func(){ +if err != nil{ +C.libxl_sched_params_dispose(xc)} +}() + +xc.vcpuid = C.int(x.Vcpuid) +xc.weight = C.int(x.Weight) +xc.cap = C.int(x.Cap) +xc.period = C.int(x.Period) +xc.extratime = C.int(x.Extratime) +xc.budget = C.int(x.Budget) + + return nil + } - return nil -} +// NewVcpuSchedParams returns an instance of VcpuSchedParams initialized with defaults. +func NewVcpuSchedParams() (*VcpuSchedParams, error) { +var ( +x VcpuSchedParams +xc C.libxl_vcpu_sched_params) -func (x *SchedParams) toC(xc *C.libxl_sched_params) (err error) { - defer func() { - if err != nil { - C.libxl_sched_params_dispose(xc) - } - }() +C.libxl_vcpu_sched_params_init(&xc) +defer C.libxl_vcpu_sched_params_dispose(&xc) - xc.vcpuid = C.int(x.Vcpuid) - xc.weight = C.int(x.Weight) - xc.cap = C.int(x.Cap) - xc.period = C.int(x.Period) - xc.extratime = C.int(x.Extratime) - xc.budget = C.int(x.Budget) +if err := x.fromC(&xc); err != nil { +return nil, err } - return nil -} +return &x, nil} -// NewVcpuSchedParams returns an instance of VcpuSchedParams initialized with defaults. -func NewVcpuSchedParams() (*VcpuSchedParams, error) { - var ( - x VcpuSchedParams - xc C.libxl_vcpu_sched_params - ) +func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { + x.Sched = Scheduler(xc.sched) +x.Vcpus = nil +if n := int(xc.num_vcpus); n > 0 { +cVcpus := (*[1<<28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:n:n] +x.Vcpus = make([]SchedParams, n) +for i, v := range cVcpus { +if err := x.Vcpus[i].fromC(&v); err != nil { +return fmt.Errorf("converting field Vcpus: %v", err) } +} +} - C.libxl_vcpu_sched_params_init(&xc) - defer C.libxl_vcpu_sched_params_dispose(&xc) + return nil} - if err := x.fromC(&xc); err != nil { - return nil, err - } +func (x *VcpuSchedParams) toC(xc *C.libxl_vcpu_sched_params) (err error){defer func(){ +if err != nil{ +C.libxl_vcpu_sched_params_dispose(xc)} +}() - return &x, nil +xc.sched = C.libxl_scheduler(x.Sched) +if numVcpus := len(x.Vcpus); numVcpus > 0 { +xc.vcpus = (*C.libxl_sched_params)(C.malloc(C.ulong(numVcpus)*C.sizeof_libxl_sched_params)) +xc.num_vcpus = C.int(numVcpus) +cVcpus := (*[1<<28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:numVcpus:numVcpus] +for i,v := range x.Vcpus { +if err := v.toC(&cVcpus[i]); err != nil { +return fmt.Errorf("converting field Vcpus: %v", err) +} } - -func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { - x.Sched = Scheduler(xc.sched) - x.Vcpus = nil - if n := int(xc.num_vcpus); n > 0 { - cVcpus := (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:n:n] - x.Vcpus = make([]SchedParams, n) - for i, v := range cVcpus { - if err := x.Vcpus[i].fromC(&v); err != nil { - return fmt.Errorf("converting field Vcpus: %v", err) - } - } - } - - return nil -} - -func (x *VcpuSchedParams) toC(xc *C.libxl_vcpu_sched_params) (err error) { - defer func() { - if err != nil { - C.libxl_vcpu_sched_params_dispose(xc) - } - }() - - xc.sched = C.libxl_scheduler(x.Sched) - if numVcpus := len(x.Vcpus); numVcpus > 0 { - xc.vcpus = (*C.libxl_sched_params)(C.malloc(C.ulong(numVcpus) * C.sizeof_libxl_sched_params)) - xc.num_vcpus = C.int(numVcpus) - cVcpus := (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:numVcpus:numVcpus] - for i, v := range x.Vcpus { - if err := v.toC(&cVcpus[i]); err != nil { - return fmt.Errorf("converting field Vcpus: %v", err) - } - } - } - - return nil } + return nil + } + // NewDomainSchedParams returns an instance of DomainSchedParams initialized with defaults. func NewDomainSchedParams() (*DomainSchedParams, error) { - var ( - x DomainSchedParams - xc C.libxl_domain_sched_params - ) +var ( +x DomainSchedParams +xc C.libxl_domain_sched_params) - C.libxl_domain_sched_params_init(&xc) - defer C.libxl_domain_sched_params_dispose(&xc) +C.libxl_domain_sched_params_init(&xc) +defer C.libxl_domain_sched_params_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { - x.Sched = Scheduler(xc.sched) - x.Weight = int(xc.weight) - x.Cap = int(xc.cap) - x.Period = int(xc.period) - x.Budget = int(xc.budget) - x.Extratime = int(xc.extratime) - x.Slice = int(xc.slice) - x.Latency = int(xc.latency) + x.Sched = Scheduler(xc.sched) +x.Weight = int(xc.weight) +x.Cap = int(xc.cap) +x.Period = int(xc.period) +x.Budget = int(xc.budget) +x.Extratime = int(xc.extratime) +x.Slice = int(xc.slice) +x.Latency = int(xc.latency) + + return nil} + +func (x *DomainSchedParams) toC(xc *C.libxl_domain_sched_params) (err error){defer func(){ +if err != nil{ +C.libxl_domain_sched_params_dispose(xc)} +}() + +xc.sched = C.libxl_scheduler(x.Sched) +xc.weight = C.int(x.Weight) +xc.cap = C.int(x.Cap) +xc.period = C.int(x.Period) +xc.budget = C.int(x.Budget) +xc.extratime = C.int(x.Extratime) +xc.slice = C.int(x.Slice) +xc.latency = C.int(x.Latency) + + return nil + } - return nil -} +// NewVnodeInfo returns an instance of VnodeInfo initialized with defaults. +func NewVnodeInfo() (*VnodeInfo, error) { +var ( +x VnodeInfo +xc C.libxl_vnode_info) -func (x *DomainSchedParams) toC(xc *C.libxl_domain_sched_params) (err error) { - defer func() { - if err != nil { - C.libxl_domain_sched_params_dispose(xc) - } - }() +C.libxl_vnode_info_init(&xc) +defer C.libxl_vnode_info_dispose(&xc) - xc.sched = C.libxl_scheduler(x.Sched) - xc.weight = C.int(x.Weight) - xc.cap = C.int(x.Cap) - xc.period = C.int(x.Period) - xc.budget = C.int(x.Budget) - xc.extratime = C.int(x.Extratime) - xc.slice = C.int(x.Slice) - xc.latency = C.int(x.Latency) +if err := x.fromC(&xc); err != nil { +return nil, err } - return nil -} +return &x, nil} -// NewVnodeInfo returns an instance of VnodeInfo initialized with defaults. -func NewVnodeInfo() (*VnodeInfo, error) { - var ( - x VnodeInfo - xc C.libxl_vnode_info - ) +func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { + x.Memkb = uint64(xc.memkb) +x.Distances = nil +if n := int(xc.num_distances); n > 0 { +cDistances := (*[1<<28]C.uint32_t)(unsafe.Pointer(xc.distances))[:n:n] +x.Distances = make([]uint32, n) +for i, v := range cDistances { +x.Distances[i] = uint32(v) +} +} +x.Pnode = uint32(xc.pnode) +if err := x.Vcpus.fromC(&xc.vcpus);err != nil { +return fmt.Errorf("converting field Vcpus: %v", err) +} - C.libxl_vnode_info_init(&xc) - defer C.libxl_vnode_info_dispose(&xc) + return nil} - if err := x.fromC(&xc); err != nil { - return nil, err - } +func (x *VnodeInfo) toC(xc *C.libxl_vnode_info) (err error){defer func(){ +if err != nil{ +C.libxl_vnode_info_dispose(xc)} +}() - return &x, nil +xc.memkb = C.uint64_t(x.Memkb) +if numDistances := len(x.Distances); numDistances > 0 { +xc.distances = (*C.uint32_t)(C.malloc(C.size_t(numDistances*numDistances))) +xc.num_distances = C.int(numDistances) +cDistances := (*[1<<28]C.uint32_t)(unsafe.Pointer(xc.distances))[:numDistances:numDistances] +for i,v := range x.Distances { +cDistances[i] = C.uint32_t(v) } - -func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { - x.Memkb = uint64(xc.memkb) - x.Distances = nil - if n := int(xc.num_distances); n > 0 { - cDistances := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:n:n] - x.Distances = make([]uint32, n) - for i, v := range cDistances { - x.Distances[i] = uint32(v) - } - } - x.Pnode = uint32(xc.pnode) - if err := x.Vcpus.fromC(&xc.vcpus); err != nil { - return fmt.Errorf("converting field Vcpus: %v", err) - } - - return nil -} - -func (x *VnodeInfo) toC(xc *C.libxl_vnode_info) (err error) { - defer func() { - if err != nil { - C.libxl_vnode_info_dispose(xc) - } - }() - - xc.memkb = C.uint64_t(x.Memkb) - if numDistances := len(x.Distances); numDistances > 0 { - xc.distances = (*C.uint32_t)(C.malloc(C.size_t(numDistances * numDistances))) - xc.num_distances = C.int(numDistances) - cDistances := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:numDistances:numDistances] - for i, v := range x.Distances { - cDistances[i] = C.uint32_t(v) - } - } - xc.pnode = C.uint32_t(x.Pnode) - if err := x.Vcpus.toC(&xc.vcpus); err != nil { - return fmt.Errorf("converting field Vcpus: %v", err) - } - - return nil } +xc.pnode = C.uint32_t(x.Pnode) +if err := x.Vcpus.toC(&xc.vcpus); err != nil { +return fmt.Errorf("converting field Vcpus: %v", err) +} + + return nil + } // NewRdmReserve returns an instance of RdmReserve initialized with defaults. func NewRdmReserve() (*RdmReserve, error) { - var ( - x RdmReserve - xc C.libxl_rdm_reserve - ) +var ( +x RdmReserve +xc C.libxl_rdm_reserve) - C.libxl_rdm_reserve_init(&xc) - defer C.libxl_rdm_reserve_dispose(&xc) +C.libxl_rdm_reserve_init(&xc) +defer C.libxl_rdm_reserve_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error { - x.Strategy = RdmReserveStrategy(xc.strategy) - x.Policy = RdmReservePolicy(xc.policy) + x.Strategy = RdmReserveStrategy(xc.strategy) +x.Policy = RdmReservePolicy(xc.policy) - return nil -} + return nil} -func (x *RdmReserve) toC(xc *C.libxl_rdm_reserve) (err error) { - defer func() { - if err != nil { - C.libxl_rdm_reserve_dispose(xc) - } - }() +func (x *RdmReserve) toC(xc *C.libxl_rdm_reserve) (err error){defer func(){ +if err != nil{ +C.libxl_rdm_reserve_dispose(xc)} +}() - xc.strategy = C.libxl_rdm_reserve_strategy(x.Strategy) - xc.policy = C.libxl_rdm_reserve_policy(x.Policy) +xc.strategy = C.libxl_rdm_reserve_strategy(x.Strategy) +xc.policy = C.libxl_rdm_reserve_policy(x.Policy) - return nil -} + return nil + } // NewDomainBuildInfo returns an instance of DomainBuildInfo initialized with defaults. func NewDomainBuildInfo(dtype DomainType) (*DomainBuildInfo, error) { - var ( - x DomainBuildInfo - xc C.libxl_domain_build_info - ) +var ( +x DomainBuildInfo +xc C.libxl_domain_build_info) - C.libxl_domain_build_info_init(&xc) - C.libxl_domain_build_info_init_type(&xc, C.libxl_domain_type(dtype)) - defer C.libxl_domain_build_info_dispose(&xc) +C.libxl_domain_build_info_init(&xc) +C.libxl_domain_build_info_init_type(&xc, C.libxl_domain_type(dtype)) +defer C.libxl_domain_build_info_dispose(&xc) - if err := x.fromC(&xc); err != nil { - return nil, err - } +if err := x.fromC(&xc); err != nil { +return nil, err } - return &x, nil -} +return &x, nil} 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 fmt.Errorf("converting field AvailVcpus: %v", err) - } - if err := x.Cpumap.fromC(&xc.cpumap); err != nil { - return fmt.Errorf("converting field Cpumap: %v", err) - } - if err := x.Nodemap.fromC(&xc.nodemap); err != nil { - return fmt.Errorf("converting field Nodemap: %v", err) - } - x.VcpuHardAffinity = nil - if n := int(xc.num_vcpu_hard_affinity); n > 0 { - cVcpuHardAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:n:n] - x.VcpuHardAffinity = make([]Bitmap, n) - for i, v := range cVcpuHardAffinity { - if err := x.VcpuHardAffinity[i].fromC(&v); err != nil { - return fmt.Errorf("converting field VcpuHardAffinity: %v", err) - } - } - } - x.VcpuSoftAffinity = nil - if n := int(xc.num_vcpu_soft_affinity); n > 0 { - cVcpuSoftAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:n:n] - x.VcpuSoftAffinity = make([]Bitmap, n) - for i, v := range cVcpuSoftAffinity { - if err := x.VcpuSoftAffinity[i].fromC(&v); err != nil { - return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) - } - } - } - if err := x.NumaPlacement.fromC(&xc.numa_placement); err != nil { - return fmt.Errorf("converting field NumaPlacement: %v", err) - } - x.TscMode = TscMode(xc.tsc_mode) - x.MaxMemkb = uint64(xc.max_memkb) - x.TargetMemkb = uint64(xc.target_memkb) - x.VideoMemkb = uint64(xc.video_memkb) - x.ShadowMemkb = uint64(xc.shadow_memkb) - x.IommuMemkb = uint64(xc.iommu_memkb) - x.RtcTimeoffset = uint32(xc.rtc_timeoffset) - x.ExecSsidref = uint32(xc.exec_ssidref) - x.ExecSsidLabel = C.GoString(xc.exec_ssid_label) - if err := x.Localtime.fromC(&xc.localtime); err != nil { - return fmt.Errorf("converting field Localtime: %v", err) - } - if err := x.DisableMigrate.fromC(&xc.disable_migrate); err != nil { - return fmt.Errorf("converting field DisableMigrate: %v", err) - } - if err := x.Cpuid.fromC(&xc.cpuid); err != nil { - return fmt.Errorf("converting field Cpuid: %v", err) - } - x.BlkdevStart = C.GoString(xc.blkdev_start) - x.VnumaNodes = nil - if n := int(xc.num_vnuma_nodes); n > 0 { - cVnumaNodes := (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_nodes))[:n:n] - x.VnumaNodes = make([]VnodeInfo, n) - for i, v := range cVnumaNodes { - if err := x.VnumaNodes[i].fromC(&v); err != nil { - return fmt.Errorf("converting field VnumaNodes: %v", err) - } - } - } - x.MaxGrantFrames = uint32(xc.max_grant_frames) - 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 fmt.Errorf("converting field DeviceModelStubdomain: %v", err) - } - x.StubdomainMemkb = uint64(xc.stubdomain_memkb) - x.StubdomainKernel = C.GoString(xc.stubdomain_kernel) - x.StubdomainRamdisk = C.GoString(xc.stubdomain_ramdisk) - 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 fmt.Errorf("converting field Extra: %v", err) - } - if err := x.ExtraPv.fromC(&xc.extra_pv); err != nil { - return fmt.Errorf("converting field ExtraPv: %v", err) - } - if err := x.ExtraHvm.fromC(&xc.extra_hvm); err != nil { - return fmt.Errorf("converting field ExtraHvm: %v", err) - } - if err := x.SchedParams.fromC(&xc.sched_params); err != nil { - return fmt.Errorf("converting field SchedParams: %v", err) - } - x.Ioports = nil - if n := int(xc.num_ioports); n > 0 { - cIoports := (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports))[:n:n] - x.Ioports = make([]IoportRange, n) - for i, v := range cIoports { - if err := x.Ioports[i].fromC(&v); err != nil { - return fmt.Errorf("converting field Ioports: %v", err) - } - } - } - x.Irqs = nil - if n := int(xc.num_irqs); n > 0 { - cIrqs := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:n:n] - x.Irqs = make([]uint32, n) - for i, v := range cIrqs { - x.Irqs[i] = uint32(v) - } - } - x.Iomem = nil - if n := int(xc.num_iomem); n > 0 { - cIomem := (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:n:n] - x.Iomem = make([]IomemRange, n) - for i, v := range cIomem { - if err := x.Iomem[i].fromC(&v); err != nil { - return fmt.Errorf("converting field Iomem: %v", err) - } - } - } - if err := x.ClaimMode.fromC(&xc.claim_mode); err != nil { - return fmt.Errorf("converting field ClaimMode: %v", err) - } - x.EventChannels = uint32(xc.event_channels) - x.Kernel = C.GoString(xc.kernel) - x.Cmdline = C.GoString(xc.cmdline) - x.Ramdisk = C.GoString(xc.ramdisk) - x.DeviceTree = C.GoString(xc.device_tree) - if err := x.Acpi.fromC(&xc.acpi); err != nil { - 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 fmt.Errorf("converting field BootloaderArgs: %v", err) - } - x.TimerMode = TimerMode(xc.timer_mode) - if err := x.NestedHvm.fromC(&xc.nested_hvm); err != nil { - return fmt.Errorf("converting field NestedHvm: %v", err) - } - if err := x.Apic.fromC(&xc.apic); err != nil { - return fmt.Errorf("converting field Apic: %v", err) - } - if err := x.DmRestrict.fromC(&xc.dm_restrict); err != nil { - return fmt.Errorf("converting field DmRestrict: %v", err) - } - x.Tee = TeeType(xc.tee) - x.Type = DomainType(xc._type) - switch x.Type { - case DomainTypeHvm: - var typeHvm DomainBuildInfoTypeUnionHvm - if err := typeHvm.fromC(xc); err != nil { - return fmt.Errorf("converting field typeHvm: %v", err) - } - x.TypeUnion = typeHvm - case DomainTypePv: - var typePv DomainBuildInfoTypeUnionPv - if err := typePv.fromC(xc); err != nil { - return fmt.Errorf("converting field typePv: %v", err) - } - x.TypeUnion = typePv - case DomainTypePvh: - var typePvh DomainBuildInfoTypeUnionPvh - if err := typePvh.fromC(xc); err != nil { - return fmt.Errorf("converting field typePvh: %v", err) - } - x.TypeUnion = typePvh - case DomainTypeInvalid: - x.TypeUnion = nil - default: - return fmt.Errorf("invalid union key '%v'", x.Type) - } - x.ArchArm.GicVersion = GicVersion(xc.arch_arm.gic_version) - x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart) - x.Altp2M = Altp2MMode(xc.altp2m) - - return nil -} + x.MaxVcpus = int(xc.max_vcpus) +if err := x.AvailVcpus.fromC(&xc.avail_vcpus);err != nil { +return fmt.Errorf("converting field AvailVcpus: %v", err) +} +if err := x.Cpumap.fromC(&xc.cpumap);err != nil { +return fmt.Errorf("converting field Cpumap: %v", err) +} +if err := x.Nodemap.fromC(&xc.nodemap);err != nil { +return fmt.Errorf("converting field Nodemap: %v", err) +} +x.VcpuHardAffinity = nil +if n := int(xc.num_vcpu_hard_affinity); n > 0 { +cVcpuHardAffinity := (*[1<<28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:n:n] +x.VcpuHardAffinity = make([]Bitmap, n) +for i, v := range cVcpuHardAffinity { +if err := x.VcpuHardAffinity[i].fromC(&v); err != nil { +return fmt.Errorf("converting field VcpuHardAffinity: %v", err) } +} +} +x.VcpuSoftAffinity = nil +if n := int(xc.num_vcpu_soft_affinity); n > 0 { +cVcpuSoftAffinity := (*[1<<28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:n:n] +x.VcpuSoftAffinity = make([]Bitmap, n) +for i, v := range cVcpuSoftAffinity { +if err := x.VcpuSoftAffinity[i].fromC(&v); err != nil { +return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) } +} +} +if err := x.NumaPlacement.fromC(&xc.numa_placement);err != nil { +return fmt.Errorf("converting field NumaPlacement: %v", err) +} +x.TscMode = TscMode(xc.tsc_mode) +x.MaxMemkb = uint64(xc.max_memkb) +x.TargetMemkb = uint64(xc.target_memkb) +x.VideoMemkb = uint64(xc.video_memkb) +x.ShadowMemkb = uint64(xc.shadow_memkb) +x.IommuMemkb = uint64(xc.iommu_memkb) +x.RtcTimeoffset = uint32(xc.rtc_timeoffset) +x.ExecSsidref = uint32(xc.exec_ssidref) +x.ExecSsidLabel = C.GoString(xc.exec_ssid_label) +if err := x.Localtime.fromC(&xc.localtime);err != nil { +return fmt.Errorf("converting field Localtime: %v", err) +} +if err := x.DisableMigrate.fromC(&xc.disable_migrate);err != nil { +return fmt.Errorf("converting field DisableMigrate: %v", err) +} +if err := x.Cpuid.fromC(&xc.cpuid);err != nil { +return fmt.Errorf("converting field Cpuid: %v", err) +} +x.BlkdevStart = C.GoString(xc.blkdev_start) +x.VnumaNodes = nil +if n := int(xc.num_vnuma_nodes); n > 0 { +cVnumaNodes := (*[1<<28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_nodes))[:n:n] +x.VnumaNodes = make([]VnodeInfo, n) +for i, v := range cVnumaNodes { +if err := x.VnumaNodes[i].fromC(&v); err != nil { +return fmt.Errorf("converting field VnumaNodes: %v", err) } +} +} +x.MaxGrantFrames = uint32(xc.max_grant_frames) +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 fmt.Errorf("converting field DeviceModelStubdomain: %v", err) +} +x.StubdomainMemkb = uint64(xc.stubdomain_memkb) +x.StubdomainKernel = C.GoString(xc.stubdomain_kernel) +x.StubdomainRamdisk = C.GoString(xc.stubdomain_ramdisk) +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 fmt.Errorf("converting field Extra: %v", err) +} +if err := x.ExtraPv.fromC(&xc.extra_pv);err != nil { +return fmt.Errorf("converting field ExtraPv: %v", err) +} +if err := x.ExtraHvm.fromC(&xc.extra_hvm);err != nil { +return fmt.Errorf("converting field ExtraHvm: %v", err) +} +if err := x.SchedParams.fromC(&xc.sched_params);err != nil { +return fmt.Errorf("converting field SchedParams: %v", err) +} +x.Ioports = nil +if n := int(xc.num_ioports); n > 0 { +cIoports := (*[1<<28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports))[:n:n] +x.Ioports = make([]IoportRange, n) +for i, v := range cIoports { +if err := x.Ioports[i].fromC(&v); err != nil { +return fmt.Errorf("converting field Ioports: %v", err) } +} +} +x.Irqs = nil +if n := int(xc.num_irqs); n > 0 { +cIrqs := (*[1<<28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:n:n] +x.Irqs = make([]uint32, n) +for i, v := range cIrqs { +x.Irqs[i] = uint32(v) +} +} +x.Iomem = nil +if n := int(xc.num_iomem); n > 0 { +cIomem := (*[1<<28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:n:n] +x.Iomem = make([]IomemRange, n) +for i, v := range cIomem { +if err := x.Iomem[i].fromC(&v); err != nil { +return fmt.Errorf("converting field Iomem: %v", err) } +} +} +if err := x.ClaimMode.fromC(&xc.claim_mode);err != nil { +return fmt.Errorf("converting field ClaimMode: %v", err) +} +x.EventChannels = uint32(xc.event_channels) +x.Kernel = C.GoString(xc.kernel) +x.Cmdline = C.GoString(xc.cmdline) +x.Ramdisk = C.GoString(xc.ramdisk) +x.DeviceTree = C.GoString(xc.device_tree) +if err := x.Acpi.fromC(&xc.acpi);err != nil { +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 fmt.Errorf("converting field BootloaderArgs: %v", err) +} +x.TimerMode = TimerMode(xc.timer_mode) +if err := x.NestedHvm.fromC(&xc.nested_hvm);err != nil { +return fmt.Errorf("converting field NestedHvm: %v", err) +} +if err := x.Apic.fromC(&xc.apic);err != nil { +return fmt.Errorf("converting field Apic: %v", err) +} +if err := x.DmRestrict.fromC(&xc.dm_restrict);err != nil { +return fmt.Errorf("converting field DmRestrict: %v", err) +} +x.Tee = TeeType(xc.tee) +x.Type = DomainType(xc._type) +switch x.Type{ +case DomainTypeHvm: +var typeHvm DomainBuildInfoTypeUnionHvm +if err := typeHvm.fromC(xc);err != nil { + return fmt.Errorf("converting field typeHvm: %v", err) +} +x.TypeUnion = typeHvm +case DomainTypePv: +var typePv DomainBuildInfoTypeUnionPv +if err := typePv.fromC(xc);err != nil { + return fmt.Errorf("converting field typePv: %v", err) +} +x.TypeUnion = typePv +case DomainTypePvh: +var typePvh DomainBuildInfoTypeUnionPvh +if err := typePvh.fromC(xc);err != nil { + return fmt.Errorf("converting field typePvh: %v", err) +} +x.TypeUnion = typePvh +case DomainTypeInvalid: +x.TypeUnion = nil +default: +return fmt.Errorf("invalid union key '%v'", x.Type)} +x.ArchArm.GicVersion = GicVersion(xc.arch_arm.gic_version) +x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart) +x.Altp2M = Altp2MMode(xc.altp2m) + + return nil} func (x *DomainBuildInfoTypeUnionHvm) fromC(xc *C.libxl_domain_build_info) error { - if DomainType(xc._type) != DomainTypeHvm { - return errors.New("expected union key DomainTypeHvm") - } - - tmp := (*C.libxl_domain_build_info_type_union_hvm)(unsafe.Pointer(&xc.u[0])) - x.Firmware = C.GoString(tmp.firmware) - x.Bios = BiosType(tmp.bios) - if err := x.Pae.fromC(&tmp.pae); err != nil { - return fmt.Errorf("converting field Pae: %v", err) - } - if err := x.Apic.fromC(&tmp.apic); err != nil { - return fmt.Errorf("converting field Apic: %v", err) - } - if err := x.Acpi.fromC(&tmp.acpi); err != nil { - return fmt.Errorf("converting field Acpi: %v", err) - } - if err := x.AcpiS3.fromC(&tmp.acpi_s3); err != nil { - return fmt.Errorf("converting field AcpiS3: %v", err) - } - if err := x.AcpiS4.fromC(&tmp.acpi_s4); err != nil { - return fmt.Errorf("converting field AcpiS4: %v", err) - } - if err := x.AcpiLaptopSlate.fromC(&tmp.acpi_laptop_slate); err != nil { - return fmt.Errorf("converting field AcpiLaptopSlate: %v", err) - } - if err := x.Nx.fromC(&tmp.nx); err != nil { - return fmt.Errorf("converting field Nx: %v", err) - } - if err := x.Viridian.fromC(&tmp.viridian); err != nil { - return fmt.Errorf("converting field Viridian: %v", err) - } - if err := x.ViridianEnable.fromC(&tmp.viridian_enable); err != nil { - return fmt.Errorf("converting field ViridianEnable: %v", err) - } - if err := x.ViridianDisable.fromC(&tmp.viridian_disable); err != nil { - return fmt.Errorf("converting field ViridianDisable: %v", err) - } - x.Timeoffset = C.GoString(tmp.timeoffset) - if err := x.Hpet.fromC(&tmp.hpet); err != nil { - return fmt.Errorf("converting field Hpet: %v", err) - } - if err := x.VptAlign.fromC(&tmp.vpt_align); err != nil { - 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 fmt.Errorf("converting field NestedHvm: %v", err) - } - if err := x.Altp2M.fromC(&tmp.altp2m); err != nil { - 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 fmt.Errorf("converting field Nographic: %v", err) - } - if err := x.Vga.fromC(&tmp.vga); err != nil { - return fmt.Errorf("converting field Vga: %v", err) - } - if err := x.Vnc.fromC(&tmp.vnc); err != nil { - return fmt.Errorf("converting field Vnc: %v", err) - } - x.Keymap = C.GoString(tmp.keymap) - if err := x.Sdl.fromC(&tmp.sdl); err != nil { - return fmt.Errorf("converting field Sdl: %v", err) - } - if err := x.Spice.fromC(&tmp.spice); err != nil { - return fmt.Errorf("converting field Spice: %v", err) - } - if err := x.GfxPassthru.fromC(&tmp.gfx_passthru); err != nil { - 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 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 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 fmt.Errorf("converting field XenPlatformPci: %v", err) - } - if err := x.UsbdeviceList.fromC(&tmp.usbdevice_list); err != nil { - 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 fmt.Errorf("converting field MsVmGenid: %v", err) - } - if err := x.SerialList.fromC(&tmp.serial_list); err != nil { - return fmt.Errorf("converting field SerialList: %v", err) - } - if err := x.Rdm.fromC(&tmp.rdm); err != nil { - return fmt.Errorf("converting field Rdm: %v", err) - } - x.RdmMemBoundaryMemkb = uint64(tmp.rdm_mem_boundary_memkb) - x.McaCaps = uint64(tmp.mca_caps) - return nil +if DomainType(xc._type) != DomainTypeHvm { +return errors.New("expected union key DomainTypeHvm") +} + +tmp := (*C.libxl_domain_build_info_type_union_hvm)(unsafe.Pointer(&xc.u[0])) +x.Firmware = C.GoString(tmp.firmware) +x.Bios = BiosType(tmp.bios) +if err := x.Pae.fromC(&tmp.pae);err != nil { +return fmt.Errorf("converting field Pae: %v", err) +} +if err := x.Apic.fromC(&tmp.apic);err != nil { +return fmt.Errorf("converting field Apic: %v", err) +} +if err := x.Acpi.fromC(&tmp.acpi);err != nil { +return fmt.Errorf("converting field Acpi: %v", err) +} +if err := x.AcpiS3.fromC(&tmp.acpi_s3);err != nil { +return fmt.Errorf("converting field AcpiS3: %v", err) +} +if err := x.AcpiS4.fromC(&tmp.acpi_s4);err != nil { +return fmt.Errorf("converting field AcpiS4: %v", err) +} +if err := x.AcpiLaptopSlate.fromC(&tmp.acpi_laptop_slate);err != nil { +return fmt.Errorf("converting field AcpiLaptopSlate: %v", err) +} +if err := x.Nx.fromC(&tmp.nx);err != nil { +return fmt.Errorf("converting field Nx: %v", err) +} +if err := x.Viridian.fromC(&tmp.viridian);err != nil { +return fmt.Errorf("converting field Viridian: %v", err) +} +if err := x.ViridianEnable.fromC(&tmp.viridian_enable);err != nil { +return fmt.Errorf("converting field ViridianEnable: %v", err) +} +if err := x.ViridianDisable.fromC(&tmp.viridian_disable);err != nil { +return fmt.Errorf("converting field ViridianDisable: %v", err) +} +x.Timeoffset = C.GoString(tmp.timeoffset) +if err := x.Hpet.fromC(&tmp.hpet);err != nil { +return fmt.Errorf("converting field Hpet: %v", err) +} +if err := x.VptAlign.fromC(&tmp.vpt_align);err != nil { +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 fmt.Errorf("converting field NestedHvm: %v", err) +} +if err := x.Altp2M.fromC(&tmp.altp2m);err != nil { +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 fmt.Errorf("converting field Nographic: %v", err) +} +if err := x.Vga.fromC(&tmp.vga);err != nil { +return fmt.Errorf("converting field Vga: %v", err) +} +if err := x.Vnc.fromC(&tmp.vnc);err != nil { +return fmt.Errorf("converting field Vnc: %v", err) +} +x.Keymap = C.GoString(tmp.keymap) +if err := x.Sdl.fromC(&tmp.sdl);err != nil { +return fmt.Errorf("converting field Sdl: %v", err) +} +if err := x.Spice.fromC(&tmp.spice);err != nil { +return fmt.Errorf("converting field Spice: %v", err) +} +if err := x.GfxPassthru.fromC(&tmp.gfx_passthru);err != nil { +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 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 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 fmt.Errorf("converting field XenPlatformPci: %v", err) +} +if err := x.UsbdeviceList.fromC(&tmp.usbdevice_list);err != nil { +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 fmt.Errorf("converting field MsVmGenid: %v", err) +} +if err := x.SerialList.fromC(&tmp.serial_list);err != nil { +return fmt.Errorf("converting field SerialList: %v", err) +} +if err := x.Rdm.fromC(&tmp.rdm);err != nil { +return fmt.Errorf("converting field Rdm: %v", err) +} +x.RdmMemBoundaryMemkb = uint64(tmp.rdm_mem_boundary_memkb) +x.McaCaps = uint64(tmp.mca_caps) +return nil } func (x *DomainBuildInfoTypeUnionPv) fromC(xc *C.libxl_domain_build_info) error { - if DomainType(xc._type) != DomainTypePv { - return errors.New("expected union key DomainTypePv") - } - - tmp := (*C.libxl_domain_build_info_type_union_pv)(unsafe.Pointer(&xc.u[0])) - x.Kernel = C.GoString(tmp.kernel) - x.SlackMemkb = uint64(tmp.slack_memkb) - x.Bootloader = C.GoString(tmp.bootloader) - if err := x.BootloaderArgs.fromC(&tmp.bootloader_args); err != nil { - 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 fmt.Errorf("converting field E820Host: %v", err) - } - return nil +if DomainType(xc._type) != DomainTypePv { +return errors.New("expected union key DomainTypePv") +} + +tmp := (*C.libxl_domain_build_info_type_union_pv)(unsafe.Pointer(&xc.u[0])) +x.Kernel = C.GoString(tmp.kernel) +x.SlackMemkb = uint64(tmp.slack_memkb) +x.Bootloader = C.GoString(tmp.bootloader) +if err := x.BootloaderArgs.fromC(&tmp.bootloader_args);err != nil { +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 fmt.Errorf("converting field E820Host: %v", err) +} +return nil } func (x *DomainBuildInfoTypeUnionPvh) fromC(xc *C.libxl_domain_build_info) error { - if DomainType(xc._type) != DomainTypePvh { - return errors.New("expected union key DomainTypePvh") - } - - tmp := (*C.libxl_domain_build_info_type_union_pvh)(unsafe.Pointer(&xc.u[0])) - if err := x.Pvshim.fromC(&tmp.pvshim); err != nil { - return fmt.Errorf("converting field Pvshim: %v", err) - } - x.PvshimPath = C.GoString(tmp.pvshim_path) - x.PvshimCmdline = C.GoString(tmp.pvshim_cmdline) - x.PvshimExtra = C.GoString(tmp.pvshim_extra) - return nil -} - -func (x *DomainBuildInfo) toC(xc *C.libxl_domain_build_info) (err error) { - defer func() { - if err != nil { - C.libxl_domain_build_info_dispose(xc) - } - }() - - xc.max_vcpus = C.int(x.MaxVcpus) - if err := x.AvailVcpus.toC(&xc.avail_vcpus); err != nil { - return fmt.Errorf("converting field AvailVcpus: %v", err) - } - if err := x.Cpumap.toC(&xc.cpumap); err != nil { - return fmt.Errorf("converting field Cpumap: %v", err) - } - if err := x.Nodemap.toC(&xc.nodemap); err != nil { - return 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)) - xc.num_vcpu_hard_affinity = C.int(numVcpuHardAffinity) - cVcpuHardAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity] - for i, v := range x.VcpuHardAffinity { - if err := v.toC(&cVcpuHardAffinity[i]); err != nil { - return fmt.Errorf("converting field VcpuHardAffinity: %v", err) - } - } - } - if numVcpuSoftAffinity := len(x.VcpuSoftAffinity); numVcpuSoftAffinity > 0 { - xc.vcpu_soft_affinity = (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuSoftAffinity) * C.sizeof_libxl_bitmap)) - xc.num_vcpu_soft_affinity = C.int(numVcpuSoftAffinity) - cVcpuSoftAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity] - for i, v := range x.VcpuSoftAffinity { - if err := v.toC(&cVcpuSoftAffinity[i]); err != nil { - return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) - } - } - } - if err := x.NumaPlacement.toC(&xc.numa_placement); err != nil { - return fmt.Errorf("converting field NumaPlacement: %v", err) - } - xc.tsc_mode = C.libxl_tsc_mode(x.TscMode) - xc.max_memkb = C.uint64_t(x.MaxMemkb) - xc.target_memkb = C.uint64_t(x.TargetMemkb) - xc.video_memkb = C.uint64_t(x.VideoMemkb) - xc.shadow_memkb = C.uint64_t(x.ShadowMemkb) - xc.iommu_memkb = C.uint64_t(x.IommuMemkb) - xc.rtc_timeoffset = C.uint32_t(x.RtcTimeoffset) - xc.exec_ssidref = C.uint32_t(x.ExecSsidref) - if x.ExecSsidLabel != "" { - xc.exec_ssid_label = C.CString(x.ExecSsidLabel) - } - if err := x.Localtime.toC(&xc.localtime); err != nil { - return fmt.Errorf("converting field Localtime: %v", err) - } - if err := x.DisableMigrate.toC(&xc.disable_migrate); err != nil { - return fmt.Errorf("converting field DisableMigrate: %v", err) - } - if err := x.Cpuid.toC(&xc.cpuid); err != nil { - return fmt.Errorf("converting field Cpuid: %v", err) - } - if x.BlkdevStart != "" { - xc.blkdev_start = C.CString(x.BlkdevStart) - } - if numVnumaNodes := len(x.VnumaNodes); numVnumaNodes > 0 { - xc.vnuma_nodes = (*C.libxl_vnode_info)(C.malloc(C.ulong(numVnumaNodes) * C.sizeof_libxl_vnode_info)) - xc.num_vnuma_nodes = C.int(numVnumaNodes) - cVnumaNodes := (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_nodes))[:numVnumaNodes:numVnumaNodes] - for i, v := range x.VnumaNodes { - if err := v.toC(&cVnumaNodes[i]); err != nil { - return fmt.Errorf("converting field VnumaNodes: %v", err) - } - } - } - xc.max_grant_frames = C.uint32_t(x.MaxGrantFrames) - xc.max_maptrack_frames = C.uint32_t(x.MaxMaptrackFrames) - xc.device_model_version = C.libxl_device_model_version(x.DeviceModelVersion) - if err := x.DeviceModelStubdomain.toC(&xc.device_model_stubdomain); err != nil { - return fmt.Errorf("converting field DeviceModelStubdomain: %v", err) - } - xc.stubdomain_memkb = C.uint64_t(x.StubdomainMemkb) - if x.StubdomainKernel != "" { - xc.stubdomain_kernel = C.CString(x.StubdomainKernel) - } - if x.StubdomainRamdisk != "" { - xc.stubdomain_ramdisk = C.CString(x.StubdomainRamdisk) - } - if x.DeviceModel != "" { - xc.device_model = C.CString(x.DeviceModel) - } - xc.device_model_ssidref = C.uint32_t(x.DeviceModelSsidref) - if x.DeviceModelSsidLabel != "" { - xc.device_model_ssid_label = C.CString(x.DeviceModelSsidLabel) - } - if x.DeviceModelUser != "" { - xc.device_model_user = C.CString(x.DeviceModelUser) - } - if err := x.Extra.toC(&xc.extra); err != nil { - return fmt.Errorf("converting field Extra: %v", err) - } - if err := x.ExtraPv.toC(&xc.extra_pv); err != nil { - return fmt.Errorf("converting field ExtraPv: %v", err) - } - if err := x.ExtraHvm.toC(&xc.extra_hvm); err != nil { - return fmt.Errorf("converting field ExtraHvm: %v", err) - } - if err := x.SchedParams.toC(&xc.sched_params); err != nil { - return 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)) - xc.num_ioports = C.int(numIoports) - cIoports := (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports))[:numIoports:numIoports] - for i, v := range x.Ioports { - if err := v.toC(&cIoports[i]); err != nil { - return fmt.Errorf("converting field Ioports: %v", err) - } - } - } - if numIrqs := len(x.Irqs); numIrqs > 0 { - xc.irqs = (*C.uint32_t)(C.malloc(C.size_t(numIrqs * numIrqs))) - xc.num_irqs = C.int(numIrqs) - cIrqs := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:numIrqs:numIrqs] - for i, v := range x.Irqs { - cIrqs[i] = C.uint32_t(v) - } - } - if numIomem := len(x.Iomem); numIomem > 0 { - xc.iomem = (*C.libxl_iomem_range)(C.malloc(C.ulong(numIomem) * C.sizeof_libxl_iomem_range)) - xc.num_iomem = C.int(numIomem) - cIomem := (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:numIomem:numIomem] - for i, v := range x.Iomem { - if err := v.toC(&cIomem[i]); err != nil { - return fmt.Errorf("converting field Iomem: %v", err) - } - } - } - if err := x.ClaimMode.toC(&xc.claim_mode); err != nil { - return fmt.Errorf("converting field ClaimMode: %v", err) - } - xc.event_channels = C.uint32_t(x.EventChannels) - if x.Kernel != "" { - xc.kernel = C.CString(x.Kernel) - } - if x.Cmdline != "" { - xc.cmdline = C.CString(x.Cmdline) - } - if x.Ramdisk != "" { - xc.ramdisk = C.CString(x.Ramdisk) - } - if x.DeviceTree != "" { - xc.device_tree = C.CString(x.DeviceTree) - } - if err := x.Acpi.toC(&xc.acpi); err != nil { - return fmt.Errorf("converting field Acpi: %v", err) - } - if x.Bootloader != "" { - xc.bootloader = C.CString(x.Bootloader) - } - if err := x.BootloaderArgs.toC(&xc.bootloader_args); err != nil { - return fmt.Errorf("converting field BootloaderArgs: %v", err) - } - xc.timer_mode = C.libxl_timer_mode(x.TimerMode) - if err := x.NestedHvm.toC(&xc.nested_hvm); err != nil { - return fmt.Errorf("converting field NestedHvm: %v", err) - } - if err := x.Apic.toC(&xc.apic); err != nil { - return fmt.Errorf("converting field Apic: %v", err) - } - if err := x.DmRestrict.toC(&xc.dm_restrict); err != nil { - return fmt.Errorf("converting field DmRestrict: %v", err) - } - xc.tee = C.libxl_tee_type(x.Tee) - xc._type = C.libxl_domain_type(x.Type) - switch x.Type { - case DomainTypeHvm: - tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionHvm) - if !ok { - return errors.New("wrong type for union key type") - } - var hvm C.libxl_domain_build_info_type_union_hvm - if tmp.Firmware != "" { - hvm.firmware = C.CString(tmp.Firmware) - } - hvm.bios = C.libxl_bios_type(tmp.Bios) - if err := tmp.Pae.toC(&hvm.pae); err != nil { - return fmt.Errorf("converting field Pae: %v", err) - } - if err := tmp.Apic.toC(&hvm.apic); err != nil { - return fmt.Errorf("converting field Apic: %v", err) - } - if err := tmp.Acpi.toC(&hvm.acpi); err != nil { - return fmt.Errorf("converting field Acpi: %v", err) - } - if err := tmp.AcpiS3.toC(&hvm.acpi_s3); err != nil { - return fmt.Errorf("converting field AcpiS3: %v", err) - } - if err := tmp.AcpiS4.toC(&hvm.acpi_s4); err != nil { - return fmt.Errorf("converting field AcpiS4: %v", err) - } - if err := tmp.AcpiLaptopSlate.toC(&hvm.acpi_laptop_slate); err != nil { - return fmt.Errorf("converting field AcpiLaptopSlate: %v", err) - } - if err := tmp.Nx.toC(&hvm.nx); err != nil { - return fmt.Errorf("converting field Nx: %v", err) - } - if err := tmp.Viridian.toC(&hvm.viridian); err != nil { - return fmt.Errorf("converting field Viridian: %v", err) - } - if err := tmp.ViridianEnable.toC(&hvm.viridian_enable); err != nil { - return fmt.Errorf("converting field ViridianEnable: %v", err) - } - if err := tmp.ViridianDisable.toC(&hvm.viridian_disable); err != nil { - return fmt.Errorf("converting field ViridianDisable: %v", err) - } - if tmp.Timeoffset != "" { - hvm.timeoffset = C.CString(tmp.Timeoffset) - } - if err := tmp.Hpet.toC(&hvm.hpet); err != nil { - return fmt.Errorf("converting field Hpet: %v", err) - } - if err := tmp.VptAlign.toC(&hvm.vpt_align); err != nil { - return 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) - if err := tmp.NestedHvm.toC(&hvm.nested_hvm); err != nil { - return fmt.Errorf("converting field NestedHvm: %v", err) - } - if err := tmp.Altp2M.toC(&hvm.altp2m); err != nil { - return fmt.Errorf("converting field Altp2M: %v", err) - } - if tmp.SystemFirmware != "" { - hvm.system_firmware = C.CString(tmp.SystemFirmware) - } - if tmp.SmbiosFirmware != "" { - hvm.smbios_firmware = C.CString(tmp.SmbiosFirmware) - } - if tmp.AcpiFirmware != "" { - hvm.acpi_firmware = C.CString(tmp.AcpiFirmware) - } - hvm.hdtype = C.libxl_hdtype(tmp.Hdtype) - if err := tmp.Nographic.toC(&hvm.nographic); err != nil { - return fmt.Errorf("converting field Nographic: %v", err) - } - if err := tmp.Vga.toC(&hvm.vga); err != nil { - return fmt.Errorf("converting field Vga: %v", err) - } - if err := tmp.Vnc.toC(&hvm.vnc); err != nil { - return fmt.Errorf("converting field Vnc: %v", err) - } - if tmp.Keymap != "" { - hvm.keymap = C.CString(tmp.Keymap) - } - if err := tmp.Sdl.toC(&hvm.sdl); err != nil { - return fmt.Errorf("converting field Sdl: %v", err) - } - if err := tmp.Spice.toC(&hvm.spice); err != nil { - return fmt.Errorf("converting field Spice: %v", err) - } - if err := tmp.GfxPassthru.toC(&hvm.gfx_passthru); err != nil { - return fmt.Errorf("converting field GfxPassthru: %v", err) - } - hvm.gfx_passthru_kind = C.libxl_gfx_passthru_kind(tmp.GfxPassthruKind) - if tmp.Serial != "" { - hvm.serial = C.CString(tmp.Serial) - } - if tmp.Boot != "" { - hvm.boot = C.CString(tmp.Boot) - } - if err := tmp.Usb.toC(&hvm.usb); err != nil { - return fmt.Errorf("converting field Usb: %v", err) - } - hvm.usbversion = C.int(tmp.Usbversion) - if tmp.Usbdevice != "" { - hvm.usbdevice = C.CString(tmp.Usbdevice) - } - if err := tmp.VkbDevice.toC(&hvm.vkb_device); err != nil { - return fmt.Errorf("converting field VkbDevice: %v", err) - } - if tmp.Soundhw != "" { - hvm.soundhw = C.CString(tmp.Soundhw) - } - if err := tmp.XenPlatformPci.toC(&hvm.xen_platform_pci); err != nil { - return fmt.Errorf("converting field XenPlatformPci: %v", err) - } - if err := tmp.UsbdeviceList.toC(&hvm.usbdevice_list); err != nil { - return fmt.Errorf("converting field UsbdeviceList: %v", err) - } - hvm.vendor_device = C.libxl_vendor_device(tmp.VendorDevice) - if err := tmp.MsVmGenid.toC(&hvm.ms_vm_genid); err != nil { - return fmt.Errorf("converting field MsVmGenid: %v", err) - } - if err := tmp.SerialList.toC(&hvm.serial_list); err != nil { - return fmt.Errorf("converting field SerialList: %v", err) - } - if err := tmp.Rdm.toC(&hvm.rdm); err != nil { - return 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) - hvmBytes := C.GoBytes(unsafe.Pointer(&hvm), C.sizeof_libxl_domain_build_info_type_union_hvm) - copy(xc.u[:], hvmBytes) - case DomainTypePv: - tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionPv) - if !ok { - return errors.New("wrong type for union key type") - } - var pv C.libxl_domain_build_info_type_union_pv - if tmp.Kernel != "" { - pv.kernel = C.CString(tmp.Kernel) - } - pv.slack_memkb = C.uint64_t(tmp.SlackMemkb) - if tmp.Bootloader != "" { - pv.bootloader = C.CString(tmp.Bootloader) - } - if err := tmp.BootloaderArgs.toC(&pv.bootloader_args); err != nil { - return fmt.Errorf("converting field BootloaderArgs: %v", err) - } - if tmp.Cmdline != "" { - pv.cmdline = C.CString(tmp.Cmdline) - } - if tmp.Ramdisk != "" { - pv.ramdisk = C.CString(tmp.Ramdisk) - } - if tmp.Features != "" { - pv.features = C.CString(tmp.Features) - } - if err := tmp.E820Host.toC(&pv.e820_host); err != nil { - return 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) - case DomainTypePvh: - tmp, ok := x.TypeUnion.(DomainBuildInfoTypeUnionPvh) - if !ok { - return errors.New("wrong type for union key type") - } - var pvh C.libxl_domain_build_info_type_union_pvh - if err := tmp.Pvshim.toC(&pvh.pvshim); err != nil { - return fmt.Errorf("converting field Pvshim: %v", err) - } - if tmp.PvshimPath != "" { - pvh.pvshim_path = C.CString(tmp.PvshimPath) - } - if tmp.PvshimCmdline != "" { - pvh.pvshim_cmdline = C.CString(tmp.PvshimCmdline) - } - if tmp.PvshimExtra != "" { - pvh.pvshim_extra = C.CString(tmp.PvshimExtra) - } - pvhBytes := C.GoBytes(unsafe.Pointer(&pvh), C.sizeof_libxl_domain_build_info_type_union_pvh) - copy(xc.u[:], pvhBytes) - case DomainTypeInvalid: - break - default: - return fmt.Errorf("invalid union key '%v'", x.Type) - } - xc.arch_arm.gic_version = C.libxl_gic_version(x.ArchArm.GicVersion) - xc.arch_arm.vuart = C.libxl_vuart_type(x.ArchArm.Vuart) - xc.altp2m = C.libxl_altp2m_mode(x.Altp2M) - - return nil +if DomainType(xc._type) != DomainTypePvh { +return errors.New("expected union key DomainTypePvh") +} + +tmp := (*C.libxl_domain_build_info_type_union_pvh)(unsafe.Pointer(&xc.u[0])) +if err := x.Pvshim.fromC(&tmp.pvshim);err != nil { +return fmt.Errorf("converting field Pvshim: %v", err) +} +x.PvshimPath = C.GoString(tmp.pvshim_path) +x.PvshimCmdline = C.GoString(tmp.pvshim_cmdline) +x.PvshimExtra = C.GoString(tmp.pvshim_extra) +return nil +} + +func (x *DomainBuildInfo) toC(xc *C.libxl_domain_build_info) (err error){defer func(){ +if err != nil{ +C.libxl_domain_build_info_dispose(xc)} +}() + +xc.max_vcpus = C.int(x.MaxVcpus) +if err := x.AvailVcpus.toC(&xc.avail_vcpus); err != nil { +return fmt.Errorf("converting field AvailVcpus: %v", err) +} +if err := x.Cpumap.toC(&xc.cpumap); err != nil { +return fmt.Errorf("converting field Cpumap: %v", err) +} +if err := x.Nodemap.toC(&xc.nodemap); err != nil { +return 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)) +xc.num_vcpu_hard_affinity = C.int(numVcpuHardAffinity) +cVcpuHardAffinity := (*[1<<28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity] +for i,v := range x.VcpuHardAffinity { +if err := v.toC(&cVcpuHardAffinity[i]); err != nil { +return fmt.Errorf("converting field VcpuHardAffinity: %v", err) +} +} +} +if numVcpuSoftAffinity := len(x.VcpuSoftAffinity); numVcpuSoftAffinity > 0 { +xc.vcpu_soft_affinity = (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuSoftAffinity)*C.sizeof_libxl_bitmap)) +xc.num_vcpu_soft_affinity = C.int(numVcpuSoftAffinity) +cVcpuSoftAffinity := (*[1<<28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity] +for i,v := range x.VcpuSoftAffinity { +if err := v.toC(&cVcpuSoftAffinity[i]); err != nil { +return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) } +} +} +if err := x.NumaPlacement.toC(&xc.numa_placement); err != nil { +return fmt.Errorf("converting field NumaPlacement: %v", err) +} +xc.tsc_mode = C.libxl_tsc_mode(x.TscMode)
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |