go-qemu icon indicating copy to clipboard operation
go-qemu copied to clipboard

qmp: API codegen based on QMP schema

Open danderson opened this issue 8 years ago • 4 comments

For my own uses, I'm in the middle of writing a go generate codegen to transform the QMP API spec (qapi-schema.json) into reasonably idiomatic Go code. Would you be interested in a contribution of this autogen and resulting API?

Depending on how idiomatic I'm able to make it (the API is pretty rough in places), we could make it a subpackage and allow the main qmp library to use either higher level types that wrap the raw ones, or the raw ones directly if the user needs to use a feature that hasn't been exposed. My aspirational goal is to make the autogenerated bindings good enough that this isn't necessary, but of course that's hard :).

danderson avatar Sep 23 '16 17:09 danderson

Sounds excellent to me. I like the approach of generating a subpackage and then wrapping it with cleaner types. We actually have #97 open to do some of that work anyway.

Please do let us know what you come up with!

CC @benlemasurier

mdlayher avatar Sep 23 '16 17:09 mdlayher

I've got a WIP here: https://github.com/danderson/go-qemu/tree/master/internal/qmp-gen

The code is still very much in flux, exploratory programming and all that. A sample of the current output is in https://github.com/danderson/go-qemu/blob/master/internal/qmp-gen/autogen .

I'll send another update when the code is actually able to speak QMP to an active connection, at that point we can decide if the generated API has the right shape, and if/how you'd like to incorporate it.

danderson avatar Sep 27 '16 04:09 danderson

This looks very cool. I'm excited to see what you come up with!

mdlayher avatar Sep 27 '16 14:09 mdlayher

@danderson we just created #go-qemu on freenode if you're interested in joining us on IRC to discuss this more!

mdlayher avatar Oct 04 '16 16:10 mdlayher

This has been merged since 6edbae9940961a9f61d3fc0aa3d518ba372168db.

connorkuehl avatar Dec 09 '22 15:12 connorkuehl