Re: [Xen-devel] [PATCH 11/24] golang/xenlight: define CpuidPolicyList builtin type

2019-11-15 Thread Nick Rosbrook
> Yes, let's do that. Okay, will do. As a point of clarification, should I be waiting until you've reviewed all patches in v1 before I send v2 of this series? Or do you prefer that I send a v2 that addresses your review so far? Thanks, -NR ___ Xen-dev

Re: [Xen-devel] [PATCH 11/24] golang/xenlight: define CpuidPolicyList builtin type

2019-11-15 Thread Nick Rosbrook
> On the whole I think sending v2 earlier is better, since I'll have the > discussions more recently in my head, and so will (hopefully) be able to > get an Ack or R-b more quickly. > > When the development window is open, stuff can be checked in as it's > reviewed, making the whole thing easier. >

[Xen-devel] [PATCH v2 00/22] generated Go libxl bindings using IDL

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook After Xen summit, we started the discussion in this[1] RFC thread to figure out how to generate Go bindings for libxl. This series implements that Go code generation using the existing IDL, and updates the existing hand-written code in xenlight.go to use the generated code

[Xen-devel] [PATCH v2 10/22] golang/xenlight: define CpuidPolicyList builtin type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook 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 --- Changes in v2

[Xen-devel] [PATCH v2 05/22] golang/xenlight: re-name Bitmap marshaling functions

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Re-name and modify signature of toGo function to fromC. The reason for using 'fromC' rather than 'toGo' is that it is not a good idea to define methods on the C types. Also, add error return type to Bitmap's toC function. Finally, as code-cleanu

[Xen-devel] [PATCH v2 03/22] golang/xenlight: define Devid type as int

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 640d82f35f..8ac26e63f0 100644 --- a/tools

[Xen-devel] [PATCH v2 08/22] golang/xenlight: define MsVmGenid builtin type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 23 +++ 1 file changed, 23 insertions(+) diff --git a/tools

[Xen-devel] [PATCH v2 11/22] golang/xenlight: re-factor Uuid type implementation

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Uuid as [16]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/xenlight.go | 37 +-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tools/golang/xenlight

[Xen-devel] [PATCH v2 06/22] golang/xenlight: define StringList builtin type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define StringList as []string an implement fromC and toC functions. Signed-off-by: Nick Rosbrook --- Changes in v2: - Define fromC with a pointer receiver since a newly-allocated slice is being assigned to the StringList. tools/golang/xenlight/xenlight.go | 29

[Xen-devel] [PATCH v2 14/22] golang/xenlight: remove no-longer used type MemKB

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook Acked-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index c2764af277..9420197bfb 100644 --- a/tools/golang

[Xen-devel] [PATCH v2 13/22] golang/xenlight: generate structs from the IDL

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Add struct and keyed union generation to gengotypes.py. For keyed unions, use a method similar to gRPC's oneof to interpret C unions as Go types. Meaning, for a given struct with a union field, generate a struct for each sub-struct defined in the union. Then, defi

[Xen-devel] [PATCH v2 07/22] golang/xenlight: define Mac builtin type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define Mac as [6]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- Changes in v2: - Fix the format string in String function to use %02x. - Use a value reciever for the toC function. tools/golang/xenlight/xenlight.go | 35

[Xen-devel] [PATCH v2 04/22] golang/xenlight: define KeyValueList as empty struct

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define KeyValueList as empty struct as there is currently no reason for this type to be available in the Go package. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook --- Changes in v2: - Re-define KeyValueList as empty struct, as it was decided

[Xen-devel] [PATCH v2 02/22] golang/xenlight: define Defbool builtin type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define Defbool as struct analagous to the C type, and define the type 'defboolVal' that represent true, false, and default defbool values. Implement Set, Unset, SetIfDefault, IsDefault, Val, and String functions on Defbool so that the type can be used in Go anal

[Xen-devel] [PATCH v2 12/22] golang/xenlight: re-factor Hwcap type implementation

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Hwcap as [8]uint32, and implement toC function. Also, re-name and modify signature of toGo function to fromC. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix comment in fromC since an array is being used now, not a slice. - Use a

[Xen-devel] [PATCH v2 01/22] golang/xenlight: generate enum types from IDL

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Introduce gengotypes.py to generate Go code the from IDL. As a first step, implement 'enum' type generation. As a result of the newly-generated code, remove the existing, and now conflicting definitions in xenlight.go. In the case of the Error type, rename the sli

[Xen-devel] [PATCH v2 09/22] golang/xenlight: define EvLink builtin as empty struct

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Define EvLink as empty struct as there is currently no reason the internal of this type should be used in Go. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 10 ++ 1

[Xen-devel] [PATCH v2 22/22] golang/xenlight: add error return type to Context.Cpupoolinfo

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook A previous commit that removed Context.CheckOpen revealed an ineffectual assignent to err in Context.Cpupoolinfo, as there is no error return type. Since it appears that the intent is to return an error here, add an error return value to the function signature. Signed-off

[Xen-devel] [PATCH v2 17/22] golang/xenlight: implement array C to Go marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 39 +++- tools/golang/xenlight/helpers.gen.go | 300 +++ 2 files changed, 338 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang

[Xen-devel] [PATCH v2 16/22] golang/xenlight: implement keyed union C to Go marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Switch over union key to determine how to populate 'union' in Go struct. Since the unions of C types cannot be directly accessed, add C structs in cgo preamble to assist in marshaling keyed unions. This allows the C type defined in the preamble to be populated

[Xen-devel] [PATCH v2 18/22] golang/xenlight: begin Go to C type marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Implement conversion of basic type conversions such as strings and integer types in toC functions. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 80 ++ tools/golang/xenlight/helpers.gen.go | 1015 ++ 2 files changed, 1095

[Xen-devel] [PATCH v2 19/22] golang/xenlight: implement keyed union Go to C marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Since the C union cannot be directly populated, populate the fields of the corresponding C struct defined in the cgo preamble, and then copy that struct as bytes into the byte slice that Go uses as the union. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight

[Xen-devel] [PATCH v2 15/22] golang/xenlight: begin C to Go type marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Implement basic type conversion in fromC functions such as strings and integer types. Also, remove existing toGo functions from xenlight.go in favor of the new generated functions. Signed-off-by: Nick Rosbrook --- Changes in v2: - Add Makefile changes for helpers.gen.go

[Xen-devel] [PATCH v2 20/22] golang/xenlight: implement array Go to C marshaling

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 44 +++- tools/golang/xenlight/helpers.gen.go | 359 +++ 2 files changed, 402 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang

[Xen-devel] [PATCH v2 21/22] golang/xenlight: revise use of Context type

2019-11-15 Thread Nick Rosbrook
From: Nick Rosbrook Remove the exported global context variable, 'Ctx.' Generally, it is better to not export global variables for use through a Go package. However, there are some exceptions that can be found in the standard library. Add a NewContext function instead, and remov

Re: [Xen-devel] [PATCH v2 02/22] golang/xenlight: define Defbool builtin type

2019-12-05 Thread Nick Rosbrook
> I implemented some tests for these methods to make sure everything > worked as expected (they did); but there's an unexpected side-effect: > > - *_test.go files cannot `import "C"` Yeah, this is unfortunate. > - The fromC / toC methods aren't exported > > So it's not possible to do the followi

Re: [Xen-devel] [PATCH v2 12/22] golang/xenlight: re-factor Hwcap type implementation

2019-12-05 Thread Nick Rosbrook
> Same thing with casting. Ack for all such cases of this casting. That's a good way to simplify. -NR ___ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 15/22] golang/xenlight: begin C to Go type marshaling

2019-12-05 Thread Nick Rosbrook
> You should probably say here explicitly what kinds of elements you're > supporting and not supporting in this patch; specifically: > > - You're converting built-ins (or is this any struct-like type?) Any struct-like type, since the fromC functions are all defined in this patch (excluding array f

Re: [Xen-devel] [PATCH v2 16/22] golang/xenlight: implement keyed union C to Go marshaling

2019-12-05 Thread Nick Rosbrook
> > It looks like this is duplicating (differently!) the field-copying code > > from golang_define_from_C. Is there any reason you couldn't have a > > single function, `xenlight_golang_fields_from_C`, which would be used > > for both? No, I should be able to re-factor that. Thanks. > Actually, i

Re: [Xen-devel] [PATCH v2 01/22] golang/xenlight: generate enum types from IDL

2019-12-05 Thread Nick Rosbrook
> Sorry to come back to this... I think this would be better explicitly > listing out the files that are needed. As I said, the current way of > doing things means gengotypes.py will *always* be re-run; and the > result, when experimenting with the `typeof` before, was that my local > changes to h

Re: [Xen-devel] [PATCH v2 15/22] golang/xenlight: begin C to Go type marshaling

2019-12-05 Thread Nick Rosbrook
> So first of all, I noticed that the marshalling code for Union structs > does what I suggest. :-) Yeah I realized that. I must have figured out that my previous way wasn't necessary, but forgot to go back and change it. > I'm not super-strong on this, so I don't want to bike-shed. But I think

Re: [Xen-devel] [PATCH v2 16/22] golang/xenlight: implement keyed union C to Go marshaling

2019-12-05 Thread Nick Rosbrook
> It actually occurs to me that the "named struct elements of union" would > still technically open up a window for divergence: i.e., if somehow the > type of the named struct didn't match up with the union element. > > I.e., the following *shouldn't* happen, but technically it *could*: > > >

Re: [Xen-devel] [PATCH v2 16/22] golang/xenlight: implement keyed union C to Go marshaling

2019-12-06 Thread Nick Rosbrook
> OK. FYI I'm going to have to stop reviewing here for a bit; if you > re-send the series with the comments on 1-16 addressed though, I'll skim > through and check it in if it looks good. Okay, thanks for the heads up. I'm hoping to send v3 in the next few days. -NR

[Xen-devel] [PATCH v3 00/22] generated Go libxl bindings using IDL

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook After Xen summit, we started the discussion in this[1] RFC thread to figure out how to generate Go bindings for libxl. This series implements that Go code generation using the existing IDL, and updates the existing hand-written code in xenlight.go to use the generated code

[Xen-devel] [PATCH v3 02/22] golang/xenlight: define Defbool builtin type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define Defbool as struct analagous to the C type, and define the type 'defboolVal' that represent true, false, and default defbool values. Implement Set, Unset, SetIfDefault, IsDefault, Val, and String functions on Defbool so that the type can be used in Go anal

[Xen-devel] [PATCH v3 04/22] golang/xenlight: define KeyValueList as empty struct

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define KeyValueList as empty struct as there is currently no reason for this type to be available in the Go package. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Re-define KeyValueList as empty

[Xen-devel] [PATCH v3 07/22] golang/xenlight: define Mac builtin type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define Mac as [6]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix the format string in String function to use %02x. - Use a value reciever for the toC function. Changes in v3: - Iterate

[Xen-devel] [PATCH v3 08/22] golang/xenlight: define MsVmGenid builtin type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v3: - In fromC, iterate over the indirect of mvg instead of creating a slice from the C type. --- tools

[Xen-devel] [PATCH v3 03/22] golang/xenlight: define Devid type as int

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 640d82f35f..8ac26e63f0 100644 --- a/tools

[Xen-devel] [PATCH v3 01/22] golang/xenlight: generate enum types from IDL

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Introduce gengotypes.py to generate Go code the from IDL. As a first step, implement 'enum' type generation. As a result of the newly-generated code, remove the existing, and now conflicting definitions in xenlight.go. In the case of the Error type, rename the sli

[Xen-devel] [PATCH v3 10/22] golang/xenlight: define CpuidPolicyList builtin type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook 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 Reviewed-by: George

[Xen-devel] [PATCH v3 09/22] golang/xenlight: define EvLink builtin as empty struct

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define EvLink as empty struct as there is currently no reason the internal of this type should be used in Go. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 10 ++ 1

[Xen-devel] [PATCH v3 05/22] golang/xenlight: re-name Bitmap marshaling functions

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Re-name and modify signature of toGo function to fromC. The reason for using 'fromC' rather than 'toGo' is that it is not a good idea to define methods on the C types. Also, add error return type to Bitmap's toC function. Finally, as code-cleanu

[Xen-devel] [PATCH v3 11/22] golang/xenlight: re-factor Uuid type implementation

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Uuid as [16]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- Changes in v3: - In fromC, iterate over the indirect of u instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 35

[Xen-devel] [PATCH v3 16/22] golang/xenlight: implement keyed union C to Go marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Switch over union key to determine how to populate 'union' in Go struct. Since the unions of C types cannot be directly accessed in cgo, use a typeof trick to typedef a struct in the cgo preamble that is analagous to each inner struct of a keyed union. For example,

[Xen-devel] [PATCH v3 15/22] golang/xenlight: begin C to Go type marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Begin implementation of fromC marshaling functions for generated struct types. This includes support for converting fields that are basic primitive types such as string and integer types, nested anonymous structs, nested libxl structs, and libxl built-in types. This patch

[Xen-devel] [PATCH v3 13/22] golang/xenlight: generate structs from the IDL

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Add struct and keyed union generation to gengotypes.py. For keyed unions, use a method similar to gRPC's oneof to interpret C unions as Go types. Meaning, for a given struct with a union field, generate a struct for each sub-struct defined in the union. Then, defi

[Xen-devel] [PATCH v3 17/22] golang/xenlight: implement array C to Go marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 39 +++- tools/golang/xenlight/helpers.gen.go | 300 +++ 2 files changed, 338 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang

[Xen-devel] [PATCH v3 06/22] golang/xenlight: define StringList builtin type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Define StringList as []string an implement fromC and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Define fromC with a pointer receiver since a newly-allocated slice is being assigned to the StringList. --- tools/golang

[Xen-devel] [PATCH v3 12/22] golang/xenlight: re-factor Hwcap type implementation

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Hwcap as [8]uint32, and implement toC function. Also, re-name and modify signature of toGo function to fromC. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix comment in fromC since an array is being used now, not a slice. - Use a

[Xen-devel] [PATCH v3 20/22] golang/xenlight: implement array Go to C marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 44 +++- tools/golang/xenlight/helpers.gen.go | 359 +++ 2 files changed, 402 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang

[Xen-devel] [PATCH v3 19/22] golang/xenlight: implement keyed union Go to C marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Since the C union cannot be directly populated, populate the fields of the corresponding C struct defined in the cgo preamble, and then copy that struct as bytes into the byte slice that Go uses as the union. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight

[Xen-devel] [PATCH v3 21/22] golang/xenlight: revise use of Context type

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Remove the exported global context variable, 'Ctx.' Generally, it is better to not export global variables for use through a Go package. However, there are some exceptions that can be found in the standard library. Add a NewContext function instead, and remov

[Xen-devel] [PATCH v3 18/22] golang/xenlight: begin Go to C type marshaling

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Implement conversion of basic type conversions such as strings and integer types in toC functions. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 80 ++ tools/golang/xenlight/helpers.gen.go | 1015 ++ 2 files changed, 1095

[Xen-devel] [PATCH v3 22/22] golang/xenlight: add error return type to Context.Cpupoolinfo

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook A previous commit that removed Context.CheckOpen revealed an ineffectual assignent to err in Context.Cpupoolinfo, as there is no error return type. Since it appears that the intent is to return an error here, add an error return value to the function signature. Signed-off

[Xen-devel] [PATCH v3 14/22] golang/xenlight: remove no-longer used type MemKB

2019-12-10 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook Acked-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 8f41047726..fb1c6d9e51 100644 --- a/tools/golang

Re: [Xen-devel] [PATCH v3 01/22] golang/xenlight: generate enum types from IDL

2019-12-16 Thread Nick Rosbrook
> I was expecting you to change this if you sent a v3. :-) > > I can still change it on check-in, but if for some reason there's a v4, > please make the change before resending. Thanks. :-) Sorry, my mistake. I will make the change if I send v4. Thanks, -NR _

Re: [Xen-devel] [PATCH v3 17/22] golang/xenlight: implement array C to Go marshaling

2019-12-17 Thread Nick Rosbrook
On Tue, Dec 17, 2019 at 6:16 AM George Dunlap wrote: > > On 12/10/19 3:47 PM, Nick Rosbrook wrote: > > From: Nick Rosbrook > > > > Signed-off-by: Nick Rosbrook > > --- > > tools/golang/xenlight/gengotypes.py | 39 +++- > >

[Xen-devel] [PATCH v4 2/6] golang/xenlight: begin Go to C type marshaling

2019-12-23 Thread Nick Rosbrook
Implement conversion of basic type conversions such as strings and integer types in toC functions. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 80 ++ tools/golang/xenlight/helpers.gen.go | 1015 ++ 2 files changed, 1095 insertions(+) diff

[Xen-devel] [PATCH v4 3/6] golang/xenlight: implement keyed union Go to C marshaling

2019-12-23 Thread Nick Rosbrook
Since the C union cannot be directly populated, populate the fields of the corresponding C struct defined in the cgo preamble, and then copy that struct as bytes into the byte slice that Go uses as the union. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 77

[Xen-devel] [PATCH v4 1/6] golang/xenlight: implement array C to Go marshaling

2019-12-23 Thread Nick Rosbrook
Signed-off-by: Nick Rosbrook --- Changes in v4: - Call fromC using slice expression instead of creating temporary variable and assigning later. --- tools/golang/xenlight/gengotypes.py | 37 +++- tools/golang/xenlight/helpers.gen.go | 246 +++ 2 files changed, 282

[Xen-devel] [PATCH v4 0/6] generated Go libxl bindings using IDL

2019-12-23 Thread Nick Rosbrook
://github.com/enr0n/xen/tree/golang-patches-v3 [5] https://github.com/enr0n/xen/tree/golang-patches-v4 Nick Rosbrook (6): golang/xenlight: implement array C to Go marshaling golang/xenlight: begin Go to C type marshaling golang/xenlight: implement keyed union Go to C marshaling golang/xenlight

[Xen-devel] [PATCH v4 4/6] golang/xenlight: implement array Go to C marshaling

2019-12-23 Thread Nick Rosbrook
Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 44 +++- tools/golang/xenlight/helpers.gen.go | 359 +++ 2 files changed, 402 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py

[Xen-devel] [PATCH v4 6/6] golang/xenlight: add error return type to Context.Cpupoolinfo

2019-12-23 Thread Nick Rosbrook
A previous commit that removed Context.CheckOpen revealed an ineffectual assignent to err in Context.Cpupoolinfo, as there is no error return type. Since it appears that the intent is to return an error here, add an error return value to the function signature. Signed-off-by: Nick Rosbrook

[Xen-devel] [PATCH v4 5/6] golang/xenlight: revise use of Context type

2019-12-23 Thread Nick Rosbrook
CheckOpen functions as a result. Also, comment-out an ineffectual assignment to 'err' inside the function Context.CpupoolInfo so that compilation does not fail. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v4: - Add line break to excessively long line in NewContex

Re: [Xen-devel] [PATCH v4 2/6] golang/xenlight: begin Go to C type marshaling

2019-12-24 Thread Nick Rosbrook
> I realize this is all generated code, but there's still a massive amount > of duplication here, which will at very least cause code bloat. I think > it should be possible to do this all at once with a defer, like this: > > func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) { > C.li

[Xen-devel] [PATCH 04/24] golang/xenlight: define Devid type as int

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 7bf16dc03b..4d4fad2a9d

[Xen-devel] [PATCH 06/24] golang/xenlight: re-name Bitmap marshaling functions

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Re-name and modify signature of toGo function to fromC. The reason for using 'fromC' rather than 'toGo' is that it is not a good idea to define methods on the C types. Also, add error return type to Bitmap's toC function. Finally, as code-cleanu

[Xen-devel] [PATCH 01/24] golang/xenlight: fix calls to libxl_domain_unpause/pause

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook These functions require a third argument of type const *libxl_asyncop_how. Pass nil to fix compilation errors. This will have the effect of performing these operations synchronously. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools

[Xen-devel] [PATCH 03/24] golang/xenlight: define Defbool builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define Defbool as struct analagous to the C type, and define the type 'defboolVal' that represent true, false, and default defbool values. Implement Set, Unset, SetIfDefault, IsDefault, Val, and String functions on Defbool so that the type can be used in Go anal

[Xen-devel] [PATCH 00/24] generated Go libxl bindings using IDL

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook After Xen summit, we started the discussion in this[1] RFC thread to figure out how to generate Go bindings for libxl. This series implements that Go code generation using the existing IDL, and updates the existing hand-written code in xenlight.go to use the generated code

[Xen-devel] [PATCH 09/24] golang/xenlight: define MsVmGenid builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC and toC functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 23 +++ 1 file changed, 23 insertions

[Xen-devel] [PATCH 02/24] golang/xenlight: generate enum types from IDL

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Introduce gengotypes.py to generate Go code the from IDL. As a first step, implement 'enum' type generation. As a result of the newly-generated code, remove the existing, and now conflicting definitions in xenlight.go. In the case of the Error type, rename the sli

[Xen-devel] [PATCH 05/24] golang/xenlight: define KeyValueList builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define KeyValueList builtin type, analagous to libxl_key_value_list as map[string]string, and implement its fromC and toC functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 33

[Xen-devel] [PATCH 07/24] golang/xenlight: define StringList builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define StringList as []string an implement fromC and toC functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 29 + 1 file changed, 29 insertions(+) diff --git a/tools

[Xen-devel] [PATCH 12/24] golang/xenlight: re-factor Uuid type implementation

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Uuid as [16]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 37 +-- 1 file changed, 35 insertions(+), 2

[Xen-devel] [PATCH 10/24] golang/xenlight: define EvLink builtin as empty struct

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define EvLink as empty struct as there is currently no reason the internal of this type should be used in Go. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go

[Xen-devel] [PATCH 11/24] golang/xenlight: define CpuidPolicyList builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define CpuidPolicyList as a wrapper struct with field val of type *C.libxl_cpuid_policy_list and implement fromC and toC functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 20

[Xen-devel] [PATCH 08/24] golang/xenlight: define Mac builtin type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Define Mac as [6]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 35 +++ 1 file changed, 35 insertions(+) diff --git a

[Xen-devel] [PATCH 15/24] golang/xenlight: remove no-longer used type MemKB

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 0adb12d1bf..f91c0d2be2

[Xen-devel] [PATCH 14/24] golang/xenlight: generate structs from the IDL

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Add struct and keyed union generation to gengotypes.py. For keyed unions, use a method similar to gRPC's oneof to interpret C unions as Go types. Meaning, for a given struct with a union field, generate a struct for each sub-struct defined in the union. Then, defi

[Xen-devel] [PATCH 13/24] golang/xenlight: re-factor Hwcap type implementation

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Re-define Hwcap as [8]uint32, and implement toC function. Also, re-name and modify signature of toGo function to fromC. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 29

[Xen-devel] [PATCH 18/24] golang/xenlight: implement array C to Go marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/gengotypes.py | 39 ++- tools/golang/xenlight/xenlight_helpers.go | 300 ++ 2 files changed, 338 insertions(+), 1 deletion(-) diff --git a

[Xen-devel] [PATCH 17/24] golang/xenlight: implement keyed union C to Go marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Switch over union key to determine how to populate 'union' in Go struct. Since the unions of C types cannot be directly accessed, add C structs in cgo preamble to assist in marshaling keyed unions. This allows the C type defined in the preamble to be populated

[Xen-devel] [PATCH 20/24] golang/xenlight: implement keyed union Go to C marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Since the C union cannot be directly populated, populate the fields of the corresponding C struct defined in the cgo preamble, and then copy that struct as bytes into the byte slice that Go uses as the union. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian

[Xen-devel] [PATCH 23/24] golang/xenlight: add error return type to Context.Cpupoolinfo

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook A previous commit that removed Context.CheckOpen revealed an ineffectual assignent to err in Context.Cpupoolinfo, as there is no error return type. Since it appears that the intent is to return an error here, add an error return value to the function signature. Signed-off

[Xen-devel] [PATCH 24/24] golang/xenlight: add make target for generated files

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Remove the PKGSOURCES variable since adding xenlight_types.go and xenlight_helpers.go to this list breaks the rest of the Makefile. Add xenlight_%.go target for generated files, and use full file names within install, uninstall and $(XEN_GOPATH)$(GOXL_PKG_DIR) rule. Signed

[Xen-devel] [PATCH 22/24] golang/xenlight: revise use of Context type

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Remove the exported global context variable, 'Ctx.' Generally, it is better to not export global variables for use through a Go package. However, there are some exceptions that can be found in the standard library. Add a NewContext function instead, and remov

[Xen-devel] [PATCH 19/24] golang/xenlight: begin Go to C type marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Implement conversion of basic type conversions such as strings and integer types in toC functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/gengotypes.py | 80 ++ tools/golang/xenlight

[Xen-devel] [PATCH 16/24] golang/xenlight: begin C to Go type marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Implement basic type conversion in fromC functions such as strings and integer types. Also, remove existing toGo functions from xenlight.go in favor of the new generated functions. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools

[Xen-devel] [PATCH 21/24] golang/xenlight: implement array Go to C marshaling

2019-10-07 Thread Nick Rosbrook
From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/gengotypes.py | 44 ++- tools/golang/xenlight/xenlight_helpers.go | 359 ++ 2 files changed, 402 insertions(+), 1 deletion(-) diff --git a

Re: [Xen-devel] [PATCH 24/24] golang/xenlight: add make target for generated files

2019-10-24 Thread Nick Rosbrook
> One standard practice when making a series is to try to avoid any > regressions, including build regressions, in the middle of the series. > This is particularly helpful to aid in bisections, but in this case it > makes it easier to observe the action of the `gengotypes.py` script (and > how it's

Re: [Xen-devel] [PATCH 05/24] golang/xenlight: define KeyValueList builtin type

2019-10-24 Thread Nick Rosbrook
> So we *could* actually just `type KeyValueList struct { }`, and punt on > all these initialization questions until such time as it turns out that > they're needed. If there is no clear need for this type to be implemented in the Go package, then I would be in favor of not doing so. IMO, a smalle

Re: [Xen-devel] [PATCH 05/24] golang/xenlight: define KeyValueList builtin type

2019-10-25 Thread Nick Rosbrook
> Ok, in that case let’s just leave the struct empty. Ok, sounds like a plan. > I think we basically have three options: > > 1. Try to arrange it so that the “zero” values correspond to “default” values > in libxl; i.e., have DevID 0 -> libxl_devid -1, DevID 1 -> libxl_devid 0, &c > > 2. Add New

Re: [Xen-devel] [PATCH 06/24] golang/xenlight: re-name Bitmap marshaling functions

2019-11-13 Thread Nick Rosbrook
> Any particular reason to use `cslice` here rather than `mapslice` (or > vice versa)? > > Not a big deal, but since they're of the came element in the C struct, > it seems like it would be better to give them the same name. (Don't > have a strong opinion on which one). IIRC, I found the name `ma

Re: [Xen-devel] [PATCH 07/24] golang/xenlight: define StringList builtin type

2019-11-13 Thread Nick Rosbrook
> Doesn't this method want a pointer receiver? Yes, since I'm allocating a new slice. If I wasn't allocating a new slice, this would be okay since the slice contains a pointer to the underlying array. -NR ___ Xen-devel mailing list Xen-devel@lists.xenp

Re: [Xen-devel] [PATCH 08/24] golang/xenlight: define Mac builtin type

2019-11-13 Thread Nick Rosbrook
> What's the point of this? > > I realize it's slightly annoying to have to type `mac[0], mac[1], ...`, > but I'd rather do that once than make the runtime copy everything over > into a slice of interfaces every String() call. As I think you realized by looking at subsequent patches, this is to ge

Re: [Xen-devel] [PATCH 11/24] golang/xenlight: define CpuidPolicyList builtin type

2019-11-14 Thread Nick Rosbrook
> Hmm, this introduces a pretty significant risk of memory leaks; but I > don't really see any way around it. I guess we really want to do some > SetFinalizer() magic on this to call libxl_cpuid_dispose()? > > We might also want to add something like a .Dispose() method to have > predictable memor

Re: [Xen-devel] [PATCH 08/24] golang/xenlight: define Mac builtin type

2019-11-14 Thread Nick Rosbrook
> So the code you have is probably going to be about equally efficient anyway. A quick benchmark [1] shows: goos: linux goarch: amd64 BenchmarkString1-8500 251 ns/op BenchmarkString2-8500 247 ns/op So yes, they're about the same :) I'll leave it as is

Re: [Xen-devel] [PATCH 14/24] golang/xenlight: generate structs from the IDL

2019-11-14 Thread Nick Rosbrook
> BTW I was discussing with Ian Jackson, and I think at some point it > would be worth considering adding in an annotation or something to the > IDL such that the generator can use time.Duration for these things. > That opens up another can of works, like the fact that Duration is > int64 rather t

  1   2   3   >