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.dun...@citrix.com> --- CC: Nick Rosbrook <rosbro...@ainfosec.com> --- 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@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel