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 <george.dunlap@citrix.com>
Reviewed-by: Nick Rosbrook <rosbrookn@ainfosec.com>
This commit is contained in:
George Dunlap committed 2020-04-23 16:00:15 +01:00
1 parent a73964c18e
commit aa14feb672
1 file changed
+18
+18
View File
@@ -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
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.