Commit a5bdb631 authored by Łukasz Nowak's avatar Łukasz Nowak

software/kvm: Set cpu-max-count and ram-max-size defaults correctly

As cpu-count and ram-size can be setup freely by the user, the cpu-max-count
and ram-max-size shall follow it.

Otherwise it generates hard to track issues with starting VMs.
parent 6d287f3a
......@@ -19,11 +19,11 @@ md5sum = e6d5c7bb627b4f1d3e7c99721b7c58fe
[template-kvm]
filename = instance-kvm.cfg.jinja2
md5sum = aa734942801ac62eeccaba43926a0a27
md5sum = 50e78a2a34efe09afab161ae1c1efd46
[template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in
md5sum = b91a0e8b083caa924699f601ca15729e
md5sum = a4788112008cd0b38a57cd28f7252fbd
[template-kvm-resilient]
filename = instance-kvm-resilient.cfg.jinja2
......
......@@ -237,9 +237,8 @@
},
"ram-max-size": {
"title": "Maximum RAM size, in MB",
"description": "Define the maximum size of the memory. The size is in MB and should be a multiple of 512.",
"description": "Define the maximum size of the memory. The size is in MB and should be a multiple of 512. Defaults to ram-size + 512",
"type": "integer",
"default": 51200,
"minimum": 1024,
"multipleOf": 512
},
......@@ -324,9 +323,8 @@
},
"cpu-max-count": {
"title": "Maximum CPU amount",
"description": "Specifies the maximum number of CPUs.",
"description": "Specifies the maximum number of CPUs. Defaults to cpu-count + 1",
"type": "integer",
"default": 24,
"minimum": 1
},
"numa": {
......
......@@ -74,14 +74,14 @@ config-authorized-key = {{ dumps(slapparameter_dict.get('authorized-keys') | joi
config-nbd-port = {{ dumps(kvm_parameter_dict.get('nbd-port', 1024)) }}
config-nbd2-port = {{ dumps(kvm_parameter_dict.get('nbd-port2', 1024)) }}
config-ram-size = {{ dumps(kvm_parameter_dict.get('ram-size', 1024)) }}
config-ram-max-size = {{ dumps(kvm_parameter_dict.get('ram-max-size', '51200')) }}
config-ram-max-size = {{ dumps(kvm_parameter_dict.get('ram-max-size', int(kvm_parameter_dict.get('ram-size', 1024)) + 512)) }}
config-enable-device-hotplug = {{ dumps(kvm_parameter_dict.get('enable-device-hotplug', False)) }}
config-ram-hotplug-slot-size = {{ dumps(kvm_parameter_dict.get('ram-hotplug-slot-size', 512)) }}
config-disk-size = {{ dumps(kvm_parameter_dict.get('disk-size', 10)) }}
config-disk-type = {{ dumps(kvm_parameter_dict.get('disk-type', 'virtio')) }}
config-disk-format = {{ dumps(kvm_parameter_dict.get('disk-format', 'qcow2')) }}
config-cpu-count = {{ dumps(kvm_parameter_dict.get('cpu-count', 1)) }}
config-cpu-max-count = {{ dumps(kvm_parameter_dict.get('cpu-max-count', 24)) }}
config-cpu-max-count = {{ dumps(kvm_parameter_dict.get('cpu-max-count', int(kvm_parameter_dict.get('cpu-count', 1)) + 1)) }}
{{ setconfig('numa', kvm_parameter_dict.get('numa', '')) }}
{{ setconfig('machine-options', kvm_parameter_dict.get('machine-options', '')) }}
{{ setconfig('nbd-host', kvm_parameter_dict.get('nbd-host', '')) }}
......
......@@ -19,9 +19,8 @@
},
"ram-max-size": {
"title": "Maximum RAM size, in MB",
"description": "Define the maximum size of the memory. The size is in MB and should be a multiple of 512.",
"description": "Define the maximum size of the memory. The size is in MB and should be a multiple of 512. Defaults to ram-size + 512",
"type": "integer",
"default": 51200,
"minimum": 1024,
"multipleOf": 512
},
......@@ -106,9 +105,8 @@
},
"cpu-max-count": {
"title": "Maximum CPU amount",
"description": "Specifies the maximum number of CPUs.",
"description": "Specifies the maximum number of CPUs. Defaults to cpu-count + 1",
"type": "integer",
"default": 24,
"minimum": 1
},
"numa": {
......
......@@ -10,6 +10,8 @@
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '22 80 443') -%}
{% set disk_device_path = slapparameter_dict.get('disk-device-path', None) -%}
{% set image_url_list_enabled = 'image-url-list' in slapparameter_dict %}
{% set cpu_max_count = dumps(slapparameter_dict.get('cpu-max-count', int(slapparameter_dict.get('cpu-count', 1)) + 1)) %}
{% set ram_max_size = dumps(slapparameter_dict.get('ram-max-size', int(slapparameter_dict.get('ram-size', 1024)) + 512)) %}
{% set extends_list = [] -%}
{% set part_list = [] -%}
......@@ -217,10 +219,10 @@ socket-path = ${kvm-controller-parameter-dict:socket-path}
enable-device-hotplug = ${kvm-controller-parameter-dict:enable-device-hotplug}
smp-count = ${kvm-controller-parameter-dict:cpu-count}
smp-max-count = ${slap-parameter:cpu-max-count}
smp-max-count = {{ cpu_max_count }}
ram-size = ${kvm-controller-parameter-dict:ram-size}
ram-max-size = ${slap-parameter:ram-max-size}
ram-max-size = {{ ram_max_size }}
init-ram-size = 1024
mac-address = ${create-mac:mac-address}
tap-mac-address = ${create-tap-mac:mac-address}
......@@ -825,7 +827,6 @@ image-url-list =
enable-device-hotplug = False
ram-size = 1024
ram-max-size = 51200
ram-hotplug-slot-size = 512
disk-size = 10
disk-type = virtio
......@@ -833,7 +834,6 @@ disk-format = qcow2
disk-device-path =
cpu-count = 1
cpu-max-count = 24
disk-cache = writeback
disk-aio = native
auto-ballooning = True
......
......@@ -729,3 +729,24 @@ class TestImageUrlListKvmCluster(InstanceTestCase):
"%s#%s" % (self.fake_image2, self.fake_image2_md5sum),
fh.read()
)
@skipUnlessKvm
class TestCpuMemMaxDynamic(InstanceTestCase):
__partition_reference__ = 'cmm'
@classmethod
def getInstanceParameterDict(cls):
return {
'cpu-count': 2,
'ram-size': 2048
}
def test(self):
with open(os.path.join(
self.computer_partition_root_path, 'bin', 'kvm_raw'), 'rb') as fh:
kvm_raw = fh.read()
self.assertTrue('smp_count = 2' in kvm_raw)
self.assertTrue('smp_max_count = 3' in kvm_raw)
self.assertTrue('ram_size = 2048' in kvm_raw)
self.assertTrue("ram_max_size = '2560'" in kvm_raw)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment