Commit 128a37e0 authored by Julien Muchembled's avatar Julien Muchembled

kvm: do not try to correct disk-related parameters

The user must be aware of any mistake he did. For example, he may lose
time by not understanding why the VM does not behave as expected or by
distorting measures in benchmarks.

The only legitimate reason to automatically fix a parameter is backward
compatibility, if a value is not valid anymore. But such fallback
should only be temporary. There's no such case recently.

At last, it increased maintenance by having to keep the lists of valid
values up-to-date.

About:

  -  if disk_info['io'] == 'native':
  -    additional_disk_options += ',cache.direct=on'

These lines are redundant when cache is none.
parent 5c5ec746
...@@ -19,7 +19,7 @@ md5sum = 0d34ff81779115bf899f7bc752877b70 ...@@ -19,7 +19,7 @@ md5sum = 0d34ff81779115bf899f7bc752877b70
[template-kvm] [template-kvm]
filename = instance-kvm.cfg.jinja2 filename = instance-kvm.cfg.jinja2
md5sum = 854ec0f379a05246f5f3761fdb634c36 md5sum = 4f71b7616b9f4a2f968e89326a237768
[template-kvm-cluster] [template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in filename = instance-kvm-cluster.cfg.jinja2.in
...@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257 ...@@ -55,7 +55,7 @@ md5sum = b7e87479a289f472b634a046b44b5257
[template-kvm-run] [template-kvm-run]
filename = template/template-kvm-run.in filename = template/template-kvm-run.in
md5sum = a8afeb2f80199368e291621576a80ca1 md5sum = e7b9623eabe1bbd5233e0fbfde94a67c
[template-kvm-controller] [template-kvm-controller]
filename = template/kvm-controller-run.in filename = template/kvm-controller-run.in
......
...@@ -932,8 +932,8 @@ disk-format = qcow2 ...@@ -932,8 +932,8 @@ disk-format = qcow2
disk-device-path = disk-device-path =
cpu-count = 1 cpu-count = 1
disk-cache = writeback disk-cache =
disk-aio = native disk-aio =
auto-ballooning = True auto-ballooning = True
machine-options = machine-options =
cpu-model = host cpu-model = host
......
...@@ -20,13 +20,10 @@ import json ...@@ -20,13 +20,10 @@ import json
import ssl import ssl
# XXX: give all of this through parameter, don't use this as template, but as module # XXX: give all of this through parameter, don't use this as template, but as module
qemu_img_path = '{{ parameter_dict.get("qemu-img-path") }}' qemu_img_path = {{ repr(parameter_dict["qemu-img-path"]) }}
qemu_path = '{{ parameter_dict.get("qemu-path") }}' qemu_path = {{ repr(parameter_dict["qemu-path"]) }}
disk_size = '{{ parameter_dict.get("disk-size") }}' disk_size = {{ repr(parameter_dict["disk-size"]) }}
disk_type = '{{ parameter_dict.get("disk-type") }}' disk_type = {{ repr(parameter_dict["disk-type"]) }}
disk_format = '{{ parameter_dict.get("disk-format", "qcow2")}}'
disk_format = disk_format \
if disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
socket_path = '{{ parameter_dict.get("socket-path") }}' socket_path = '{{ parameter_dict.get("socket-path") }}'
nbd_list = (('{{ parameter_dict.get("nbd-host") }}', nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
...@@ -34,7 +31,6 @@ nbd_list = (('{{ parameter_dict.get("nbd-host") }}', ...@@ -34,7 +31,6 @@ nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
('{{ parameter_dict.get("nbd2-host") }}', ('{{ parameter_dict.get("nbd2-host") }}',
{{ parameter_dict.get("nbd2-port") }})) {{ parameter_dict.get("nbd2-port") }}))
default_cdrom_iso = '{{ parameter_dict.get("default-cdrom-iso") }}' default_cdrom_iso = '{{ parameter_dict.get("default-cdrom-iso") }}'
disk_path = '{{ parameter_dict.get("disk-path") }}'
virtual_hard_drive_url = '{{ parameter_dict.get("virtual-hard-drive-url") }}'.strip() virtual_hard_drive_url = '{{ parameter_dict.get("virtual-hard-drive-url") }}'.strip()
virtual_hard_drive_md5sum = '{{ parameter_dict.get("virtual-hard-drive-md5sum") }}'.strip() virtual_hard_drive_md5sum = '{{ parameter_dict.get("virtual-hard-drive-md5sum") }}'.strip()
...@@ -56,9 +52,7 @@ init_ram_size = {{ parameter_dict.get("init-ram-size") }} ...@@ -56,9 +52,7 @@ init_ram_size = {{ parameter_dict.get("init-ram-size") }}
pid_file_path = '{{ parameter_dict.get("pid-file-path") }}' pid_file_path = '{{ parameter_dict.get("pid-file-path") }}'
external_disk_number = {{ parameter_dict.get("external-disk-number") }} external_disk_number = {{ parameter_dict.get("external-disk-number") }}
external_disk_size = {{ parameter_dict.get("external-disk-size") }} external_disk_size = {{ parameter_dict.get("external-disk-size") }}
external_disk_format = '{{ parameter_dict.get("external-disk-format", "qcow2") }}' external_disk_format = {{ repr(parameter_dict["external-disk-format"]) }}
external_disk_format = external_disk_format \
if external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
disk_storage_dict = {} disk_storage_dict = {}
disk_storage_list = """{{ parameter_dict.get("disk-storage-list") }}""".split('\n') disk_storage_list = """{{ parameter_dict.get("disk-storage-list") }}""".split('\n')
map_storage_list = [] map_storage_list = []
...@@ -70,11 +64,6 @@ cluster_doc_port = {{ parameter_dict.get("cluster-doc-port") }} ...@@ -70,11 +64,6 @@ cluster_doc_port = {{ parameter_dict.get("cluster-doc-port") }}
url_check_certificate = '{{ parameter_dict.get("hard-drive-url-check-certificate", "true") }}'.lower() url_check_certificate = '{{ parameter_dict.get("hard-drive-url-check-certificate", "true") }}'.lower()
auto_ballooning = '{{ parameter_dict.get("auto-ballooning") }}' in ('true', 'True', '1') auto_ballooning = '{{ parameter_dict.get("auto-ballooning") }}' in ('true', 'True', '1')
vm_name = '{{ parameter_dict.get("name") }}' vm_name = '{{ parameter_dict.get("name") }}'
disk_cache = '{{ parameter_dict.get("disk-cache", "writeback") }}'.strip()
disk_cache = disk_cache if disk_cache in ["none", "writeback", "unsafe",
"directsync", "writethrough"] else "writeback"
disk_aio = '{{ parameter_dict.get("disk-aio", "threads") }}'.strip()
disk_aio = disk_aio if disk_aio in ["threads", "native"] else "threads"
# If a device (ie.: /dev/sdb) is provided, use it instead # If a device (ie.: /dev/sdb) is provided, use it instead
# the disk_path with disk_format # the disk_path with disk_format
...@@ -84,16 +73,18 @@ for disk_device_path in '{{ parameter_dict.get("disk-device-path", "") }}'.split ...@@ -84,16 +73,18 @@ for disk_device_path in '{{ parameter_dict.get("disk-device-path", "") }}'.split
disk_info_list.append({ disk_info_list.append({
'path': disk_device_path, 'path': disk_device_path,
'format': "raw", 'format': "raw",
'io': "native", 'aio': "native",
'cache': "none" 'cache': "none"
}) })
if len(disk_info_list) == 0: if not disk_info_list:
disk_info_list.append({ disk_info_list.append({
'path': disk_path, {%- for k in 'path', 'format', 'aio', 'cache' %}
'format': disk_format, {%- set v = parameter_dict['disk-' + k] %}
'io': disk_aio, {%- if v %}
'cache': disk_cache, {{ repr(k) }}: {{ repr(v) }},
{%- endif %}
{%- endfor %}
}) })
smp_count = {{ parameter_dict.get("smp-count") }} smp_count = {{ parameter_dict.get("smp-count") }}
...@@ -312,14 +303,14 @@ kvm_argument_list = [qemu_path, ...@@ -312,14 +303,14 @@ kvm_argument_list = [qemu_path,
for disk_info in disk_info_list: for disk_info in disk_info_list:
additional_disk_options = '' additional_disk_options = ''
if disk_info['io'] == 'native':
additional_disk_options += ',cache.direct=on'
if disk_info['format'] == "raw": if disk_info['format'] == "raw":
additional_disk_options += ',discard=on' additional_disk_options += ',discard=on'
kvm_argument_list.extend([ kvm_argument_list.extend([
'-drive', '-drive',
'file=%s,if=%s,cache=%s,aio=%s%s' % ( disk_info['path'], disk_type, disk_info['cache'], disk_info['io'], additional_disk_options) 'file=%s,if=%s%s%s' % (
disk_info['path'], disk_type, additional_disk_options,
''.join(',%s=%s' % x for x in disk_info.items() if x[0] != 'path'))
]) ])
rgx = re.compile('^[\w*\,][\=\d+\-\,\w]*$') rgx = re.compile('^[\w*\,][\=\d+\-\,\w]*$')
......
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