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

[Xen-devel] [PATCH v3 2/8] go/xenlight: Fix CpuidPoliclyList conversion


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Date: Fri, 17 Jan 2020 15:57:28 +0000
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@xxxxxxxxxx; spf=Pass smtp.mailfrom=George.Dunlap@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Fri, 17 Jan 2020 15:58:01 +0000
  • Ironport-sdr: bX1ymuBVfVruhi2tmvXrgWHvEW3aysskTMhoAMxWx5Lj+ZTeubfNF5bhsq6I7RZrj1FORmrb8B sdX3M+tYs24E24ks8sqe2/uualkAxktcKeFINH4D9HgJSR+R4Y/ddckoSQx2AZCObKvF8Rtqo7 3iIJ14dDowKonxX7p1HKlx9yjAzdobGV67AbWI1IxFm9103oY5ghjTZq9GZ2WjEsDkRoX/IxS0 5hqu7crBrwjTdfVT7y7F5HyPfV33yZueDKO+5AgpFVfKMktp4yBdcaPDZ0yK+q7RsMkI5jIzvW RSw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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>
---
v2:
- Port over toC() function signature change
- Have fromC set the string to ""

CC: 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
-- 
2.24.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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