From aa14feb6723d3bb15a884533ade1cd9732792145 Mon Sep 17 00:00:00 2001 From: George Dunlap Date: Tue, 24 Dec 2019 12:51:56 +0000 Subject: [PATCH] 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 --- tools/golang/xenlight/xenlight.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 +} -- 2.30.2