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

qmp: add Monitor which uses cgo bindings to interact with libvirt

Open mdlayher opened this issue 8 years ago • 4 comments

The libvirt-go cgo bindings will likely provide the best stability and error handling capabilities for interacting with libvirt, so we should add the ability to use them. They must be guarded by a build tag.

If built without the tag, all cgo operations will return error stubs.

mdlayher avatar May 02 '16 14:05 mdlayher

I've been looking into this issue and here is one idea on addressing the build tag guard. I thought about creating 3 files like so: libvirtgo.go (this file contains implementation methods entry point for Monitor, etc... It will call the correct implementation method based on the GOOS where it's built)

libvirtgo_linux.go (this file contains the calls to libvirt-go package)

libvirtgo_others.go [build tag: // +build !linux](this file contains operations returning error stubs) Of course, there will be *_test.go files with the corresponding tests.

Does this make sense?

robertojrojas avatar Oct 11 '16 22:10 robertojrojas

Yep, seems reasonable to me. I'm happy as long as it compiles on all platforms, even if every method returns an error when not running on Linux.

mdlayher avatar Oct 12 '16 13:10 mdlayher

I'm getting closer to a PR for this issue. As for the dependency to the libvirt-go package, would Go 1.5+ vendoring suffice?

robertojrojas avatar Oct 17 '16 01:10 robertojrojas

Since we are providing packages and not an application, we don't explicit vendor our dependencies. Importing it without vendoring is fine, especially because both repositories belong to DigitalOcean.

mdlayher avatar Oct 17 '16 02:10 mdlayher