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

[Xen-devel] [PATCH 4/9] go/xenlight: Fix CpuidPoliclyList conversion


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: George Dunlap <george.dunlap@xxxxxxxxxx>
  • Date: Fri, 27 Dec 2019 16:32:19 +0000
  • Authentication-results: esa6.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, 27 Dec 2019 16:32:51 +0000
  • Ironport-sdr: 3BPHlT5ppEa5BEHZK+WdcLxhxN47Pm9UAn0JNWJ9d+ntcUNTfBvFpMD5dOE1Ohen9xmD2iklU8 OapuyABTygnuBe2O/yU4RMLrE5wupxzv2B1Lz5iyx8oCkGTHUIHH74/sGwocub5k3ha9SM1YNP t+dJsKSSTYtPucBKwWyK7C1Kb6JykSZp/ajCpsfi/bZzR8SQDAtj7rO0c2gM09509EIXFwgmGQ Te3PpEcq2WjmiHGXTHVa6YKT+JkcwMxEU/5crlmQWnLLTfqAWSHPpGp3K1BjlOm4norOm7Y3bb 5oI=
  • 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.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
CC: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
---
 tools/golang/xenlight/xenlight.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/golang/xenlight/xenlight.go 
b/tools/golang/xenlight/xenlight.go
index e18f0f35f8..99de68320b 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -317,6 +317,10 @@ 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) {
+       if cpl == "" {
+               return nil, nil
+       }
+
        var ccpl C.libxl_cpuid_policy_list
 
        s := C.CString(string(cpl))
@@ -326,7 +330,8 @@ func (cpl CpuidPolicyList) toC() 
(C.libxl_cpuid_policy_list, error) {
        if ret != 0 {
                C.libxl_cpuid_dispose(&ccpl)
 
-               return ccpl, Error(-ret)
+               // libxl_cpuid_parse_config doesn't return a normal libxl error.
+               return ccpl, ErrorInval
        }
 
        return ccpl, nil
-- 
2.24.0


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