go-libvirt
go-libvirt copied to clipboard
Support for modular libvirt daemons
Currently the socket is defined as a variable here https://github.com/digitalocean/go-libvirt/blob/15feff002086ca5276717d866e19ebf9e082f343/socket/dialers/local.go#L10
so it only works with Monolithic daemon mode (libvirtd) and not the Modular daemons mode (virtqemud, virtstoraged,...).
Ref: https://libvirt.org/daemons.html
Are you able to connect to the modular sockets with the dialers package? Something like this:
dialer := dialers.NewLocal(dialers.WithSocket("/var/run/libvirt/virtqemud"))
lv := libvirt.NewWithDialer(dialer)
err := lv.Connect()
defer lv.Disconnect()
Sorry that I'm not familiar with Go. I modified the snippet above a little:
package main
import (
"github.com/digitalocean/go-libvirt"
"github.com/digitalocean/go-libvirt/socket/dialers"
"github.com/sirupsen/logrus"
)
func main() {
dialer := dialers.NewLocal(dialers.WithSocket("/var/run/libvirt/virtqemud-sock"))
lv := libvirt.NewWithDialer(dialer)
if err := lv.Connect(); err != nil {
logrus.Fatal(err)
}
defer lv.Disconnect()
}
Running it with go run main.go
doesn't return any errors (and it returns 0) so I guess it connects successfully.
What I want to ask here is to support dynamic socket. So instead of relying on 1 defined socket, we can detect which modular socket we need to connect to based on the API call.
On a normal system, 1 modular daemon alone is kind of useless, but also people might not want to enable libvirtd
as they don't use all libvirt features.
Ah, I see. That makes sense. I can't promise this will get done in the near future, but if someone else beats one of us and submits patches, I'm happy to review them.
Thanks for filing this feature request :slightly_smiling_face: