From: George Dunlap Date: Tue, 24 Dec 2019 12:51:56 +0000 (+0000) Subject: golang/xenlight: Implement DomainCreateNew X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~360 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=aa14feb6723d3bb15a884533ade1cd9732792145;p=xen.git golang/xenlight: Implement DomainCreateNew This implements the wrapper around libxl_domain_create_new(). With the previous changes, it's now possible to create a domain using the golang bindings (although not yet to unpause it or harvest it after it shuts down). Signed-off-by: George Dunlap Reviewed-by: Nick Rosbrook --- diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 20f6542f6b..6b4f492550 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -1213,3 +1213,21 @@ func (Ctx *Context) DeviceUsbdevRemove(domid Domid, usbdev *DeviceUsbdev) error return nil } + +// DomainCreateNew creates a new domain. +func (Ctx *Context) DomainCreateNew(config *DomainConfig) (Domid, error) { + var cdomid C.uint32_t + var cconfig C.libxl_domain_config + err := config.toC(&cconfig) + if err != nil { + return Domid(0), fmt.Errorf("converting domain config to C: %v", err) + } + defer C.libxl_domain_config_dispose(&cconfig) + + ret := C.libxl_domain_create_new(Ctx.ctx, &cconfig, &cdomid, nil, nil) + if ret != 0 { + return Domid(0), Error(ret) + } + + return Domid(cdomid), nil +}