Re: New git repository for Go bindings

2025-03-07 Thread Victor Toso
On Fri, Mar 07, 2025 at 12:49:59PM +, Daniel P. Berrangé wrote: > On Fri, Mar 07, 2025 at 01:30:38PM +0100, Victor Toso wrote: > > Hi, > > > > I've been working on and off in having Go bindings for QEMU's > > QAPI specification. The last version [0] s

New git repository for Go bindings

2025-03-07 Thread Victor Toso
Hi, I've been working on and off in having Go bindings for QEMU's QAPI specification. The last version [0] seems to be accepted so far but we would like not to have that in qemu.git. In the past [1], Daniel suggested creating a repo per each generated schema: go-qemu.git, go-qga.git, go-qsd.git

Re: [PATCH v4 00/11]

2025-03-07 Thread Victor Toso
Hi, On Mon, Feb 17, 2025 at 05:52:49PM +0100, Victor Toso wrote: > On Mon, Feb 17, 2025 at 02:58:22PM +, Daniel P. Berrangé wrote: > > On Fri, Feb 14, 2025 at 09:29:33PM +0100, Victor Toso wrote: > > > > > > # Expectations # > > > #

Re: [PATCH v4 00/11]

2025-02-17 Thread Victor Toso
Hi, On Mon, Feb 17, 2025 at 02:58:22PM +, Daniel P. Berrangé wrote: > On Fri, Feb 14, 2025 at 09:29:33PM +0100, Victor Toso wrote: > > Hi again, > > > > This patch series intent is to introduce a generator that produces a Go > > module for Go applications to

[PATCH v4 11/11] docs: add notes on Golang code generator

2025-02-14 Thread Victor Toso
The goal of this patch is converge discussions into a documentation, to make it easy and explicit design decisions, known issues and what else might help a person interested in how the Go module is generated. Signed-off-by: Victor Toso --- docs/devel/index-build.rst | 1 + docs/devel

[PATCH v4 08/11] qapi: golang: Generate Event interface

2025-02-14 Thread Victor Toso
The Event interface is an abstraction that can be used by client and server to the manager the Event types albeit with a different implementation for sending and receiving. The implementation of client/server is not part of this series. Signed-off-by: Victor Toso --- scripts/qapi/golang

[PATCH v4 06/11] qapi: golang: Generate union type

2025-02-14 Thread Victor Toso
ts to 'keep'. For VNC, only 'keep' | // is currently implemented. | Connected *SetPasswordAction `json:"connected,omitempty"` | // Variants fields | Vnc *SetPasswordOptionsVnc `json:"-"` | // Unbranched enum fields | Spice bool `json

[PATCH v4 04/11] qapi: golang: Generate struct types

2025-02-14 Thread Victor Toso
to add to the image file; 0 for not adding an | // extent size hint (default: 1 MB, since 5.1) | ExtentSizeHint *uint64 `json:"extent-size-hint,omitempty"` | } Signed-off-by: Victor Toso --- scripts/qapi/golang/golang.py | 193 +- 1 file chang

[PATCH v4 09/11] qapi: golang: Generate command type

2025-02-14 Thread Victor Toso
uot;, "arguments": { | // "fdset-id": 1 } } <- { "return": { "fdset-id": 1, "fd": 3 } } | type AddFdCommand struct { | // The ID of the fd set to add the file descriptor to. | FdsetId *int64 `json:"fdset-id,omitempty"`

[PATCH v4 05/11] qapi: golang: structs: Address nullable members

2025-02-14 Thread Victor Toso
arshaling from JSON. This patch handles this very specific case: - It implements the Marshaler interface for these structs to properly handle these values. - It adds the interface AbsentAlternate() and implement it for any Alternate that can be JSON Null. See its uses in map_and_set() Sign

[PATCH v4 10/11] qapi: golang: Generate Command sync/async interfaces

2025-02-14 Thread Victor Toso
is not part of this series. Signed-off-by: Victor Toso --- scripts/qapi/golang/golang.py | 56 +++ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/golang/golang.py b/scripts/qapi/golang/golang.py index a14970fb1f..0b7dadff41 100644 --- a

[PATCH v4 07/11] qapi: golang: Generate event type

2025-02-14 Thread Victor Toso
d/device[2]" }, "timestamp": { "seconds": | // 1588168529, "microseconds": 201316 } } | type MemoryDeviceSizeChangeEvent struct { | // device's ID | Id *string `json:"id,omitempty"` | // the new size of memory that the device p

[PATCH v4 03/11] qapi: golang: Generate alternate types

2025-02-14 Thread Victor Toso
rent meaning. | // | // Since: 2.10 | type StrOrNull struct { | // the string value | S *string | // no string value | IsNull bool | } | | // Helper function to get its underlying Go value or absent of value | func (s *StrOrNull) ToAnyOrAbsent() (any, boo

[PATCH v4 02/11] qapi: golang: Generate enum type

2025-02-14 Thread Victor Toso
ata': [ 'vnc', 'spice' ] } go: | // Display protocols which support changing password options. | // | // Since: 7.0 | type DisplayProtocol string | | const ( | DisplayProtocolVnc DisplayProtocol = "vnc" | DisplayProtocolSpice DisplayProtoc

[PATCH v4 00/11]

2025-02-14 Thread Victor Toso
rged we would need to: 1. Create gitlab's repo 2. Add unit test and CI to new repos 3. Have first alpha relase/tag 4. Start working on top :) Thanks for the time looking at this. I appreciate it. Victor Toso (11): qapi: golang: first level unmarshalling type qapi: golang: Generate en

[PATCH v4 01/11] qapi: golang: first level unmarshalling type

2025-02-14 Thread Victor Toso
te any patch of this series with: python3 ./scripts/qapi-gen.py -o /tmp/out qapi/qapi-schema.json Signed-off-by: Victor Toso --- scripts/qapi/golang/__init__.py | 0 scripts/qapi/golang/golang.py | 135 scripts/qapi/golang/protocol.go | 48

Re: [PATCH v3 0/8] qapi-go: add generator for Golang interfaces

2025-02-11 Thread Victor Toso
Hi, On Tue, Feb 11, 2025 at 11:10:37AM +, Daniel P. Berrangé wrote: > On Tue, Feb 11, 2025 at 11:25:05AM +0100, Victor Toso wrote: > > Hi, > > > > On Thu, Jan 16, 2025 at 09:59:52PM +, Daniel P. Berrangé wrote: > > > <<<<

Re: [PATCH v3 0/8] qapi-go: add generator for Golang interfaces

2025-02-11 Thread Victor Toso
Hi, On Thu, Jan 16, 2025 at 09:59:52PM +, Daniel P. Berrangé wrote: > Pause here if you've read enough for now. > > > > As a way to validate these thoughts, I spent a day to mock up a demo > of a QAPI client and server implementation. > > First I created some manually written

Re: [PATCH v3 0/8] qapi-go: add generator for Golang interfaces

2025-01-29 Thread Victor Toso
Hi, On Thu, Jan 16, 2025 at 09:59:52PM +, Daniel P. Berrangé wrote: > On Fri, Jan 10, 2025 at 11:49:38AM +0100, Victor Toso wrote: > > I've pushed this series in my gitlab fork: > > https://gitlab.com/victortoso/qapi-go/ > > > > The fork contains some

Re: [PATCH v3 1/8] qapi: golang: Generate enum type

2025-01-17 Thread Victor Toso
Hi, On Fri, Jan 17, 2025 at 10:10:51AM +, Daniel P. Berrangé wrote: > On Fri, Jan 10, 2025 at 11:49:39AM +0100, Victor Toso wrote: > > This patch handles QAPI enum types and generates its equivalent in Go. > > We sort the output based on enum's type name. > > >

Re: [PATCH v3 0/8] qapi-go: add generator for Golang interfaces

2025-01-14 Thread Victor Toso
Hi, On Mon, Jan 13, 2025 at 01:52:25PM +0100, Markus Armbruster wrote: > Victor Toso writes: > > > This patch series intent is to introduce a generator that produces a Go > > module for Go applications to interact over QMP with QEMU. > > > > The initial Goal is to

Re: [PATCH v3 1/8] qapi: golang: Generate enum type

2025-01-14 Thread Victor Toso
Hi, On Tue, Jan 14, 2025 at 09:52:23AM +0100, Markus Armbruster wrote: > Victor Toso writes: > > > This patch handles QAPI enum types and generates its equivalent in Go. > > We sort the output based on enum's type name. > > Any particular reason for sorting? It w

[PATCH v3 0/8] qapi-go: add generator for Golang interfaces

2025-01-10 Thread Victor Toso
drea) On python script: - rebased: now uses QAPISchemaBranches, QAPISchemaAlternatives - use textwrap as much as possible (Andrea) - lots of changes to make the output like gofmt does Victor Toso (8): qapi: golang: Generate enum type qapi: golang: Generate alternate types qapi: golang: Generate

[PATCH v3 7/8] qapi: golang: Generate command type

2025-01-10 Thread Victor Toso
arshal([]byte(input), &c) | if err != nil { | panic(err) | } | // c.Password == "secret" | } | | // Generic way, using Command interface and helper function | if cmd, err := GetCommandType(input); err != nil { | // handle bad data or unknown event | }

[PATCH v3 4/8] qapi: golang: structs: Address nullable members

2025-01-10 Thread Victor Toso
arshaling from JSON. This patch handles this very specific case: - It implements the Marshaler interface for these structs to properly handle these values. - It adds the interface AbsentAlternate() and implement it for any Alternate that can be JSON Null. See its uses in map_and_set() Signed-of

[PATCH v3 2/8] qapi: golang: Generate alternate types

2025-01-10 Thread Victor Toso
rent meaning. | // | // Since: 2.10 | type StrOrNull struct { | // the string value | S *string | // no string value | IsNull bool | } | | // Helper function to get its underlying Go value or absent of value | func (s *StrOrNull) ToAnyOrAbsent() (any, bool)

[PATCH v3 8/8] docs: add notes on Golang code generator

2025-01-10 Thread Victor Toso
The goal of this patch is converge discussions into a documentation, to make it easy and explicit design decisions, known issues and what else might help a person interested in how the Go module is generated. Signed-off-by: Victor Toso --- docs/devel/index-build.rst | 1 + docs/devel

[PATCH v3 1/8] qapi: golang: Generate enum type

2025-01-10 Thread Victor Toso
ata': [ 'vnc', 'spice' ] } go: | // Display protocols which support changing password options. | // | // Since: 7.0 | type DisplayProtocol string | | const ( | DisplayProtocolVnc DisplayProtocol = "vnc" | DisplayProtocolSpice DisplayProtoc

[PATCH v3 5/8] qapi: golang: Generate union type

2025-01-10 Thread Victor Toso
ts to 'keep'. For VNC, only 'keep' | // is currently implemented. | Connected *SetPasswordAction `json:"connected,omitempty"` | // Variants fields | Vnc *SetPasswordOptionsVnc `json:"-"` | // Unbranched enum fields | Spice bool `jso

[PATCH v3 6/8] qapi: golang: Generate event type

2025-01-10 Thread Victor Toso
| // Straight forward if you know the event type | { | mdsc := MemoryDeviceSizeChangeEvent{} | err := json.Unmarshal([]byte(input), &mdsc) | if err != nil { | panic(err) | } | // mdsc.QomPath == "/machine/unattached/

[PATCH v3 3/8] qapi: golang: Generate struct types

2025-01-10 Thread Victor Toso
to add to the image file; 0 for not adding an | // extent size hint (default: 1 MB, since 5.1) | ExtentSizeHint *uint64 `json:"extent-size-hint,omitempty"` | } Signed-off-by: Victor Toso --- scripts/qapi/golang.py | 199 - 1 fil

[PATCH] qapi: fix colon in Since tag section

2024-12-17 Thread Victor Toso
As described in docs/devel/qapi-code-gen.rst line 998, there should be no space between "Since" and ":". Signed-off-by: Victor Toso --- qapi/cxl.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qapi/cxl.json b/qapi/cxl.json index 9f65589bce..dd9

Re: [RFC PATCH v2 0/8] qapi: add generator for Golang interface

2024-11-08 Thread Victor Toso
9:24PM +0200, Victor Toso wrote: > > Hi, > > > > This is the second iteration of RFC v1: > > https://lists.gnu.org/archive/html/qemu-devel/2022-04/msg00226.html > > > > > > # What this is about? > > > > To generate a simple Golang interface

Re: [PATCH v2 07/11] qapi: golang: Generate qapi's union types in Go

2023-11-10 Thread Victor Toso
Hi, On Fri, Nov 10, 2023 at 01:54:50AM -0800, Andrea Bolognani wrote: > On Thu, Nov 09, 2023 at 07:35:04PM +0100, Victor Toso wrote: > > On Thu, Nov 09, 2023 at 09:29:28AM -0800, Andrea Bolognani wrote: > > > Additionally, this would allow client code that *looks* at the &

Re: [PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go

2023-11-10 Thread Victor Toso
Hi, On Fri, Nov 10, 2023 at 01:58:20AM -0800, Andrea Bolognani wrote: > On Thu, Nov 09, 2023 at 08:01:48PM +0100, Victor Toso wrote: > > On Thu, Nov 09, 2023 at 09:34:56AM -0800, Andrea Bolognani wrote: > > > We should call this Null instead of IsNull, and also make it a >

Re: [PATCH v2 10/11] qapi: golang: Add CommandResult type to Go

2023-11-09 Thread Victor Toso
Hi, On Thu, Nov 09, 2023 at 10:24:20AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:27:03PM +0200, Victor Toso wrote: > > This patch adds a struct type in Go that will handle return values > > for QAPI's command types. > > > > The return value o

Re: [PATCH v2 08/11] qapi: golang: Generate qapi's event types in Go

2023-11-09 Thread Victor Toso
Hi, On Thu, Nov 09, 2023 at 09:59:50AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:27:01PM +0200, Victor Toso wrote: > > This patch handles QAPI event types and generates data structures in > > Go that handles it. > > > > We also define a Event interfa

Re: [PATCH v2 00/11] qapi-go: add generator for Golang interface

2023-11-09 Thread Victor Toso
Hi, On Thu, Nov 09, 2023 at 10:35:07AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:26:53PM +0200, Victor Toso wrote: > > This patch series intent is to introduce a generator that produces a Go > > module for Go applications to interact over QMP with QEMU. >

Re: [PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go

2023-11-09 Thread Victor Toso
Hi, On Thu, Nov 09, 2023 at 09:34:56AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:26:57PM +0200, Victor Toso wrote: > > [*] The exception for optional fields as default is to Types that can > > accept JSON Null as a value. For this case, we translate NULL to a

Re: [PATCH v2 07/11] qapi: golang: Generate qapi's union types in Go

2023-11-09 Thread Victor Toso
Hi, On Thu, Nov 09, 2023 at 09:29:28AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:27:00PM +0200, Victor Toso wrote: > > This patch handles QAPI union types and generates the equivalent data > > structures and methods in Go to handle it. > > > > The QA

Re: [PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go

2023-11-06 Thread Victor Toso
Hi, On Mon, Nov 06, 2023 at 07:28:04AM -0800, Andrea Bolognani wrote: > On Mon, Oct 16, 2023 at 05:26:57PM +0200, Victor Toso wrote: > > This patch handles QAPI alternate types and generates data structures > > in Go that handles it. > > > > Alternate types are sim

Re: [PATCH v2 00/11] qapi-go: add generator for Golang interface

2023-11-06 Thread Victor Toso
Hi, On Fri, Nov 03, 2023 at 11:34:18AM -0700, Andrea Bolognani wrote: > On Tue, Oct 31, 2023 at 09:42:10AM -0700, Andrea Bolognani wrote: > > On Fri, Oct 27, 2023 at 07:33:30PM +0200, Victor Toso wrote: > > > Hi, > > > > > > Daniel & Andrea, it wo

Re: [PATCH v2 00/11] qapi-go: add generator for Golang interface

2023-10-27 Thread Victor Toso
ata type names) - scripts/qapi library wrt to generating interfaces in other languages other than C I would love to have this prior to 8.2 feature freeze if the idea and current code meet your expectations. Cheers, Victor On Mon, Oct 16, 2023 at 05:26:53PM +0200, Victor Toso wrote: >

Re: [PATCH v3 10/10] qapi: scripts: add a generator for qapi's examples

2023-10-18 Thread Victor Toso
Hi Markus, Sorry the delay on reply here. On Thu, Sep 21, 2023 at 01:06:01PM +0200, Markus Armbruster wrote: > Victor Toso writes: > > > This generator has two goals: > > 1. Mechanical validation of QAPI examples > > 2. Generate the examples in a JSON format

Re: [PATCH v2 11/11] docs: add notes on Golang code generator

2023-10-18 Thread Victor Toso
Hi, On Wed, Oct 18, 2023 at 01:47:56PM +0200, Markus Armbruster wrote: > Victor Toso writes: > > > The goal of this patch is converge discussions into a documentation, > > to make it easy and explicit design decisions, known issues and what > > else might help a person

Re: [PATCH v2 02/11] scripts: qapi: black format main.py

2023-10-18 Thread Victor Toso
On Wed, Oct 18, 2023 at 01:00:07PM +0200, Markus Armbruster wrote: > Victor Toso writes: > > > flake8 complained: > > ./main.py:60:1: E302 expected 2 blank lines, found 1 > > > > Which is simple enough. My vim has black [0] enabled by default, so it >

[PATCH v2 08/11] qapi: golang: Generate qapi's event types in Go

2023-10-16 Thread Victor Toso
uot;data":{"id":"vm0","size":1073741824,"qom-path":"/machine/unattached/device[2]"}}` | e, err := UnmarshalEvent([]byte(input) | if err != nil { | panic(err) | } | if e.GetName() == `MEMORY_DEVICE_SIZE_CHANGE` { | m := e.(*MemoryDevi

[PATCH v2 05/11] qapi: golang: Generate qapi's struct types in Go

2023-10-16 Thread Victor Toso
go: | type BlockdevCreateOptionsFile struct { | Filename string`json:"filename"` | Size uint64`json:"size"` | Preallocation *PreallocMode `json:"preallocation,omitempty"` | Nocow *bool

[PATCH v2 03/11] qapi: golang: Generate qapi's enum types in Go

2023-10-16 Thread Victor Toso
DisplayProtocol = "vnc" | DisplayProtocolSpice DisplayProtocol = "spice" | ) Signed-off-by: Victor Toso --- scripts/qapi/golang.py | 173 + scripts/qapi/main.py | 3 + 2 files changed, 176 insertions(+) create mode 100644

[PATCH v2 00/11] qapi-go: add generator for Golang interface

2023-10-16 Thread Victor Toso
ded a fix from John https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg01305.html - Added a tangent fix suggestion to main.py "scripts: qapi: black format main.py" John Snow (1): qapi: re-establish linting baseline Victor Toso (10): scripts: qapi: black format main.py qapi: go

[PATCH v2 06/11] qapi: golang: structs: Address 'null' members

2023-10-16 Thread Victor Toso
arshaling from JSON. This patch handles this very specific case: - It implements the Marshaler interface for these structs to properly handle these values. - It adds the interface AbsentAlternate() and implement it for any Alternate that can be JSON Null Signed-off-by: Victor Toso --- scrip

[PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go

2023-10-16 Thread Victor Toso
Go. This will be explained better in the documentation patch of this series but the main rationale is around Marshaling to and from JSON and Go data structures. Example: qapi: | { 'alternate': 'StrOrNull', | 'data': { 's': 'str'

[PATCH v2 07/11] qapi: golang: Generate qapi's union types in Go

2023-10-16 Thread Victor Toso
minator': 'protocol', | 'data': { 'vnc': 'SetPasswordOptionsVnc' } } go: | type SetPasswordOptions struct { | Password string `json:"password"` | Connected *SetPasswordAction `json:"connected,omitempty"` |

[PATCH v2 11/11] docs: add notes on Golang code generator

2023-10-16 Thread Victor Toso
The goal of this patch is converge discussions into a documentation, to make it easy and explicit design decisions, known issues and what else might help a person interested in how the Go module is generated. Signed-off-by: Victor Toso --- docs/devel/index-build.rst | 1 + docs/devel

[PATCH v2 10/11] qapi: golang: Add CommandResult type to Go

2023-10-16 Thread Victor Toso
e" : "running",` + |`"handle" : 1 } } ` | | ret := QuerySevCommandReturn{} | err := json.Unmarshal([]byte(input), &ret) | if ret.Error != nil { | // Handle command failure {"error": { ...}} | } else if ret.Result !

[PATCH v2 09/11] qapi: golang: Generate qapi's command types in Go

2023-10-16 Thread Victor Toso
f c.GetName() == `set_password` { | m := c.(*SetPasswordCommand) | // m.Password == "secret" | } Signed-off-by: Victor Toso --- scripts/qapi/golang.py | 116 - 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/s

[PATCH v2 01/11] qapi: re-establish linting baseline

2023-10-16 Thread Victor Toso
From: John Snow Some very minor housekeeping to make the linters happy once more. Signed-off-by: John Snow --- scripts/qapi/gen.py| 2 +- scripts/qapi/parser.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index bf5716b

[PATCH v2 02/11] scripts: qapi: black format main.py

2023-10-16 Thread Victor Toso
flake8 complained: ./main.py:60:1: E302 expected 2 blank lines, found 1 Which is simple enough. My vim has black [0] enabled by default, so it did some extra formatting. I'm proposing to follow it. [0] https://black.readthedocs.io/en/stable/ Signed-off-by: Victor Toso --- scripts

Re: [PATCH v1 7/9] qapi: golang: Generate qapi's command types in Go

2023-10-14 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 03:32:54PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:42PM +0200, Victor Toso wrote: > > This patch handles QAPI command types and generates data structures in > > Go that decodes from QMP JSON Object to Go data structure and

Re: [PATCH v1 5/9] qapi: golang: Generate qapi's union types in Go

2023-10-11 Thread Victor Toso
Hi, On Fri, Sep 29, 2023 at 03:41:27PM +0200, Victor Toso wrote: > Hi, > > On Thu, Sep 28, 2023 at 03:21:59PM +0100, Daniel P. Berrangé wrote: > > On Wed, Sep 27, 2023 at 01:25:40PM +0200, Victor Toso wrote: > > > This patch handles QAPI union types and gener

Re: [PATCH v1 2/9] qapi: golang: Generate qapi's alternate types in Go

2023-10-04 Thread Victor Toso
Hi, On Mon, Oct 02, 2023 at 05:48:37PM -0400, John Snow wrote: > On Fri, Sep 29, 2023 at 8:37 AM Daniel P. Berrangé > wrote: > > > > On Fri, Sep 29, 2023 at 02:23:22PM +0200, Victor Toso wrote: > > > Hi, > > > > > > On Thu, Sep 28, 2023 at 03:51:50P

Re: [PATCH v1 2/9] qapi: golang: Generate qapi's alternate types in Go

2023-10-04 Thread Victor Toso
Hi, On Mon, Oct 02, 2023 at 04:36:11PM -0400, John Snow wrote: > On Wed, Sep 27, 2023 at 7:25 AM Victor Toso wrote: > > > > This patch handles QAPI alternate types and generates data structures > > in Go that handles it. > > > > Alternate types are similar to

Re: [PATCH v1 1/9] qapi: golang: Generate qapi's enum types in Go

2023-10-04 Thread Victor Toso
Hi, On Mon, Oct 02, 2023 at 04:09:29PM -0400, John Snow wrote: > On Mon, Oct 2, 2023 at 3:07 PM John Snow wrote: > > > > On Wed, Sep 27, 2023 at 7:25 AM Victor Toso wrote: > > > > > > This patch handles QAPI enum types and generates its equivalent in Go. >

Re: [PATCH v1 1/9] qapi: golang: Generate qapi's enum types in Go

2023-10-04 Thread Victor Toso
Hi, On Mon, Oct 02, 2023 at 03:07:49PM -0400, John Snow wrote: > On Wed, Sep 27, 2023 at 7:25 AM Victor Toso wrote: > > > > This patch handles QAPI enum types and generates its equivalent in Go. > > > > Basically, Enums are being handled as strings in Golang. > &

Re: [PATCH v1 0/9] qapi-go: add generator for Golang interface

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 02:40:27PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:35PM +0200, Victor Toso wrote: > > Hi, long time no see! > > > > This patch series intent is to introduce a generator that produces a Go > > module for Go applic

Re: [PATCH v1 0/9] qapi-go: add generator for Golang interface

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 02:54:10PM +0100, Daniel P. Berrangé wrote: > On Thu, Sep 28, 2023 at 02:40:27PM +0100, Daniel P. Berrangé wrote: > > On Wed, Sep 27, 2023 at 01:25:35PM +0200, Victor Toso wrote: > > IOW, it would push towards > > > >go-qemu.git > >

Re: [PATCH v1 8/9] qapi: golang: Add CommandResult type to Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 04:03:12PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:43PM +0200, Victor Toso wrote: > > This patch adds a struct type in Go that will handle return values > > for QAPI's command types. > > > > The return value o

Re: [PATCH v1 7/9] qapi: golang: Generate qapi's command types in Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 03:32:54PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:42PM +0200, Victor Toso wrote: > > This patch handles QAPI command types and generates data structures in > > Go that decodes from QMP JSON Object to Go data structure and

Re: [PATCH v1 5/9] qapi: golang: Generate qapi's union types in Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 03:21:59PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:40PM +0200, Victor Toso wrote: > > This patch handles QAPI union types and generates the equivalent data > > structures and methods in Go to handle it. > > > >

Re: [PATCH v1 3/9] qapi: golang: Generate qapi's struct types in Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 03:06:23PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:38PM +0200, Victor Toso wrote: > > This patch handles QAPI struct types and generates the equivalent > > types in Go. The following patch adds extra logic when a member of the &

Re: [PATCH v1 2/9] qapi: golang: Generate qapi's alternate types in Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 03:51:50PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:37PM +0200, Victor Toso wrote: > > This patch handles QAPI alternate types and generates data structures > > in Go that handles it. > > This file (and most others) nee

Re: [PATCH v1 1/9] qapi: golang: Generate qapi's enum types in Go

2023-09-29 Thread Victor Toso
Hi, On Thu, Sep 28, 2023 at 02:52:08PM +0100, Daniel P. Berrangé wrote: > On Wed, Sep 27, 2023 at 01:25:36PM +0200, Victor Toso wrote: > > This patch handles QAPI enum types and generates its equivalent in Go. > > > > Basically, Enums are being handled as strings in Golang.

Re: [PATCH v1 9/9] docs: add notes on Golang code generator

2023-09-29 Thread Victor Toso
27, 2023 at 01:25:44PM +0200, Victor Toso wrote: > > The goal of this patch is converge discussions into a documentation, > > to make it easy and explicit design decisions, known issues and what > > else might help a person interested in how the Go module is generated.

Re: [PATCH v1 0/9] qapi-go: add generator for Golang interface

2023-09-27 Thread Victor Toso
On Wed, Sep 27, 2023 at 01:25:35PM +0200, Victor Toso wrote: > Hi, long time no see! > > This patch series intent is to introduce a generator that produces a Go > module for Go applications to interact over QMP with QEMU. > > This idea was discussed before, as RFC:

[PATCH v1 3/9] qapi: golang: Generate qapi's struct types in Go

2023-09-27 Thread Victor Toso
go: | type BlockdevCreateOptionsFile struct { | Filename string`json:"filename"` | Size uint64`json:"size"` | Preallocation *PreallocMode `json:"preallocation,omitempty"` | Nocow *bool

[PATCH v1 9/9] docs: add notes on Golang code generator

2023-09-27 Thread Victor Toso
The goal of this patch is converge discussions into a documentation, to make it easy and explicit design decisions, known issues and what else might help a person interested in how the Go module is generated. Signed-off-by: Victor Toso --- docs/devel/qapi-golang-code-gen.rst | 341

[PATCH v1 0/9] qapi-go: add generator for Golang interface

2023-09-27 Thread Victor Toso
about my broken python :) Cheers, Victor Victor Toso (9): qapi: golang: Generate qapi's enum types in Go qapi: golang: Generate qapi's alternate types in Go qapi: golang: Generate qapi's struct types in Go qapi: golang: structs: Address 'null' members qapi: golang:

[PATCH v1 1/9] qapi: golang: Generate qapi's enum types in Go

2023-09-27 Thread Victor Toso
| DisplayProtocolVnc DisplayProtocol = "vnc" | DisplayProtocolSpice DisplayProtocol = "spice" | ) Signed-off-by: Victor Toso --- scripts/qapi/golang.py | 140 + scripts/qapi/main.py | 2 + 2 files changed, 142 insertions(+) create m

[PATCH v1 6/9] qapi: golang: Generate qapi's event types in Go

2023-09-27 Thread Victor Toso
uot;data":{"id":"vm0","size":1073741824,"qom-path":"/machine/unattached/device[2]"}}` | e, err := UnmarshalEvent([]byte(input) | if err != nil { | panic(err) | } | if e.GetName() == `MEMORY_DEVICE_SIZE_CHANGE` { | m := e.(*MemoryDevi

[PATCH v1 7/9] qapi: golang: Generate qapi's command types in Go

2023-09-27 Thread Victor Toso
",` + | `"arguments":{"protocol":"vnc",` + | `"password":"secret"}}` | | c, err := UnmarshalCommand([]byte(input)) | if err != nil { | panic(err) | } | | if c.GetName() == `set_password` { | m

[PATCH v1 5/9] qapi: golang: Generate qapi's union types in Go

2023-09-27 Thread Victor Toso
or': 'protocol', | 'data': { 'vnc': 'SetPasswordOptionsVnc' } } go: | type SetPasswordOptions struct { | Protocol DisplayProtocol`json:"protocol"` | Password string `json:"password"` | Connected *Se

[PATCH v1 8/9] qapi: golang: Add CommandResult type to Go

2023-09-27 Thread Victor Toso
e" : "running",` + |`"handle" : 1 } } ` | | ret := QuerySevCommandReturn{} | err := json.Unmarshal([]byte(input), &ret) | if ret.Error != nil { | // Handle command failure {"error": { ...}} | } else if ret.Result

[PATCH v1 4/9] qapi: golang: structs: Address 'null' members

2023-09-27 Thread Victor Toso
s to properly handle these values. - It adds the interface AbsentAlternate() and implement it for any Alternate that can be JSON Null Signed-off-by: Victor Toso --- scripts/qapi/golang.py | 195 ++--- 1 file changed, 184 insertions(+), 11 deletions(

[PATCH v1 2/9] qapi: golang: Generate qapi's alternate types in Go

2023-09-27 Thread Victor Toso
boolean value in a field called IsNull. This will be explained better in the documentation patch of this series but the main rationale is around Marshaling to and from JSON and Go data structures. Example: qapi: | { 'alternate': 'StrOrNull', | 'data': { 's'

[PATCH v3 01/10] qapi: fix example of get-win32-socket command

2023-09-19 Thread Victor Toso
Example output lacks double quotes. Fix it. Fixes: 4cda177c60 "qmp: add 'get-win32-socket'" Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/misc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q

[PATCH v3 09/10] qapi: fix example of query-spice command

2023-09-19 Thread Victor Toso
Example output has a comment embedded in the array. Remove it. The end result is a list of size 2. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé --- qapi/ui.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 006616aa77

[PATCH v3 07/10] qapi: fix example of query-blockstats command

2023-09-19 Thread Victor Toso
Example output has several missing commas. Add them. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/block-core.json | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/qapi/block-core.json b

[PATCH v3 05/10] qapi: fix example of calc-dirty-rate command

2023-09-19 Thread Victor Toso
Example output has property name with single quotes. Fix it. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index

[PATCH v3 02/10] qapi: fix example of dumpdtb command

2023-09-19 Thread Victor Toso
Example output has extra end curly bracket. Switch with comma. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/machine.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/machine.json b/qapi/machine.json index

[PATCH v3 10/10] qapi: scripts: add a generator for qapi's examples

2023-09-19 Thread Victor Toso
into "sequence-order". A language binding project can then consume this files to Marshal and Unmarshal, comparing if the results are what is to be expected. RFC discussion: https://lists.gnu.org/archive/html/qemu-devel/2022-08/msg04641.html Signed-off-by: Victor Toso --- scripts/qapi

[PATCH v3 06/10] qapi: fix example of NETDEV_STREAM_CONNECTED event

2023-09-19 Thread Victor Toso
Example output was using single quotes. Fix it. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/net.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index 313c8a606e..81988e499a

[PATCH v3 04/10] qapi: fix example of set-vcpu-dirty-limit command

2023-09-19 Thread Victor Toso
Example output has extra end curly bracket. Remove it. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index

[PATCH v3 03/10] qapi: fix example of cancel-vcpu-dirty-limit command

2023-09-19 Thread Victor Toso
Example output has extra end curly bracket. Remove it. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé Reviewed-by: Markus Armbruster --- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index

[PATCH v3 08/10] qapi: fix example of query-rocker-of-dpa-flows command

2023-09-19 Thread Victor Toso
Example output has a comment embedded in the array. Remove it. The end result is a list of size 1. Signed-off-by: Victor Toso Reviewed-by: Daniel P. Berrangé --- qapi/rocker.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qapi/rocker.json b/qapi/rocker.json index

[PATCH v3 00/10] Validate and test qapi examples

2023-09-19 Thread Victor Toso
in self.schema._entity_dict) obj = self.schema._entity_dict[name] + +if not obj.info.pragma.doc_required: +return + assert((obj.doc is not None)) module_name = obj._module.name which avoid failures with tests that don't have any docs. Ch

Re: [PATCH v1 0/7] Validate and test qapi examples

2023-09-14 Thread Victor Toso
Hi, On Fri, Sep 08, 2023 at 09:51:35AM +0200, Philippe Mathieu-Daudé wrote: > On 7/9/23 20:17, Victor Toso wrote: > > Hi, > > > >File "/home/berrange/src/virt/qemu/scripts/qapi/dumpexamples.py", line > > > 118, in parse_examples_o

Re: [PATCH v2 07/11] qapi: fix example of query-rocker-of-dpa-flows command

2023-09-14 Thread Victor Toso
Hi, On Thu, Sep 14, 2023 at 03:50:23PM +0200, Markus Armbruster wrote: > Victor Toso writes: > > > Example output has a comment embedded in the array. Remove it. > > The end result is a list of size 1. > > > > Signed-off-by: Victor Toso > > --- > > qa

[PATCH v2 10/11] qapi: meson: add test flag to allow skip generators

2023-09-11 Thread Victor Toso
The next patch adds a generator that also validates qapi documentation. We don't want to execute it with a test schema. Signed-off-by: Victor Toso --- scripts/qapi/main.py | 4 tests/meson.build| 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/main

[PATCH v2 11/11] qapi: scripts: add a generator for qapi's examples

2023-09-11 Thread Victor Toso
into "sequence-order". A language binding project can then consume this files to Marshal and Unmarshal, comparing if the results are what is to be expected. RFC discussion: https://lists.gnu.org/archive/html/qemu-devel/2022-08/msg04641.html Signed-off-by: Victor Toso --- scripts/qapi

Re: [PATCH v2 10/11] qapi: meson: add test flag to allow skip generators

2023-09-11 Thread Victor Toso
2023 at 01:13:23PM +0200, Victor Toso wrote: > The next patch adds a generator that also validates qapi > documentation. We don't want to execute it with a test schema. > > Signed-off-by: Victor Toso > --- > scripts/qapi/main.py | 4 > tests/meson.build| 2 +- &g

  1   2   3   >