dhiltgen / docker-machine-kvm

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

Memory allocation uses the wrong unit for allocation #54

Open gbraad opened 6 years ago

gbraad commented 6 years ago

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.

gbraad commented 6 years ago

Build log and artifact:

$ minishift start --memory 2048
$ sudo virsh edit minishift
<domain type='kvm'>
  <name>minishift</name>
  <uuid>a000f98a-1d03-48e5-ac10-67afd456d8c6</uuid>
  <memory unit='KiB'>2000000</memory>
  <currentMemory unit='KiB'>2000000</currentMemory>

2 000 000 KiB = 2048 MB

Ref

gbraad commented 6 years ago

@r2d4 @aaron-prindle Hi guys, this also affects you

gbraad commented 6 years ago

@dhiltgen I have proposed the solution several days ago #55. Would appreciate your feedback.