karmab / kcli

Management tool for virtualization and kubernetes platforms
https://kcli.readthedocs.io/en/latest/
Apache License 2.0
498 stars 137 forks source link

kcli doesn't honor memory configuration in profile in libvirt #219

Closed e-minguez closed 4 years ago

e-minguez commented 4 years ago
$ uname -a
Linux endurance.minwi.lan 4.18.0-193.14.2.el8_2.x86_64 #1 SMP Sun Jul 26 03:54:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ kcli version
version: 99.0 commit: ede2ce9 Available Updates: False

$ rpm -qi kcli
Name        : kcli
Version     : 99.0.0.git.202008222357.ede2ce9d
Release     : 1.el8
Architecture: x86_64
Install Date: Sun 23 Aug 2020 06:30:14 PM CEST
Group       : Development/Languages/Python
Size        : 4429506
License     : ASL 2.0
Signature   : RSA/SHA1, Sun 23 Aug 2020 02:01:48 AM CEST, Key ID d8c84386b99058cd
Source RPM  : kcli-99.0.0.git.202008222357.ede2ce9d-1.el8.src.rpm
Build Date  : Sun 23 Aug 2020 02:01:45 AM CEST
Build Host  : ip-172-30-2-212.ec2.internal
Relocations : (not relocatable)
URL         : http://github.com/karmab/kcli
Summary     : Wrapper for libvirt,gcp,aws,ovirt,openstack,kubevirt and vsphere
Description :
Kcli is meant to interact with a local/remote libvirt, gcp, aws ovirt,
openstack, vsphere and kubevirt and to easily deploy single vms from cloud images or several using plans

$ kcli list profile
+----------+------------------+---------+-------+--------------------------------------------------------+---------+-----------+--------+------------+-------------+
| Profile  |      Flavor      |   Pool  | Disks |                         Image                          |   Nets  | Cloudinit | Nested | Reservedns | Reservehost |
+----------+------------------+---------+-------+--------------------------------------------------------+---------+-----------+--------+------------+-------------+
| centos-8 | 2cpus 4096Mb ram | default |   20  | CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2 | default |    True   |  True  |   False    |    False    |
+----------+------------------+---------+-------+--------------------------------------------------------+---------+-----------+--------+------------+-------------+

$ cat ~/.kcli/profiles.yml 
centos-8:
  image: CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2
  numcpus: 2
  cpuhotplug: true
  cpumodel: "host-passthrough"
  memory: 4096
  memoryhotplug: true
  disks:
  - size: 20
  nets:
  - name: default
  cmds:
  - echo unix1234 | passwd --stdin centos

$ kcli -d create vm -p centos-8 test01
Deploying vm test01 from profile centos-8...
neither id_rsa or id_dsa public keys found in your .ssh or .kcli directory, you might have trouble accessing the vm
<domain type='kvm' >
                  <name>test01</name>
                  <metadata>
        <kvirt:info xmlns:kvirt="kvirt">
        <kvirt:creationdate>23-08-2020 16:55</kvirt:creationdate>
        <kvirt:profile>centos-8</kvirt:profile>
<kvirt:image>CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2</kvirt:image>
                    <kvirt:plan>kvirt</kvirt:plan>
                    </kvirt:info>
                    </metadata>
                  <maxMemory slots='16' unit='MiB'>1524288</maxMemory>

                  <memory unit='MiB'>4096</memory>
                  <vcpu  placement='static' current='2'>64</vcpu>
                  <os>
                    <type arch='x86_64' machine='pc'>hvm</type>

                    <boot dev='hd'/>

                    <bootmenu enable='yes'/>
                  </os>
                  <features>
                    <acpi/>
                    <apic/>
                    <pae/>
                  </features>
                  <clock offset='utc'/>
                  <on_poweroff>destroy</on_poweroff>
                  <on_reboot>restart</on_reboot>
                  <on_crash>restart</on_crash>
                  <devices>
                    <disk type='file' device='disk'>
                    <driver name='qemu' type='qcow2'/>
                    <source file='/var/lib/libvirt/images/test01_0.img'/>
                    <backingStore type='file' index='1'>
                                        <format type='qcow2'/>
                                        <source file='/var/lib/libvirt/images/CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2'/>
                                        </backingStore>
                    <target dev='vda' bus='virtio'/>

                    </disk>

                     <interface type='network'>

                     <source network='default'/>

                     <model type='virtio'/>
                     </interface>
                    <disk type='file' device='cdrom'>
                        <driver name='qemu' type='raw'/>
                        <source file='/var/lib/libvirt/images/test01.ISO'/>
                        <target dev='hdd' bus='ide'/>
                        <readonly/>
                        </disk>
                    <input type='tablet' bus='usb'/>
                        <input type='mouse' bus='ps2'/>
                        <graphics type='spice' port='-1' autoport='yes' listen='127.0.0.1'>
                        <listen type='address' address='127.0.0.1'/>
                        </graphics>
                        <memballoon model='virtio'/>
                    <serial type='pty'>
                       <target port='0'/>
                       </serial>
                       <console type='pty'>
                       <target type='serial' port='0'/>
                       </console>

                    <channel type='unix'>
                      <source mode='bind'/>
                      <target type='virtio' name='org.qemu.guest_agent.0'/>
                      </channel>

                  </devices>
                    <cpu mode='host-passthrough'>
                        <model fallback='allow'/><feature policy='require' name='vmx'/><numa><cell id='0' cpus='0-1' memory='1048576' unit='KiB'/></numa></cpu>

                    </domain>
test01 created on local

$ sudo virsh dumpxml test01 | grep -i memory
  <maxMemory slots='16' unit='KiB'>1560870912</maxMemory>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
      <cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>

$ kcli info vm test01 | grep memory
memory: 1024

$ kcli ssh test01
Warning: Permanently added '192.168.122.175' (ECDSA) to the list of known hosts.
centos@192.168.122.175's password: 
Activate the web console with: systemctl enable --now cockpit.socket

$ free -m
              total        used        free      shared  buff/cache   available
Mem:            741         166         313          11         261         443
Swap:             0           0           0
karmab commented 4 years ago

i think it's specific to the memory hotplug thing

karmab commented 4 years ago

fixed in https://github.com/karmab/kcli/commit/78dc1e1a42273dafd1d05b91cbaada5b697b518d