mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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:
1 parent
a73964c18e
commit
aa14feb672
1 file changed
+18
@@ -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
|
||||
}
|
||||