dhiltgen / docker-machine-kvm

KVM driver for docker-machine
Apache License 2.0
376 stars 111 forks source link

Configurable connection URI #35

Open tn-osimis opened 7 years ago

tn-osimis commented 7 years ago

Sifting through the code I gather the connection URI is not configurable.

const (
        connectionString   = "qemu:///system"
func (d *Driver) getConn() (*libvirt.Connect, error) {
        if d.conn == nil {
                conn, err := libvirt.NewConnect(connectionString)

I need to use a different URI (e.g. qemu:///session). I think a driver parameter would be appropriate here. Alternatively, passing an empty string to libvirt.NewConnect would have libvirt select the default connection and let the user configure it themselves.

func NewConnect(uri string) (*Connect, error) {
        var cUri *C.char
        if uri != "" {
                cUri = C.CString(uri)
                defer C.free(unsafe.Pointer(cUri))
        }
        ptr := C.virConnectOpen(cUri)

virConnectOpen: https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen

bersace commented 7 years ago

I totally agree with this. That's now easy to have user QEMU thanks to qemu-bridge-helper. We need only two params : the connection string (use the session) and the bridge to use (instead of a libvirt network).

This will avoid a password prompt and make it more secure. Also, this will help isolate dév env in dév home.

🆙 👍 Thanks for the report.

@dhiltgen do you want help on this topic ?

bersace commented 7 years ago

Actually, in my setup, I simply use the same bridge as for my lxc containers:

   <interface type='bridge'>
     <mac address='52:54:00:a5:a2:78'/>
     <source bridge='lxcbr0'/>
     <model type='rtl8139'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>

Here is how i setup qemu-bridge-helpers on debian: https://github.com/bersace/dotfiles/blob/master/virtualisation.yml#L58-L79

karmab commented 7 years ago

addressed by PR https://github.com/dhiltgen/docker-machine-kvm/pull/63