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

[Xen-changelog] [xen master] go/xenlight: Fix CpuidPoliclyList conversion



commit 084974fe715399ba9b4f60be3420f15c68cbfe59
Author:     George Dunlap <george.dunlap@xxxxxxxxxx>
AuthorDate: Thu Dec 26 17:43:17 2019 +0000
Commit:     George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Tue Jan 21 17:48:24 2020 +0000

    go/xenlight: Fix CpuidPoliclyList conversion
    
    Empty Go strings should be converted to `nil` libxl_cpuid_policy_list;
    otherwise libxl_cpuid_parse_config gets confused.
    
    Also, libxl_cpuid_policy_list returns a weird error, not a "normal"
    libxl error; if it returns one of these non-standard errors, convert
    it to ErrorInval.
    
    Finally, make the fromC() method take a pointer, and set the value of
    CpuidPolicyList such that it will generate a valid CpuidPolicyList in
    response.
    
    Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
    Reviewed-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index b1587b964f..1299981713 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -306,9 +306,14 @@ func (el *EvLink) toC(cel *C.libxl_ev_link) (err error) { 
return }
 // 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) fromC(ccpl *C.libxl_cpuid_policy_list) error { 
*cpl = ""; return nil }
 
 func (cpl CpuidPolicyList) toC(ccpl *C.libxl_cpuid_policy_list) error {
+       if cpl == "" {
+               *ccpl = nil
+               return nil
+       }
+
        s := C.CString(string(cpl))
        defer C.free(unsafe.Pointer(s))
 
@@ -316,7 +321,8 @@ func (cpl CpuidPolicyList) toC(ccpl 
*C.libxl_cpuid_policy_list) error {
        if ret != 0 {
                C.libxl_cpuid_dispose(ccpl)
 
-               return Error(-ret)
+               // libxl_cpuid_parse_config doesn't return a normal libxl error.
+               return ErrorInval
        }
 
        return nil
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
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®.