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.dun...@citrix.com>
---
v4:
- Remove hand-crafted constructor code, make non-RFC

CC: Nick Rosbrook <rosbro...@ainfosec.com>
---
 tools/golang/xenlight/xenlight.go | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index 56fa31fd7b..808b4a327c 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -1111,3 +1111,24 @@ func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) 
(path string, err error)
        path = C.GoString(cpath)
        return
 }
+
+// int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config,
+//                             uint32_t *domid,
+//                             const libxl_asyncop_how *ao_how,
+//                             const libxl_asyncprogress_how *aop_console_how)
+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.25.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to