Giter Club home page Giter Club logo

docker-machine-kvm's Introduction

docker-machine-kvm

KVM driver for docker-machine

This driver leverages the new plugin architecture being developed for Docker Machine.

Quick start instructions

  • Install libvirt and qemu-kvm on your system (e.g., sudo apt-get install libvirt-bin qemu-kvm)
    • Add yourself to the libvirtd group (may vary by linux distro) so you don't need to sudo
  • Install docker-machine
  • Go to the releases page and download the docker-machine-driver-kvm binary, putting it in your PATH.
  • You can now create virtual machines using this driver with docker-machine create -d kvm myengine0.

Dependencies

This driver leverages libvirt and the libvirt-go library to create and manage KVM based virtual machines. It has been tested with Ubuntu 12.04 through 15.04 and should work on most platforms with KVM/libvirt support. If you run into compatibility problems, please file an issue.

Typically you'll run docker-machine as yourself, so you'll want to follow your distro specific instructions on allowing libvirt access from your account. For most distro's, you accomplish this by adding your account to the libvirtd group.

Capabilities

Images

By default docker-machine-kvm uses a boot2docker.iso as guest os for the kvm hypervisior. It's also possible to use every guest os image that is derived from boot2docker.iso as well. For using another image use the --kvm-boot2docker-url parameter.

Community Members did some tests and it works with rancher/os as guest os too.

Dual Network

  • eth1 - A host private network called docker-machines is automatically created to ensure we always have connectivity to the VMs. The docker-machine ip command will always return this IP address which is only accessible from your local system.
  • eth0 - You can specify any libvirt named network. If you don't specify one, the "default" named network will be used.
    • If you have exotic networking topolgies (openvswitch, etc.), you can use virsh edit mymachinename after creation, modify the first network definition by hand, then reboot the VM for the changes to take effect.
    • Typically this would be your "public" network accessible from external systems
    • To retrieve the IP address of this network, you can run a command like the following:
    docker-machine ssh mymachinename "ip -one -4 addr show dev eth0|cut -f7 -d' '"

Driver Parameters

Here are all currently driver parameters listed that you can use.

Parameter Description
--kvm-cpu-count Sets the used CPU Cores for the KVM Machine. Defaults to 1 .
--kvm-disk-size Sets the kvm machine Disk size in MB. Defaults to 20000 .
--kvm-memory Sets the Memory of the kvm machine in MB. Defaults to 1024.
--kvm-network Sets the Network of the kvm machinee which it should connect to. Defaults to default.
--kvm-boot2docker-url Sets the url from which host the image is loaded. By default it's not set.
--kvm-cache-mode Sets the caching mode of the kvm machine. Defaults to default.
--kvm-io-mode-url Sets the disk io mode of the kvm machine. Defaults to threads.

docker-machine-kvm's People

Contributors

aaron-prindle avatar caiobegotti avatar dhiltgen avatar dpw avatar flavio avatar makuk66 avatar mikefaille avatar r2d4 avatar rsampaio avatar solidnerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-machine-kvm's Issues

dial tcp: missing address

Hi,

When I run the create command :

$ docker-machine create -d kvm dockerhans1

I get an error : dial tcp: missing address

When I run the same command as root it works fine.

Any ideas ?

(myengine0) Failed to decode dnsmasq lease status: unexpected end of JSON input

docker version 1.9.1
docker-machine 0.5.6 and 0.6.0+

docker-machine create -d lvm myengine0

NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
myengine0 * kvm Running Unknown unexpected end of JSON input

docker-machine ls

NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
myengine0 - kvm Running tcp://192.168.42.44:2376 Unknown Unable to query docker version: Unable to read TLS config: open /root/.docker/machine/machines/myengine0/server.pem: no such file or directory

Thoughts?

Configurable connection URI

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

Allow setting the CPU model OR enabling nesting

Sometimes - like with kubevirt we are running VMs with kubernetes. In that context we'd like to allow nesting, this requires libvirtd to use <cpu mode='host-model'> for the (minikube) VM.

It would be nice if there was a way to enable this.

Machine Creation: Network not found

Hello and thanks for working on this driver ๐Ÿ˜„

When trying to create a machine with docker-machine create -d kvm default the kvm driver prints the following error message:

$ docker-machine create -d kvm default
Running pre-create checks...
Error with pre-create check: "[Code-43] [Domain-19] Network not found: no network with matching name 'default'"

It seems the driver doesn't (maybe cannot) create a network for the virtual machine, but still expects it.

I am running Fedora 24 with

  • libvirt 1.3.3.2
  • qemu-kvm 2.6.1
  • docker-machine 0.8.1, build 41b3b25
  • docker-machine-driver-kvm 0.7.0

Unable to run on CentOS

$ cat /etc/issue
CentOS release 6.7 (Final)
Kernel \r on an \m
$ uname -a
Linux <snip> 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 06:42:08 PST 2015 x86_64 x86_64 x86_64 GNU/Linux
$ bin/docker-machine-driver-kvm 
bin/docker-machine-driver-kvm: /usr/lib64/libvirt.so.0: version `LIBVIRT_1.1.1' not found (required by bin/docker-machine-driver-kvm)
bin/docker-machine-driver-kvm: /usr/lib64/libvirt.so.0: version `LIBVIRT_1.0.2' not found (required by bin/docker-machine-driver-kvm)
$ libvirtd --version
libvirtd (libvirt) 0.10.2

Any other info I need to provide in order to isolate issue?

For sure, I know that true way to use this driver is to issue following command, but it doesn't work either:

$ docker-machine create -d kvm myengine0
Error loading driver "kvm": dial tcp: missing address

dial tcp: missing address

Error while creating KVM-based machine using docker-machine 0.6.0

$ docker-machine create --driver kvm -v node01
dial tcp: missing address

Using v0.6.0 for both kvm plugin and docker-machine on Linux Mint 17.3 (based on Ubuntu 14.04.4).

Is there anything else I should specify or is this a bug?

Permission problems when creating VM on Slackware

I intend to publish Slackware build script for docker-machine-kvm so that other Slackware users could benefit from it. I have the script written, but I'm experiencing permission problems when trying to use docker-machine-kvm.

docker-machine version is 0.11.0, libvirt is 3.2.0, qemu is 2.8.1. libvirt is built using --with-qemu-group=users, in /etc/libvirt/qemu.conf group is set to users as well, the line where user is set is commented. qemu is built to set /dev/kvm group to users. Let me know if you need additional information.

When trying to create VM the following happens:

$ docker-machine -D create -d kvm myvm1         
Docker Machine Version:  0.11.0, build 5b27455
Found binary path at /usr/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:35505
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(flag-lookup) Calling .GetMachineName
(flag-lookup) Calling .DriverName
(flag-lookup) Calling .GetCreateFlags
Found binary path at /usr/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:37091
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(myvm1) Calling .GetMachineName
(myvm1) Calling .DriverName
(myvm1) Calling .GetCreateFlags
(myvm1) Calling .SetConfigFromFlags
(myvm1) DBG | SetConfigFromFlags called
Running pre-create checks...
(myvm1) Calling .PreCreateCheck
(myvm1) DBG | About to check libvirt version
(myvm1) DBG | Validating private network
(myvm1) DBG | Validating network default
(myvm1) Calling .GetConfigRaw
Creating machine...
(myvm1) Calling .Create
(myvm1) DBG | local Boot2Docker ISO version:  v17.05.0-ce
(myvm1) Copying /home/audrius/.docker/machine/cache/boot2docker.iso to /home/audrius/.docker/machine/machines/myvm1/boot2docker.iso...
(myvm1) Creating SSH key...
(myvm1) DBG | Verifying executable bit set on /home/audrius/.docker/machine/machines/myvm1
(myvm1) DBG | Setting executable bit set on /home/audrius/.docker/machine/machines/myvm1
(myvm1) DBG | Verifying executable bit set on /home/audrius/.docker/machine/machines
(myvm1) DBG | Verifying executable bit set on /home/audrius/.docker/machine
(myvm1) DBG | Verifying executable bit set on /home/audrius/.docker
(myvm1) DBG | Verifying executable bit set on /home/audrius
(myvm1) DBG | Verifying executable bit set on /home
(myvm1) DBG | Creating VM data disk...
(myvm1) DBG | Creating 20000 MB hard disk image...
(myvm1) DBG | Defining VM...
(myvm1) DBG | Starting VM myvm1
(myvm1) Failed to start: virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: 2017-05-27T17:30:39.454975Z qemu-kvm: -drive file=/home/audrius/.docker/machine/machines/myvm1/myvm1.img,format=raw,if=none,id=drive-ide0-0-0,aio=threads: Could not open '/home/audrius/.docker/machine/machines/myvm1/myvm1.img': Permission denied')
Error creating machine: Error in driver during machine creation: virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: 2017-05-27T17:30:39.454975Z qemu-kvm: -drive file=/home/audrius/.docker/machine/machines/myvm1/myvm1.img,format=raw,if=none,id=drive-ide0-0-0,aio=threads: Could not open '/home/audrius/.docker/machine/machines/myvm1/myvm1.img': Permission denied')
notifying bugsnag: [Error creating machine: Error in driver during machine creation: virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: 2017-05-27T17:30:39.454975Z qemu-kvm: -drive file=/home/audrius/.docker/machine/machines/myvm1/myvm1.img,format=raw,if=none,id=drive-ide0-0-0,aio=threads: Could not open '/home/audrius/.docker/machine/machines/myvm1/myvm1.img': Permission denied')]

The permissions of VM files:

$ ls -l ~/.docker/machine/machines/myvm1/
total 39960
-rw------- 1 root    users    40894464 May 27 20:30 boot2docker.iso
-rw------- 1 audrius users        2685 May 27 20:30 config.json
-rw------- 1 audrius users        1679 May 27 20:30 id_rsa
-rw------- 1 audrius users         381 May 27 20:30 id_rsa.pub
-rw-r--r-- 1 root    root  20971520000 May 27 20:30 myvm1.img

I've found that the only way to make it work is to set user to myself (audrius) and group to users in /etc/libvirt/qemu.conf, but setting it like this causes permission problems with existing regular VMs in /var/lib/libvirt/images/ and doesn't feel right in general.

Unexpected JSON Output

I tried to use the latest released version with docker-machine, and I am getting this error. I am not deeply familiar with KVM or libvirt, so I am not sure how this works. I have libvirt working fine with vagrant and mini-kube (using their embedded kvm2 docker-machine driver) without any problems. I am not sure how I could debug further.

$ docker-machine -D create -d kvm myengine1
Docker Machine Version:  0.16.2, build bd45ab13
Found binary path at /usr/local/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:41571
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(flag-lookup) Calling .GetMachineName
(flag-lookup) Calling .DriverName
(flag-lookup) Calling .GetCreateFlags
Found binary path at /usr/local/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:45025
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(myengine1) Calling .GetMachineName
(myengine1) Calling .DriverName
(myengine1) Calling .GetCreateFlags
(myengine1) Calling .SetConfigFromFlags
(myengine1) DBG | SetConfigFromFlags called
Reading certificate data from /home/joaquin/.docker/machine/certs/ca.pem
Decoding PEM data...
Parsing certificate...
Reading certificate data from /home/joaquin/.docker/machine/certs/cert.pem
Decoding PEM data...
Parsing certificate...
Running pre-create checks...
(myengine1) Calling .PreCreateCheck
(myengine1) DBG | About to check libvirt version
(myengine1) DBG | Validating private network
(myengine1) DBG | Validating network default
(myengine1) Calling .GetConfigRaw
Creating machine...
(myengine1) Calling .Create
(myengine1) DBG | local Boot2Docker ISO version:  v19.03.12
(myengine1) Copying /home/joaquin/.docker/machine/cache/boot2docker.iso to /home/joaquin/.docker/machine/machines/myengine1/boot2docker.iso...
(myengine1) Creating SSH key...
(myengine1) DBG | Verifying executable bit set on /home/joaquin/.docker/machine/machines/myengine1
(myengine1) DBG | Setting executable bit set on /home/joaquin/.docker/machine/machines/myengine1
(myengine1) DBG | Verifying executable bit set on /home/joaquin/.docker/machine/machines
(myengine1) DBG | Verifying executable bit set on /home/joaquin/.docker/machine
(myengine1) DBG | Verifying executable bit set on /home/joaquin/.docker
(myengine1) DBG | Verifying executable bit set on /home/joaquin
(myengine1) DBG | Verifying executable bit set on /home
(myengine1) DBG | Creating VM data disk...
(myengine1) DBG | Creating 20000 MB hard disk image...
(myengine1) DBG | Defining VM...
(myengine1) DBG | Starting VM myengine1
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 0
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 1
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 2
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 3
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 4
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 5
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 6
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 7
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 8
(myengine1) DBG | GetIP called for myengine1
(myengine1) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine1) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine1) DBG | Unable to locate IP address for MAC 52:54:00:d2:f1:a0
(myengine1) DBG | Waiting for the VM to come up... 9

There's no such file /var/lib/libvirt/dnsmasq/docker-machines.leases.

$ ls -la /var/lib/libvirt/dnsmasq
total 24
drwxr-xr-x 2 root root 4096 Oct 11 03:46 .
drwxr-xr-x 7 root root 4096 Oct 11 02:00 ..
-rw-r--r-- 1 root root    0 Oct 11 02:01 default.addnhosts
-rw------- 1 root root  619 Oct 11 02:01 default.conf
-rw-r--r-- 1 root root    0 Oct 11 02:01 default.hostsfile
-rw-r--r-- 1 root root    0 Oct 11 03:25 docker-machines.addnhosts
-rw------- 1 root root  688 Oct 11 03:25 docker-machines.conf
-rw-r--r-- 1 root root    0 Oct 11 03:25 docker-machines.hostsfile
-rw-r--r-- 1 root root   85 Oct 11 03:46 virbr0.macs
-rw-r--r-- 1 root root    0 Oct 11 01:02 virbr0.status
-rw-r--r-- 1 root root   85 Oct 11 03:46 virbr1.macs
-rw-r--r-- 1 root root    0 Oct 11 03:25 virbr1.status

login and security

hi there

we use qemu-kvm, and happy with docker-machine with qemu in my notebook

we want to make kvm in our server, any idea to use this driver? we cant find how to login or use security to create a vm outside machine remotely

Error to load plugin with 0.0.5

Hello, i've diownloaded your 0.0.5 release and have tried to test it with d-m 0.0.5 but i get :

$ docker-machine create --driver kvm --help
Error loading driver "kvm": dial tcp: missing address

Any idea ?

Thanks
Anthony.

Default domain settings lead to >25% CPU usage, fix proposed

Hello! The current domain XML you are using for the KVM driver does not specify a CPU mode, which makes things very slow and usually lead to a constant >25% CPU usage for people using your driver with Kubernetes and Minikube. The proposed fix below solves this as it simply tells KVM to use everything the host supports and emulate whatever else is needed, so now your driver is at 0.0% of CPU usage and instead of being the 1st process in top it is now the 721st :-)

See http://wiki.qemu.org/Features/CPUModels#-cpu_host_and_feature_probing for more info. CPU host mode is usually safe and recommended for scenarios like the ones your driver is used for. The only limitation (which I suspect is not a big deal here) is that if you do KVM migrations between hosts of different CPUs models all the time.

diff --git a/kvm.go b/kvm.go
index f843ad0..7a1a9e2 100644
--- a/kvm.go
+++ b/kvm.go
@@ -35,6 +35,7 @@ const (
   <name>{{.MachineName}}</name> <memory unit='M'>{{.Memory}}</memory>
   <vcpu>{{.CPU}}</vcpu>
   <features><acpi/><apic/><pae/></features>
+  <cpu mode='host-passthrough'></cpu>
   <os>
     <type>hvm</type>
     <boot dev='cdrom'/>

If you are still suspicious about the fix, accepting a CPU mode via an option/parameter would solve it for people having performance issues with your driver, I think.

Add support for arm64

Hello we are trying to run docker-machine-kvm on arm64 and we are getting the following error

 Unexpected enum value 0 for virDomainDeviceAddressType

we found something similar here kubevirt/kubevirt#2470. It seems to be related to having hardcoded the architecture somewhere but honestly no idea ๐Ÿคทโ€โ™‚๏ธ, just doing my best guess.

Unable to remove failed machine

$ docker-machine rm test
About to remove test
Are you sure? (y/n): y
(test) Failed to fetch machine
Error removing host "test": unexpected EOF

This machine was built but virtlogd wasn't running... crickey!

$ docker-machine create -d kvm test
Running pre-create checks...
Creating machine...
(test) Copying /home/yoan/.docker/machine/cache/boot2docker.iso to /home/yoan/.docker/machine/machines/test/boot2docker.iso...
(test) Failed to start: [Code-38] [Domain-7] Failed to connect socket to '/var/run/libvirt/virtlogd-sock': Aucun fichier ou dossier de ce type
Error creating machine: Error in driver during machine creation: [Code-38] [Domain-7] Failed to connect socket to '/var/run/libvirt/virtlogd-sock': Aucun fichier ou dossier de ce type

Do you have any clue how I whould properly delete it? I've already deleted them from virt-manager.

Cheers and thanks for this amazing plugin!

Error E0422 when starting minishift on SuSE leap.

Environment:
SuSE Leap 15.2 on intel hardware.
Fresh installation of minishift (binary downloaded from github).
kvm and libvirt the ones supplied with the OS.
docker machine and docker_machine_driver_kvm came from an extra OpenSuse repository called 'Virtualisation Containers'. - the docker_machine_driver_kvm is identical to the centos7 one in github.
I followed the instructions for setting up the environment from here: https://docs.okd.io/3.11/minishift/getting-started/setting-up-virtualization-environment.html#for-linux.

I got the following output when running minishift start:
-- Starting Minishift VM ..... FAIL E0422 17:12:52.630115 10016 start.go:499] Error starting the VM: Error creating the VM. Error creating machine: Error in driver during machine creation: virError(Code=38, Domain=7, Message='End of file while reading data: Input/output error'). Retrying.
Error starting the VM: Error creating the VM. Error creating machine: Error in driver during machine creation: virError(Code=38, Domain=7, Message='End of file while reading data: Input/output error')

Subsequent attempts to start return this:
-- Starting profile 'minishift'
-- Check if deprecated options are used ... OK
-- Checking if https://github.com is reachable ... OK
-- Checking if requested OpenShift version 'v3.11.0' is valid ... OK
-- Checking if requested OpenShift version 'v3.11.0' is supported ... OK
-- Checking if requested hypervisor 'kvm' is supported on this platform ... OK
-- Checking if KVM driver is installed ...
Driver is available at /usr/local/bin/docker-machine-driver-kvm ...
Checking driver binary is executable ... OK
-- Checking if Libvirt is installed ... OK
-- Checking if Libvirt default network is present ... OK
-- Checking if Libvirt default network is active ... OK
-- Checking the ISO URL ... OK
-- Checking if provided oc flags are supported ... OK
-- Starting the OpenShift cluster using 'kvm' hypervisor ...
-- Starting Minishift VM .... FAIL E0422 17:41:15.974634 12836 start.go:499] Error starting the VM: Error getting the state for host: unexpected EOF. Retrying.
Error starting the VM: Error getting the state for host: unexpected EOF

Have I missed something or is this a genuine issue?

Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases

Versioning information:

OS: SUSE Linux Enterprise Server 12 Patch 1

virsh version
Compiled against library: libvirt 1.2.18
Using library: libvirt 1.2.18
Using API: QEMU 1.2.18
Running hypervisor: QEMU 2.3.1

dnsmasq --version
Dnsmasq version 2.76 Copyright (c) 2000-2016 Simon Kelley
Compile time options: IPv6 GNU-getopt no-DBus i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify

docker-machine --version
docker-machine version 0.12.2, build 9371605

docker-machine-driver-kvm version v0.10.0

When running:

docker-machine -D create -d "kvm" default

I get the following:

(default) DBG | Creating VM data disk...
(default) DBG | Creating 20000 MB hard disk image...
(default) DBG | Defining VM...
(default) DBG | Starting VM default
(default) DBG | GetIP called for default
(default) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(default) Failed to decode dnsmasq lease status: unexpected end of JSON input
(default) DBG | Unable to locate IP address for MAC 52:54:00:6c:d5:d8

As can be seen the ISO downloads and the VM starts. I can see the VM in virt-manager and also connect to it. The lease failure repeats until it times out. I have no /var/lib/libvirt/dnsmasq/docker-machines.leases file present. The assumption is that the failure is because that file is missing but what is supposed to be creating that file in the process and any idea why it isn't being automatically created? Using virsh net-dumpxml I can see "docker-machines" and it has the following configuration:

docker-machines 221c842f-27b9-4b17-83d2-f9233971bb9e

Using virsh net-list it shows with an active state.

`docker-machine create -d kvm` fails with: Failed to Start network: [Code-1] [Domain-59] internal error: Failed to initialize a valid firewall backend

Given the success on Ubuntu I'm wondering if I just have something environmental that may be causing this problem.

Command + output:

$ docker-machine create -d kvm myengine0
Creating CA: /home/me/.docker/machine/certs/ca.pem
Creating client certificate: /home/me/.docker/machine/certs/cert.pem
Running pre-create checks... (myengine0) Failed to Start network: [Code-1] [Domain-59] internal error: Failed to initialize a valid firewall backend
Error with pre-create check: "[Code-1] [Domain-59] internal error: Failed to initialize a valid firewall backend"

Environment:

  • Arch Linux, 4.6.4-1 x86_64 kernel
  • libvirt 2.0.0-1
  • docker-machine 0.7.0
  • ~/bin/docker-machine-driver-kvm 0.7.0 and is in my PATH
  • User is in the libvirt group, libvirtd is running

Please let me know if there is any other information I can provide.

Please include a LICENSE

Hey,

I'd like to submit some PRs to this repo, but my employer requires that you have a LICENSE defined. Would you mind choosing one and including it in the root of the repo?

Diver Parameter --kvm-network "Network not found"

Hey there,

i tried your kvm driver for docker-machine. The machine will be created if i use the cmd "docker-machine create -d kvm foobar"

but i want to add a bridged network to the vm at the creation step.
i used the --kvm-network parameter for my bridged network on the host (this bridged network is working with virtualbox)

but if i run this
cmd "docker-machine create --kvm-network br1 -d kvm foobar"
following error appears
Error with pre-create check: "[Code-43] [Domain-19] Network not found: no network with matching name 'br1'"

any idea?

Suddenly malfunctioning driver: Failed to retrieve dnsmasq leases

So this is a solution rather than an issue. However I ran into this issue, without that I have changed anything about my infrastructure. I use this in combination with gitlab-runner and it suddenly failed to start my vms and got stuck on getting an IP.

To the logs it would write something like:

Failed to retrieve dnsmasq lease

Do not have all logs here anymore, however, the solution to this is: downgrade the boot2docker version, by specifiying an older one. I.e. the 17.03. For some reason new boot2docker version fail to boot correctly, probably the docker team changed there a lot of things how boot2docker works recently.

To set this you need to set the kvm-boot2docker-url variable to another iso. I set for example: "kvm-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v17.03.1-ce/boot2docker.iso"

After that everything should work as expected again.

Can't start a VM till the lease expires

I'm using Minikube with KVM through libvirt. Every time I stop the VM (which is the Minikube cluster's VM), I can't start it till the lease is expired.

Here is some detail:

Minikube version: v0.17.1
Environment:

  • OS: Ubuntu 16.04.2 LTS (Xenial Xerus)
  • VM Driver: KVM, libvirtd (libvirt) 1.3.1
  • VM image: ~/.minikube/machines/minikube/boot2docker.iso

What happened:
Whether or not the Minikube cluster's VM is properly stopped, I can't start it until the DHCP lease is expired.

~$ minikube start --vm-driver="kvm" --insecure-registry=192.168.42.22:80 --logtostderr --v=7
Starting local Kubernetes cluster...
Starting VM...
I0411 17:29:13.318825   12960 cluster.go:67] Machine exists!
Found binary path at /usr/local/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Plugin server listening at address 127.0.0.1:44304
() Calling .GetVersion
Using API Version  1
() Calling .SetConfigRaw
() Calling .GetMachineName
(minikube) Calling .GetState
(minikube) DBG | Getting current state...
(minikube) DBG | Fetching VM...
I0411 17:29:13.332112   12960 cluster.go:74] Machine state:  Stopped
(minikube) Calling .Start
(minikube) DBG | Starting VM minikube
(minikube) DBG | GetIP called for minikube
(minikube) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(minikube) DBG | IP address: 192.168.42.11
(minikube) DBG | Unable to locate IP address for MAC 52:54:00:37:5b:48
(minikube) Calling .GetConfigRaw
Waiting for SSH to be available...
Getting to WaitForSSH function...
(minikube) Calling .GetSSHHostname
(minikube) DBG | GetIP called for minikube
(minikube) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(minikube) DBG | IP address: 192.168.42.11
(minikube) DBG | Unable to locate IP address for MAC 52:54:00:37:5b:48
(minikube) Calling .GetSSHPort
(minikube) Calling .GetSSHKeyPath
(minikube) Calling .GetSSHKeyPath
(minikube) DBG | AK: resolvestorepath: /home/amir/.minikube
(minikube) DBG | AK: resolvestorepath: /home/amir/.minikube
(minikube) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /home/amir/.minikube/machines/minikube/id_rsa (-rw-------)
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i /home/amir/.minikube/machines/minikube/id_rsa -p 22] /usr/bin/ssh <nil>}
About to run SSH command:
exit 0
SSH cmd err, output: exit status 255: 
Error getting ssh command 'exit 0' : Something went wrong running an SSH command!
command : exit 0
err     : exit status 255
output  :

It seems that this driver can't find the right lease file. That's the only error I see.

What you expected to happen:

Find the correct lease file and start without an error.

How to reproduce it:

  • Start minikube with KVM.
  • Stop it.
  • Try to start it before lease is expired. I don't know what the default expiry time is. But try to start it right after.

Additional info:

https://bugzilla.redhat.com/show_bug.cgi?id=1228631

It seems that libvirt is changed to read lease records from custom made files (named after interface). But I think you already knew that.

Unable to start VM through docker-machine in KVM in CentOS 7

Hi,

I am getting some error while creating VM through docker-machine in KVM in CentOS 7.

[budhram@localhost ~]$ docker-machine -D create -d kvm default
Docker Machine Version:  0.8.2, build e18a919
Found binary path at /usr/local/bin/docker-machine-driver-kvm
Launching plugin server for driver kvm
Error attempting to get plugin server address for RPC: Failed to dial the plugin server in 10s

Other details

[budhram@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


[budhram@localhost ~]$ sudo systemctl status libvirtd
โ— libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2016-12-13 20:49:06 IST; 56min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 9495 (libvirtd)
   Memory: 0B
   CGroup: /system.slice/libvirtd.service
           โ”œโ”€2286 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           โ”œโ”€2287 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
           โ””โ”€9495 /usr/sbin/libvirtd

Dec 13 20:49:06 localhost.localdomain systemd[1]: Starting Virtualization daemon...
Dec 13 20:49:06 localhost.localdomain systemd[1]: Started Virtualization daemon.
Dec 13 20:49:06 localhost.localdomain dnsmasq[2286]: read /etc/hosts - 2 addresses
Dec 13 20:49:06 localhost.localdomain dnsmasq[2286]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Dec 13 20:49:06 localhost.localdomain dnsmasq-dhcp[2286]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Dec 13 20:57:47 localhost.localdomain systemd[1]: Started Virtualization daemon.
Dec 13 20:58:21 localhost.localdomain libvirtd[9495]: libvirt version: 2.0.0, package: 10.el7_3.2 (CentOS BuildSystem <http://bugs.centos.or...os.org)
Dec 13 20:58:21 localhost.localdomain libvirtd[9495]: hostname: localhost.localdomain
Dec 13 20:58:21 localhost.localdomain libvirtd[9495]: End of file while reading data: Input/output error
Hint: Some lines were ellipsized, use -l to show in full.

Unit tests ?

Hi @dhiltgen

Thanks for the nice driver.

Just wondering why we don't have unit tests so far?

Happy to contribute ๐Ÿ˜„

machine creation process stuck on loop

Hello all,
i ve just started to learn how to use docker. I am using latest version of docker-machine-kvm and docker, docker-machine on Ubuntu 16.04.

I am trying to use "sudo docker-machine -D create -d kvm myengine" command to create a new docker-machine but it stucks on

(myengine) DBG | GetIP called for myengine4
(myengine) DBG | Failed to retrieve dnsmasq leases from /var/lib/libvirt/dnsmasq/docker-machines.leases
(myengine) Failed to decode dnsmasq lease status: unexpected end of JSON input
(myengine) DBG | Unable to locate IP address for MAC ------
(myengine) DBG | Waiting for the VM to come up... 82

after i ve stopped this process, virtual machine is on running state but not able to start itself.

Thanks for all responses, happy coding.

Find new home for docker-machine KVM driver

For various reasons I no longer use this driver during my day-to-day dev work, and given the lack of CI for builds and test automation, this makes it challenging to keep up with incoming PRs. I tried to keep up for a while but at this point to be fair to the community of folks who are using this driver, I'd like to explore if there are other folks out there that are actively using it and would be interested in taking over the project so we can be more responsive to incoming PRs.

\cc @karmab @nkiesel @op @mfriedenhagen @gbraad @mykaul @zakame @petrkotas @HartS @flavio @jcodybaker

Fails to create machine on Fedora 26

The driver is failing to create machines on Fedora 26 with the following error. I tried modifying the Makefile and creating a Dockerfile for Fedora 26 to build the driver that way, but I get the same error either using this newly created driver of the Centos 7 version of the driver.

Running pre-create checks...
Creating machine...
(faas-test) Copying /home/dvdmuckle/.docker/machine/cache/boot2docker.iso to /home/dvdmuckle/.docker/machine/machines/faas-test/boot2docker.iso...
(faas-test) Creating SSH key...
(faas-test) Failed to start: virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
(faas-test) failed to initialize KVM: Device or resource busy')
Error creating machine: Error in driver during machine creation: virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
failed to initialize KVM: Device or resource busy')

Memory allocation uses the wrong unit for allocation

Problem

In the driver plugin actually M is being used as the unit for Memory:

https://github.com/dhiltgen/docker-machine-kvm/blob/master/kvm.go#L37

And according to the description, this is meant to mean Megabytes:
https://github.com/dhiltgen/docker-machine-kvm/blob/master/kvm.go#L104

However, according to the libvirt documentation M is Mebibytes
https://libvirt.org/formatdomain.html#elementsMemoryAllocation

Solution

In the template MB should be used instead to allocate the correct amount of memory

Details

Currently, in docker-machine, minikube and minishift, we assign 2048 as a default for the memory. This will be treated as MB, and this should result in 2G of memory.

However, in virt-manager this VM is created with:

$ sudo virsh edit minishift
<memory unit='KiB'>2097152</memory>

image

This means that the VM is actually created with more memory assigned:

2 097 152 KiB = 2.14748365 GB

Ref
Note: this is for all the clients used docker-machine, minikube and minishift.

static binary

Please make a static binary available so that it's easier to run on obscure systems.

dial tcp: missing address when running docker-machine

When I run docker-machine I get the following error:
dial tcp: missing address

I am running RHEL 7.4

$ ls -l /var/run/libvirt/libvirt-sock*
srwxrwxrwx. 1 root libvirt 0 Nov 17 14:03 /var/run/libvirt/libvirt-sock
srwxrwxrwx. 1 root libvirt 0 Nov 17 14:03 /var/run/libvirt/libvirt-sock-ro

As root I run:

# virsh net-list
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              active     yes           yes

but as a user I run it and get:

$ virsh net-list --all
 Name                 State      Autostart     Persistent
----------------------------------------------------------

I ran docker-machine as root and got the same error.

# systemctl status libvirtd
โ— libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-11-17 14:03:18 EST; 15min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 1304 (libvirtd)
   CGroup: /system.slice/libvirtd.service
           โ”œโ”€1304 /usr/sbin/libvirtd
           โ”œโ”€1615 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa...
           โ””โ”€1617 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/defa...

Nov 17 14:03:18 newnuc dnsmasq[1615]: started, version 2.76 cachesize 150
Nov 17 14:03:18 newnuc dnsmasq[1615]: compile time options: IPv6 GNU-getopt...fy
Nov 17 14:03:18 newnuc dnsmasq-dhcp[1615]: DHCP, IP range 192.168.122.2 -- 1...h
Nov 17 14:03:18 newnuc dnsmasq-dhcp[1615]: DHCP, sockets bound exclusively t...0
Nov 17 14:03:18 newnuc dnsmasq[1615]: reading /etc/resolv.conf
Nov 17 14:03:18 newnuc dnsmasq[1615]: using nameserver 75.75.75.75#53
Nov 17 14:03:18 newnuc dnsmasq[1615]: using nameserver 75.75.76.76#53
Nov 17 14:03:18 newnuc dnsmasq[1615]: read /etc/hosts - 2 addresses
Nov 17 14:03:18 newnuc dnsmasq[1615]: read /var/lib/libvirt/dnsmasq/default...es
Nov 17 14:03:18 newnuc dnsmasq-dhcp[1615]: read /var/lib/libvirt/dnsmasq/def...e
Hint: Some lines were ellipsized, use -l to show in full.

# lsmod |grep -i kvm
kvm_intel             170200  0
kvm                   566604  1 kvm_intel
irqbypass              13503  1 kvm

$ virsh -c qemu:///system list
 Id    Name                           State
----------------------------------------------------

Thanks

Enhancement request : kvm of a remote host

Hi Daniel,

Good work, anyway, what could really be coolest for me is to have kvm on a remote server. That way we'll be able to docker-machine --kvm-ip :)

BR,
Vincent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.