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

[Xen-changelog] [xen staging] golang/xenlight: define CpuidPolicyList builtin type



commit 186f162c2a1750c0310e5fa7391f07d75a43b680
Author:     Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
AuthorDate: Mon Dec 16 18:08:05 2019 +0000
Commit:     George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Mon Dec 16 18:08:05 2019 +0000

    golang/xenlight: define CpuidPolicyList builtin type
    
    Define CpuidPolicyList as a string so that libxl_cpuid_parse_config can
    be used in the toC function.
    
    For now, fromC is a no-op since libxl does not support a way to read a
    policy, modify it,and then give it back to libxl.
    
    Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index c1d9fe85fd..6b87bf857d 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -245,6 +245,31 @@ type EvLink struct{}
 func (el *EvLink) fromC(cel *C.libxl_ev_link) error      { return nil }
 func (el *EvLink) toC() (cel C.libxl_ev_link, err error) { return }
 
+// CpuidPolicyList represents a libxl_cpuid_policy_list.
+//
+// The value of CpuidPolicyList is honored when used as input to libxl. If
+// a struct contains a field of type CpuidPolicyList, that field will be left
+// empty when it is returned from libxl.
+type CpuidPolicyList string
+
+func (cpl CpuidPolicyList) fromC(ccpl *C.libxl_cpuid_policy_list) error { 
return nil }
+
+func (cpl CpuidPolicyList) toC() (C.libxl_cpuid_policy_list, error) {
+       var ccpl C.libxl_cpuid_policy_list
+
+       s := C.CString(string(cpl))
+       defer C.free(unsafe.Pointer(s))
+
+       ret := C.libxl_cpuid_parse_config(&ccpl, s)
+       if ret != 0 {
+               C.libxl_cpuid_dispose(&ccpl)
+
+               return ccpl, Error(-ret)
+       }
+
+       return ccpl, nil
+}
+
 type Context struct {
        ctx    *C.libxl_ctx
        logger *C.xentoollog_logger_stdiostream
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
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®.