go-qemu
go-qemu copied to clipboard
qmp: add Monitor which uses cgo bindings to interact with libvirt
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.
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?
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.
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?
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.