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

[Xen-devel] [PATCH RFC 5/8] golang/xenlight: Add tests host related functinality functions



Create tests for the following functions:
- GetVersionInfo
- GetPhysinfo
- GetDominfo
- GetMaxCpus
- GetOnlineCpus
- GetMaxNodes
- GetFreeMemory

Signed-off-by: Ronald Rojas <ronladred@xxxxxxxxx>
---
 tools/golang/xenlight/test/dominfo/Makefile        | 18 ++++++++
 tools/golang/xenlight/test/dominfo/dominfo.c       | 29 +++++++++++++
 tools/golang/xenlight/test/dominfo/dominfo.go      | 48 ++++++++++++++++++++++
 tools/golang/xenlight/test/freememory/Makefile     | 19 +++++++++
 tools/golang/xenlight/test/freememory/freememory.c | 25 +++++++++++
 .../golang/xenlight/test/freememory/freememory.go  | 35 ++++++++++++++++
 tools/golang/xenlight/test/maxcpu/Makefile         | 19 +++++++++
 tools/golang/xenlight/test/maxcpu/maxcpu.c         | 21 ++++++++++
 tools/golang/xenlight/test/maxcpu/maxcpu.go        | 34 +++++++++++++++
 tools/golang/xenlight/test/maxnodes/Makefile       | 19 +++++++++
 tools/golang/xenlight/test/maxnodes/maxnodes.c     | 21 ++++++++++
 tools/golang/xenlight/test/maxnodes/maxnodes.go    | 34 +++++++++++++++
 tools/golang/xenlight/test/onlinecpu/Makefile      | 19 +++++++++
 tools/golang/xenlight/test/onlinecpu/onlinecpu.c   | 21 ++++++++++
 tools/golang/xenlight/test/onlinecpu/onlinecpu.go  | 34 +++++++++++++++
 tools/golang/xenlight/test/physinfo/Makefile       | 19 +++++++++
 tools/golang/xenlight/test/physinfo/physinfo.c     | 31 ++++++++++++++
 tools/golang/xenlight/test/physinfo/physinfo.go    | 36 ++++++++++++++++
 tools/golang/xenlight/test/versioninfo/Makefile    | 18 ++++++++
 .../golang/xenlight/test/versioninfo/versioninfo.c | 18 ++++++++
 .../xenlight/test/versioninfo/versioninfo.go       | 33 +++++++++++++++
 21 files changed, 551 insertions(+)
 create mode 100644 tools/golang/xenlight/test/dominfo/Makefile
 create mode 100644 tools/golang/xenlight/test/dominfo/dominfo.c
 create mode 100644 tools/golang/xenlight/test/dominfo/dominfo.go
 create mode 100644 tools/golang/xenlight/test/freememory/Makefile
 create mode 100644 tools/golang/xenlight/test/freememory/freememory.c
 create mode 100644 tools/golang/xenlight/test/freememory/freememory.go
 create mode 100644 tools/golang/xenlight/test/maxcpu/Makefile
 create mode 100644 tools/golang/xenlight/test/maxcpu/maxcpu.c
 create mode 100644 tools/golang/xenlight/test/maxcpu/maxcpu.go
 create mode 100644 tools/golang/xenlight/test/maxnodes/Makefile
 create mode 100644 tools/golang/xenlight/test/maxnodes/maxnodes.c
 create mode 100644 tools/golang/xenlight/test/maxnodes/maxnodes.go
 create mode 100644 tools/golang/xenlight/test/onlinecpu/Makefile
 create mode 100644 tools/golang/xenlight/test/onlinecpu/onlinecpu.c
 create mode 100644 tools/golang/xenlight/test/onlinecpu/onlinecpu.go
 create mode 100644 tools/golang/xenlight/test/physinfo/Makefile
 create mode 100644 tools/golang/xenlight/test/physinfo/physinfo.c
 create mode 100644 tools/golang/xenlight/test/physinfo/physinfo.go
 create mode 100644 tools/golang/xenlight/test/versioninfo/Makefile
 create mode 100644 tools/golang/xenlight/test/versioninfo/versioninfo.c
 create mode 100644 tools/golang/xenlight/test/versioninfo/versioninfo.go

diff --git a/tools/golang/xenlight/test/dominfo/Makefile 
b/tools/golang/xenlight/test/dominfo/Makefile
new file mode 100644
index 0000000..a7351cf
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/Makefile
@@ -0,0 +1,18 @@
+
+test: clean build
+       ./dominfo.out >> c.output
+       go run dominfo.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetDominfo PASSED";\
+       else \
+               echo "GetDominfo FAILED";\
+       fi\
+
+build:
+       go build -o dominfo.a dominfo.go 
+       gcc dominfo.c -lxenlight -lyajl -o dominfo.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
diff --git a/tools/golang/xenlight/test/dominfo/dominfo.c 
b/tools/golang/xenlight/test/dominfo/dominfo.c
new file mode 100644
index 0000000..ebe18c3
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/dominfo.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+char * bool_to_string(bool b);
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_dominfo info;
+    int err = libxl_domain_info(context, &info, 0);
+    if(err != 0){
+        return err;
+    }
+    
+    
+       printf("%d\n%d\n", info.domid, info.ssidref);
+       printf("%s\n%s\n%s\n%s\n%s\n%s\n", bool_to_string(info.running), 
bool_to_string(info.blocked ), bool_to_string(info.paused 
),bool_to_string(info.shutdown ),bool_to_string(info.dying), 
bool_to_string(info.never_stop));
+       long cpu_time = info.cpu_time/((long)1<<35);
+       printf("%d\n%lu\n%lu\n%lu\n%lu\n%lu\n%lu\n%d\n%d\n%d\n", 
info.shutdown_reason, info.outstanding_memkb, info.current_memkb, 
info.shared_memkb, info.paged_memkb, info.max_memkb, cpu_time, 
info.vcpu_max_id, info.vcpu_online, info.cpupool);
+       printf("%d\n", info.domain_type);
+
+
+    libxl_ctx_free(context);
+
+}
+char * bool_to_string(bool b){
+    return b ? "true": "false";
+}
diff --git a/tools/golang/xenlight/test/dominfo/dominfo.go 
b/tools/golang/xenlight/test/dominfo/dominfo.go
new file mode 100644
index 0000000..e6c6a64
--- /dev/null
+++ b/tools/golang/xenlight/test/dominfo/dominfo.go
@@ -0,0 +1,48 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       info, err:= ctx.DomainInfo(0)
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       fmt.Printf("%d\n%d\n", info.Domid, info.Ssidref)
+       //fmt.Printf("%s\n", info.SsidLabel)
+       fmt.Printf("%t\n%t\n%t\n%t\n%t\n%t\n", info.Running, info.Blocked, 
info.Paused, info.Shutdown, info.Dying, info.NeverStop)
+       cpuTime := info.CpuTime/(1<<35)
+       fmt.Printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n", 
info.ShutdownReason, info.OutstandingMemkb, info.CurrentMemkb, 
info.SharedMemkb, info.PagedMemkb, info.MaxMemkb, cpuTime, info.VcpuMaxId, 
info.VcpuOnline, info.Cpupool)
+       fmt.Printf("%d\n", info.DomainType)
+
+}
+
+func replaceDomainType(n int32)(ret string){
+       switch n{
+       case -1:
+               ret = "invalid"
+       case 1:
+               ret = "hvm"
+       case 2:
+               ret = "pv"
+       }
+       return
+
+}
diff --git a/tools/golang/xenlight/test/freememory/Makefile 
b/tools/golang/xenlight/test/freememory/Makefile
new file mode 100644
index 0000000..9548e50
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+       ./func.out >> c.output
+       go run func.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetFreeMemory PASSED";\
+       else \
+               echo "GetFreeMemory FAILED"; \
+       fi\
+
+build:
+       go build -o func.a func.go
+       gcc func.c -lxenlight -lyajl -o func.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
+
diff --git a/tools/golang/xenlight/test/freememory/freememory.c 
b/tools/golang/xenlight/test/freememory/freememory.c
new file mode 100644
index 0000000..9ff8444
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/freememory.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+   uint64_t free_memory;
+    err = libxl_get_free_memory(context, &free_memory);
+    if(err < 0){
+        printf("%d\n", err);
+    }else{
+        printf("%lu\n", free_memory);
+    }
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/freememory/freememory.go 
b/tools/golang/xenlight/test/freememory/freememory.go
new file mode 100644
index 0000000..19501e7
--- /dev/null
+++ b/tools/golang/xenlight/test/freememory/freememory.go
@@ -0,0 +1,35 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+
+       free_memory, err := ctx.GetFreeMemory()
+       if err != nil{
+               fmt.Printf("%d\n", err)
+       }else{
+               fmt.Printf("%d\n", free_memory)
+       }
+
+}
diff --git a/tools/golang/xenlight/test/maxcpu/Makefile 
b/tools/golang/xenlight/test/maxcpu/Makefile
new file mode 100644
index 0000000..17aa19a
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+       ./maxcpu.out >> c.output
+       go run maxcpu.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetMaxCpu PASSED";\
+       else \
+               echo "GetMaxCpu FAILED"; \
+       fi\
+
+build:
+       go build -o maxcpu.a maxcpu.go
+       gcc maxcpu.c -lxenlight -lyajl -o maxcpu.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
+
diff --git a/tools/golang/xenlight/test/maxcpu/maxcpu.c 
b/tools/golang/xenlight/test/maxcpu/maxcpu.c
new file mode 100644
index 0000000..60ef7ce
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/maxcpu.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int max_cpus = libxl_get_max_cpus(context);
+    printf("%d\n", max_cpus);
+
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/maxcpu/maxcpu.go 
b/tools/golang/xenlight/test/maxcpu/maxcpu.go
new file mode 100644
index 0000000..eef575f
--- /dev/null
+++ b/tools/golang/xenlight/test/maxcpu/maxcpu.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       max_cpus, err := ctx.GetMaxCpus()
+       if err != nil{
+               fmt.Printf("%d\n", err )
+       }else{
+               fmt.Printf("%d\n", max_cpus)
+       }
+
+}
diff --git a/tools/golang/xenlight/test/maxnodes/Makefile 
b/tools/golang/xenlight/test/maxnodes/Makefile
new file mode 100644
index 0000000..7535efe
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+       ./maxnodes.out >> c.output
+       go run maxnodes.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetMaxNodes PASSED";\
+       else \
+               echo "GetMaxNodes FAILED"; \
+       fi\
+
+build:
+       go build -o maxnodes.a maxnodes.go
+       gcc maxnodes.c -lxenlight -lyajl -o maxnodes.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
+
diff --git a/tools/golang/xenlight/test/maxnodes/maxnodes.c 
b/tools/golang/xenlight/test/maxnodes/maxnodes.c
new file mode 100644
index 0000000..8f7ce9c
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/maxnodes.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int max_nodes = libxl_get_max_nodes(context);
+    printf("%d\n", max_nodes);
+
+   libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/maxnodes/maxnodes.go 
b/tools/golang/xenlight/test/maxnodes/maxnodes.go
new file mode 100644
index 0000000..5f619ff
--- /dev/null
+++ b/tools/golang/xenlight/test/maxnodes/maxnodes.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       max_nodes, err := ctx.GetMaxNodes()
+       if err != nil{
+               fmt.Printf("%d\n", err)
+       }else{
+               fmt.Printf("%d\n", max_nodes)
+       }
+
+}
diff --git a/tools/golang/xenlight/test/onlinecpu/Makefile 
b/tools/golang/xenlight/test/onlinecpu/Makefile
new file mode 100644
index 0000000..9df2256
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+       ./onlinecpu.out >> c.output
+       go run onlinecpu.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetOnlineCpus PASSED";\
+       else \
+               echo "GetOnline FAILED"; \
+       fi\
+
+build:
+       go build -o onlinecpu.a onlinecpu.go
+       gcc onlinecpu.c -lxenlight -lyajl -o onlinecpu.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
+
diff --git a/tools/golang/xenlight/test/onlinecpu/onlinecpu.c 
b/tools/golang/xenlight/test/onlinecpu/onlinecpu.c
new file mode 100644
index 0000000..a56ff71
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/onlinecpu.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    int online_cpus = libxl_get_online_cpus(context);
+    printf("%d\n", online_cpus);
+
+    libxl_ctx_free(context);
+
+}
+
diff --git a/tools/golang/xenlight/test/onlinecpu/onlinecpu.go 
b/tools/golang/xenlight/test/onlinecpu/onlinecpu.go
new file mode 100644
index 0000000..2c4968e
--- /dev/null
+++ b/tools/golang/xenlight/test/onlinecpu/onlinecpu.go
@@ -0,0 +1,34 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       online_cpus, err := ctx.GetOnlineCpus()
+       if err != nil{
+               fmt.Printf("%d\n", err)
+       }else{
+               fmt.Printf("%d\n", online_cpus)
+       }
+
+}
diff --git a/tools/golang/xenlight/test/physinfo/Makefile 
b/tools/golang/xenlight/test/physinfo/Makefile
new file mode 100644
index 0000000..87fd171
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/Makefile
@@ -0,0 +1,19 @@
+
+test: clean build
+       ./physinfo.out >> c.output
+       go run physinfo.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetPhysinfo PASSED";\
+       else \
+               echo "GetPhysinfo FAILED"; \
+       fi\
+
+build:
+       go build -o physinfo.a physinfo.go 
+       gcc physinfo.c -lxenlight -lyajl -o physinfo.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
+
diff --git a/tools/golang/xenlight/test/physinfo/physinfo.c 
b/tools/golang/xenlight/test/physinfo/physinfo.c
new file mode 100644
index 0000000..92c8f47
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/physinfo.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+char *bool_to_string(bool b);
+int main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_physinfo info ;
+    int err= libxl_get_physinfo(context,&info);
+    if(err != 0){
+        return err;
+    }
+
+    printf("%d\n%d\n%d\n%d\n%d\n", info.threads_per_core, 
info.cores_per_socket, info.max_cpu_id, info.nr_cpus, info.cpu_khz);
+    printf("%lu\n%lu\n%lu\n%lu\n%lu\n%lu\n", info.total_pages, 
info.free_pages, info.scrub_pages, info.outstanding_pages, 
info.sharing_freed_pages, info.sharing_used_frames);
+    printf("%u\n",info.nr_nodes);
+    printf("%s\n%s\n", bool_to_string(info.cap_hvm), 
bool_to_string(info.cap_hvm_directio));
+
+    for(int i = 0; i < 8; i++){
+        printf("%u\n", info.hw_cap[i]);
+    }
+
+    libxl_ctx_free(context);
+
+}
+
+char * bool_to_string(bool b){
+    return b ? "true": "false";
+}
diff --git a/tools/golang/xenlight/test/physinfo/physinfo.go 
b/tools/golang/xenlight/test/physinfo/physinfo.go
new file mode 100644
index 0000000..039da59
--- /dev/null
+++ b/tools/golang/xenlight/test/physinfo/physinfo.go
@@ -0,0 +1,36 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       info, err:= ctx.GetPhysinfo()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       fmt.Printf("%d\n%d\n%d\n%d\n%d\n", info.ThreadsPerCore, 
info.CoresPerSocket, info.MaxCpuId, info.NrCpus, info.CpuKhz)
+       fmt.Printf("%d\n%d\n%d\n%d\n%d\n%d\n", info.TotalPages, info.FreePages, 
info.ScrubPages, info.OutstandingPages, info.SharingFreedPages, 
info.SharingUsedFrames)
+       fmt.Printf("%d\n",info.NrNodes)
+       fmt.Printf("%t\n%t\n", info.CapHvm, info.CapHvmDirectio)
+
+       for i := 0; i < 8; i++ {
+       fmt.Printf("%d\n", info.HwCap[i]);
+       }
+}
diff --git a/tools/golang/xenlight/test/versioninfo/Makefile 
b/tools/golang/xenlight/test/versioninfo/Makefile
new file mode 100644
index 0000000..0ad1527
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/Makefile
@@ -0,0 +1,18 @@
+
+test: clean build
+       ./versioninfo.out >> c.output
+       go run versioninfo.go >> go.output
+       if cmp -s "c.output" "go.output"; then\
+               echo "GetVersionInfo PASSED";\
+       else \
+               echo "GetVersionInfo FAILED"; \
+       fi\
+
+build:
+       go build -o versioninfo.a versioninfo.go 
+       gcc versioninfo.c -lxenlight -lyajl -o versioninfo.out
+
+clean:
+       rm -f *.a
+       rm -f *.out
+       rm -f *.output
diff --git a/tools/golang/xenlight/test/versioninfo/versioninfo.c 
b/tools/golang/xenlight/test/versioninfo/versioninfo.c
new file mode 100644
index 0000000..f40495d
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/versioninfo.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <libxl.h>
+
+main(){
+
+    libxl_ctx *context;
+    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
+    libxl_version_info* info = libxl_get_version_info(context);
+
+    printf("%d\n%d\n", info->xen_version_major, info->xen_version_minor);
+    printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", info->xen_version_extra, 
info->compiler, info->compile_by, info->compile_domain, info->compile_date, 
info->capabilities, info->changeset);
+    printf("%lu\n%d\n", info->virt_start, info->pagesize);
+    printf("%s\n%s\n", info->commandline, info->build_id);
+
+    libxl_ctx_free(context);
+
+}
diff --git a/tools/golang/xenlight/test/versioninfo/versioninfo.go 
b/tools/golang/xenlight/test/versioninfo/versioninfo.go
new file mode 100644
index 0000000..cad8391
--- /dev/null
+++ b/tools/golang/xenlight/test/versioninfo/versioninfo.go
@@ -0,0 +1,33 @@
+
+package main
+
+/*
+#cgo LDFLAGS: -lxenlight -lyajl
+#include <stdlib.h>
+#include <libxl.h>
+*/
+import "C"
+import (
+       "fmt"
+       "xenproject.org/xenlight"
+       "os"
+)
+
+func main() {
+       ctx := xenlight.Ctx
+       err := ctx.Open()
+       if err != nil{
+               os.Exit(-1)
+       }
+       defer ctx.Close()
+       info, err:= ctx.GetVersionInfo()
+       if err != nil{
+               os.Exit(-1)
+       }
+
+       fmt.Printf("%d\n%d\n", info.XenVersionMajor, info.XenVersionMinor);
+       fmt.Printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", info.XenVersionExtra, 
info.Compiler, info.CompileBy, info.CompileDomain, info.CompileDate, 
info.Capabilities, info.Changeset);
+       fmt.Printf("%d\n%d\n", info.VirtStart, info.Pagesize);
+       fmt.Printf("%s\n%s\n", info.Commandline, info.BuildId);
+
+}
-- 
2.7.4


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

 


Rackspace

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