[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 07/10] golang/xenlight: Implement Domain operations
From: Ronald Rojas <ronladred@xxxxxxxxx> Add calls for the following Domain related functionality - libxl_domain_pause - libxl_domain_shutdown - libxl_domain_reboot - libxl_list_domain Signed-off-by: Ronald Rojas <ronladred@xxxxxxxxx> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- CC: Ian Jackson <ian.jackson@xxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> tools/golang/xenlight/xenlight.go | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 86253c5..f16185e 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -713,3 +713,73 @@ func (Ctx *Context) DomainUnpause(Id Domid) (err error) { } return } + +//int libxl_domain_pause(libxl_ctx *ctx, uint32_t domain); +func (Ctx *Context) DomainPause(id Domid) (err error) { + err = Ctx.CheckOpen() + if err != nil { + return + } + + ret := C.libxl_domain_pause(Ctx.ctx, C.uint32_t(id)) + + if ret != 0 { + err = Error(-ret) + } + return +} + +//int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid); +func (Ctx *Context) DomainShutdown(id Domid) (err error) { + err = Ctx.CheckOpen() + if err != nil { + return + } + + ret := C.libxl_domain_shutdown(Ctx.ctx, C.uint32_t(id)) + + if ret != 0 { + err = Error(-ret) + } + return +} + +//int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid); +func (Ctx *Context) DomainReboot(id Domid) (err error) { + err = Ctx.CheckOpen() + if err != nil { + return + } + + ret := C.libxl_domain_reboot(Ctx.ctx, C.uint32_t(id)) + + if ret != 0 { + err = Error(-ret) + } + return +} + +//libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out); +//void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain); +func (Ctx *Context) ListDomain() (glist []Dominfo) { + err := Ctx.CheckOpen() + if err != nil { + return + } + + var nbDomain C.int + clist := C.libxl_list_domain(Ctx.ctx, &nbDomain) + defer C.libxl_dominfo_list_free(clist, nbDomain) + + if int(nbDomain) == 0 { + return + } + + gslice := (*[1 << 30]C.libxl_dominfo)(unsafe.Pointer(clist))[:nbDomain:nbDomain] + for i := range gslice { + info := gslice[i].toGo() + glist = append(glist, *info) + } + + return +} -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |