[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] golang/xenlight: Implement Vcpuinfo and ListVcpu



commit 58b9512b297da86f36fdde3682dba841917b7c1b
Author:     Ronald Rojas <ronladred@xxxxxxxxx>
AuthorDate: Wed Apr 5 17:05:52 2017 +0100
Commit:     George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Thu Apr 6 15:34:32 2017 +0100

    golang/xenlight: Implement Vcpuinfo and ListVcpu
    
    Include Golang version of libxl_vcpu_info
    as VcpuInfo
    
    Add a Golang call for libxl_list_vcpu as
    ListVcpu
    
    Signed-off-by: Ronald Rojas <ronladred@xxxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 52 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index f16185e..a8ade4f 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -783,3 +783,55 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) {
 
        return
 }
+
+type Vcpuinfo struct {
+       Vcpuid     uint32
+       Cpu        uint32
+       Online     bool
+       Blocked    bool
+       Running    bool
+       VCpuTime   time.Duration
+       Cpumap     Bitmap
+       CpumapSoft Bitmap
+}
+
+func (cvci C.libxl_vcpuinfo) toGo() (gvci Vcpuinfo) {
+       gvci.Vcpuid = uint32(cvci.vcpuid)
+       gvci.Cpu = uint32(cvci.cpu)
+       gvci.Online = bool(cvci.online)
+       gvci.Blocked = bool(cvci.blocked)
+       gvci.Running = bool(cvci.running)
+       gvci.VCpuTime = time.Duration(cvci.vcpu_time)
+       gvci.Cpumap = cvci.cpumap.toGo()
+       gvci.CpumapSoft = cvci.cpumap_soft.toGo()
+
+       return
+}
+
+//libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
+//                             int *nb_vcpu, int *nr_cpus_out);
+//void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
+func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) {
+       err := Ctx.CheckOpen()
+       if err != nil {
+               return
+       }
+
+       var nbVcpu C.int
+       var nrCpu C.int
+
+       clist := C.libxl_list_vcpu(Ctx.ctx, C.uint32_t(id), &nbVcpu, &nrCpu)
+       defer C.libxl_vcpuinfo_list_free(clist, nbVcpu)
+
+       if int(nbVcpu) == 0 {
+               return
+       }
+
+       gslice := (*[1 << 
30]C.libxl_vcpuinfo)(unsafe.Pointer(clist))[:nbVcpu:nbVcpu]
+       for i := range gslice {
+               info := gslice[i].toGo()
+               glist = append(glist, info)
+       }
+
+       return
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.