1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Enea AB and others.
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Guillermo Herrero <Guillermo.Herrero@enea.com>
10 Date: Tue, 25 Jul 2017 00:58:32 +0200
11 Subject: [PATCH] salt-formulas: Add & enable armband formula
13 - prereq: install qemu-efi;
14 - prereq: install vgabios;
15 - prereq: fix missing link for vgabios binary blob;
16 - nova patch: Support qemu >= 2.10 (backport from [1]);
17 - nova patch: Add video type virtio for AArch64 (backport from [2]);
18 - nova patch: libvirt driver: Add ttyAMA0 by default on AArch64;
19 - nova patch: libvirt driver: AArch64: ACPI depends on AAVMF;
20 - nova conf: cpu_model=cortex-a57 (only for virtual deploys);
21 - nova conf: virt_type=qemu (only for virtual deploys);
22 - nova conf: pointer_model=ps2mouse since AArch64 has no USB tablet;
24 [1] https://github.com/openstack/nova/commit/8075797
25 [2] https://github.com/openstack/nova/commit/f0f0953
27 Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
28 Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
29 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
31 mcp/config/states/openstack_ha | 1 +
32 mcp/config/states/openstack_noha | 2 +
33 mcp/config/states/virtual_control_plane | 1 +
34 .../armband/files/nova-libvirt-aarch64-rollup.diff | 270 +++++++++++++++++++++
35 mcp/salt-formulas/armband/init.sls | 7 +
36 mcp/salt-formulas/armband/nova_config.sls | 30 +++
37 mcp/salt-formulas/armband/nova_libvirt.sls | 7 +
38 mcp/salt-formulas/armband/qemu_efi.sls | 2 +
39 mcp/salt-formulas/armband/vgabios.sls | 7 +
40 9 files changed, 327 insertions(+)
41 create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
42 create mode 100644 mcp/salt-formulas/armband/init.sls
43 create mode 100644 mcp/salt-formulas/armband/nova_config.sls
44 create mode 100644 mcp/salt-formulas/armband/nova_libvirt.sls
45 create mode 100644 mcp/salt-formulas/armband/qemu_efi.sls
46 create mode 100644 mcp/salt-formulas/armband/vgabios.sls
48 diff --git a/mcp/config/states/openstack_ha b/mcp/config/states/openstack_ha
49 index 62a9654..bf17e20 100755
50 --- a/mcp/config/states/openstack_ha
51 +++ b/mcp/config/states/openstack_ha
52 @@ -52,6 +52,7 @@ salt -I 'neutron:server' state.sls neutron -b 1
53 salt -I 'neutron:gateway' state.sls neutron.gateway
55 salt -I 'nova:compute' state.sls nova
56 +salt -I 'nova:compute' state.sls armband || true
58 salt -I 'mongodb:server' state.sls mongodb || true
59 wait_for 90 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
60 diff --git a/mcp/config/states/openstack_noha b/mcp/config/states/openstack_noha
61 index 1578dcf..6dc27cd 100755
62 --- a/mcp/config/states/openstack_noha
63 +++ b/mcp/config/states/openstack_noha
64 @@ -49,3 +49,5 @@ salt -I 'ceilometer:server' state.sls ceilometer
65 salt -I 'ceilometer:agent' state.sls ceilometer
67 salt -I 'horizon:server' state.sls horizon
69 +salt -I 'nova:compute' state.sls armband || true
70 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
71 index 3856bef..8c02d68 100755
72 --- a/mcp/config/states/virtual_control_plane
73 +++ b/mcp/config/states/virtual_control_plane
74 @@ -27,6 +27,7 @@ if [ "${ERASE_ENV}" -eq 1 ]; then
77 # KVM libvirt first, VCP deployment
78 +salt -C 'kvm*' state.sls armband || true
79 wait_for 5 "salt -C 'kvm*' state.sls libvirt"
81 salt -C 'kvm* or cmp*' state.apply salt
82 diff --git a/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff b/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
84 index 0000000..75fb07d
86 +++ b/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
88 +From 807579755c4a116309eca5b2bcdbab9d1f393bab Mon Sep 17 00:00:00 2001
89 +From: Matt Riedemann <mriedem.os@gmail.com>
90 +Date: Wed, 20 Sep 2017 10:44:11 -0400
91 +Subject: [PATCH] Support qemu >= 2.10
93 +Qemu 2.10 added the requirement of a --force-share flag to qemu-img
94 +info when reading information about a disk that is in use by a
95 +guest. We do this a lot in Nova for operations like gathering
96 +information before live migration.
98 +Up until this point all qemu/libvirt version matching has been solely
99 +inside the libvirt driver, however all the image manip code was moved
100 +out to nova.virt.images. We need the version of QEMU available there.
102 +This does it by initializing that version on driver init host. The net
103 +effect is also that broken libvirt connections are figured out
104 +earlier, as there is an active probe for this value.
106 +Co-Authored-By: Sean Dague <sean@dague.net>
108 +[ Alexandru.Avadanii@enea.com ]
109 +Minor patch adjustment to apply cleanly on Newton without further
112 +Change-Id: Iae2962bb86100f03fd3ad9aac3767da876291e74
113 +Closes-Bug: #1718295
115 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
117 + nova/test.py | 3 +++
118 + nova/tests/unit/virt/libvirt/test_driver.py | 20 ++++++++++++++++++--
119 + nova/tests/unit/virt/libvirt/test_utils.py | 25 +++++++++++++++++++++++++
120 + nova/virt/images.py | 10 ++++++++++
121 + nova/virt/libvirt/driver.py | 14 +++++++++-----
122 + 5 files changed, 65 insertions(+), 7 deletions(-)
124 +diff --git a/nova/test.py b/nova/test.py
125 +index f0e6953b965..9b9ea9507e8 100644
129 + from nova.tests.unit import policy_fixture
130 + from nova.tests import uuidsentinel as uuids
131 + from nova import utils
132 ++from nova.virt import images
136 +@@ -299,6 +300,8 @@ def setUp(self):
137 + # nova.utils._IS_NEUTRON. We set it to None to avoid any
138 + # caching of that value.
139 + utils._IS_NEUTRON = None
140 ++ # Reset the global QEMU version flag.
141 ++ images.QEMU_VERSION = None
143 + # Reset the traits sync flag
144 + objects.resource_provider._TRAITS_SYNCED = False
145 +diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
146 +index fe54dc75e7f..4e9f2bd250e 100644
147 +--- a/nova/tests/unit/virt/libvirt/test_driver.py
148 ++++ b/nova/tests/unit/virt/libvirt/test_driver.py
149 +@@ -985,6 +985,23 @@ def test_next_min_qemu_version_ok(self, mock_warning, mock_get_libversion):
151 + self.assertFalse(version_arg_found)
153 ++ # NOTE(sdague): python2.7 and python3.5 have different behaviors
154 ++ # when it comes to comparing against the sentinel, so
155 ++ # has_min_version is needed to pass python3.5.
156 ++ @mock.patch.object(nova.virt.libvirt.host.Host, "has_min_version",
157 ++ return_value=True)
158 ++ @mock.patch.object(fakelibvirt.Connection, 'getVersion',
159 ++ return_value=mock.sentinel.qemu_version)
160 ++ def test_qemu_image_version(self, mock_get_libversion, min_ver):
161 ++ """Test that init_host sets qemu image version
163 ++ A sentinel is used here so that we aren't chasing this value
164 ++ against minimums that get raised over time.
166 ++ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
167 ++ drvr.init_host("dummyhost")
168 ++ self.assertEqual(images.QEMU_VERSION, mock.sentinel.qemu_version)
170 + @mock.patch.object(fakelibvirt.Connection, 'getLibVersion',
171 + return_value=versionutils.convert_version_to_int(
172 + libvirt_driver.MIN_LIBVIRT_OTHER_ARCH.get(
173 +@@ -11636,9 +11653,8 @@ def test_command_with_broken_connection(self):
174 + return_value=service_mock),
175 + mock.patch.object(host.Host, "get_capabilities")):
177 +- drvr.init_host("wibble")
178 + self.assertRaises(exception.HypervisorUnavailable,
179 +- drvr.get_num_instances)
180 ++ drvr.init_host, ("wibble",))
181 + self.assertTrue(service_mock.disabled)
183 + def test_service_resume_after_broken_connection(self):
184 +diff --git a/nova/tests/unit/virt/libvirt/test_utils.py b/nova/tests/unit/virt/libvirt/test_utils.py
185 +index 646a72c8599..49945a3cd3b 100644
186 +--- a/nova/tests/unit/virt/libvirt/test_utils.py
187 ++++ b/nova/tests/unit/virt/libvirt/test_utils.py
188 +@@ -173,6 +173,31 @@ def test_qemu_info_canon(self, mock_execute, mock_exists):
190 + @mock.patch('os.path.exists', return_value=True)
191 + @mock.patch('nova.utils.execute')
192 ++ def test_qemu_info_canon_qemu_2_10(self, mock_execute, mock_exists):
193 ++ images.QEMU_VERSION = images.QEMU_VERSION_REQ_SHARED
194 ++ path = "disk.config"
195 ++ example_output = """image: disk.config
197 ++virtual size: 64M (67108864 bytes)
198 ++cluster_size: 65536
202 ++ mock_execute.return_value = (example_output, '')
203 ++ image_info = images.qemu_img_info(path)
204 ++ mock_execute.assert_called_once_with('env', 'LC_ALL=C', 'LANG=C',
205 ++ 'qemu-img', 'info', path,
207 ++ prlimit=images.QEMU_IMG_LIMITS)
208 ++ mock_exists.assert_called_once_with(path)
209 ++ self.assertEqual('disk.config', image_info.image)
210 ++ self.assertEqual('raw', image_info.file_format)
211 ++ self.assertEqual(67108864, image_info.virtual_size)
212 ++ self.assertEqual(98304, image_info.disk_size)
213 ++ self.assertEqual(65536, image_info.cluster_size)
215 ++ @mock.patch('os.path.exists', return_value=True)
216 ++ @mock.patch('nova.utils.execute')
217 + def test_qemu_info_canon2(self, mock_execute, mock_exists):
218 + path = "disk.config"
219 + example_output = """image: disk.config
220 +diff --git a/nova/virt/images.py b/nova/virt/images.py
221 +index dae6bc7ef52..be2a9d9e062 100644
222 +--- a/nova/virt/images.py
223 ++++ b/nova/virt/images.py
225 + Handling of VM disk images.
231 + from oslo_concurrency import processutils
234 + address_space=1 * units.Gi)
236 ++# This is set by the libvirt driver on startup. The version is used to
237 ++# determine what flags need to be set on the command line.
238 ++QEMU_VERSION = None
239 ++QEMU_VERSION_REQ_SHARED = 2010000
242 + def qemu_img_info(path, format=None):
243 + """Return an object containing the parsed output from qemu-img info."""
244 +@@ -61,6 +67,10 @@ def qemu_img_info(path, format=None):
245 + 'qemu-img', 'info', '--force-share', path)
246 + if format is not None:
247 + cmd = cmd + ('-f', format)
248 ++ # Check to see if the qemu version is >= 2.10 because if so, we need
249 ++ # to add the --force-share flag.
250 ++ if QEMU_VERSION and operator.ge(QEMU_VERSION, QEMU_VERSION_REQ_SHARED):
251 ++ cmd = cmd + ('--force-share',)
252 + out, err = utils.execute(*cmd, prlimit=QEMU_IMG_LIMITS)
253 + except processutils.ProcessExecutionError as exp:
254 + # this means we hit prlimits, make the exception more specific
255 +diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
256 +index 82dc2b99f6a..8d4eb90ecf5 100644
257 +--- a/nova/virt/libvirt/driver.py
258 ++++ b/nova/virt/libvirt/driver.py
259 +@@ -477,11 +477,15 @@ def init_host(self, host):
260 + _('Nova requires libvirt version %s or greater.') %
261 + self._version_to_string(MIN_LIBVIRT_VERSION))
263 +- if (CONF.libvirt.virt_type in ("qemu", "kvm") and
264 +- not self._host.has_min_version(hv_ver=MIN_QEMU_VERSION)):
265 +- raise exception.InternalError(
266 +- _('Nova requires QEMU version %s or greater.') %
267 +- self._version_to_string(MIN_QEMU_VERSION))
268 ++ if CONF.libvirt.virt_type in ("qemu", "kvm"):
269 ++ if self._host.has_min_version(hv_ver=MIN_QEMU_VERSION):
270 ++ # "qemu-img info" calls are version dependent, so we need to
271 ++ # store the version in the images module.
272 ++ images.QEMU_VERSION = self._host.get_connection().getVersion()
274 ++ raise exception.InternalError(
275 ++ _('Nova requires QEMU version %s or greater.') %
276 ++ self._version_to_string(MIN_QEMU_VERSION))
278 + if CONF.libvirt.virt_type == 'parallels':
279 + if not self._host.has_min_version(hv_ver=MIN_VIRTUOZZO_VERSION):
282 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
283 +Date: Thu, 24 Aug 2017 10:57:28 +0200
284 +Subject: [PATCH] libvirt: AArch64: ACPI depends on AAVMF
286 +On AArch64, ACPI should be added to domain XML only if guest UEFI
287 +(AAVMF) is also used.
289 +[ Alexandru.Avadanii@enea.com ]
290 +- pike rebase: minor context adj
292 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
293 +Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
297 +diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
298 +--- a/nova/virt/libvirt/driver.py
299 ++++ b/nova/virt/libvirt/driver.py
300 +@@ -4314,7 +4314,10 @@
302 + if (virt_type not in ("lxc", "uml", "parallels", "xen") or
303 + (virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
304 +- guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
305 ++ guestarch = libvirt_utils.get_arch(image_meta)
306 ++ if (guestarch not in (fields.Architecture.ARMV7, fields.Architecture.AARCH64) or
307 ++ image_meta.properties.get('hw_firmware_type') == 'uefi'):
308 ++ guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
309 + guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
311 + if (virt_type in ("qemu", "kvm") and
314 +From f0f09530ee9169eb29bc28d4f118676d7dc6640e Mon Sep 17 00:00:00 2001
315 +From: Kevin Zhao <kevin.zhao@arm.com>
316 +Date: Tue, 15 Aug 2017 09:52:09 +0000
317 +Subject: [PATCH] Add video type virtio for AArch64
319 +Currently only "virtio" type is supported on AArch64, and the
320 +other "virrus", "qxl" and "vga" don't work on AArch64 according to
322 +https://www.redhat.com/archives/libvir-list/2016-September/msg00546.html
323 +Then this patch adds the virtio for AArch64 and tweaks the related test cases.
325 +Closes-bug: #1710766
327 +[ Alexandru.Avadanii@enea.com ]
328 +Dropped test changes so it applies cleanly on Newton without more backports.
330 +Change-Id: Iba8a1e671f2b5759b3d9178aa1871d0cf888b26b
331 +Signed-off-by: Kevin Zhao <kevin.zhao@arm.com>
332 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
335 +--- a/nova/virt/libvirt/driver.py
336 ++++ b/nova/virt/libvirt/driver.py
337 +@@ -4342,7 +4342,8 @@ def _check_number_of_serial_console(self, num_ports):
338 + allowed=ALLOWED_QEMU_SERIAL_PORTS, virt_type=virt_type)
340 + def _add_video_driver(self, guest, image_meta, flavor):
341 +- VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga", "xen", "qxl")
342 ++ VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga",
343 ++ "xen", "qxl", "virtio")
344 + video = vconfig.LibvirtConfigGuestVideo()
345 + # NOTE(ldbragst): The following logic sets the video.type
346 + # depending on supported defaults given the architecture,
347 +@@ -4360,6 +4361,10 @@ def _add_video_driver(self, guest, image_meta, flavor):
348 + # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
349 + # so use 'vga' instead when running on Power hardware.
351 ++ elif guestarch in (fields.Architecture.AARCH64):
352 ++ # NOTE(kevinz): Only virtio device type is supported by AARCH64
353 ++ # so use 'virtio' instead when running on AArch64 hardware.
354 ++ video.type = 'virtio'
355 + elif CONF.spice.enabled:
357 + if image_meta.properties.get('hw_video_model'):
358 diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
360 index 0000000..8a8cf2a
362 +++ b/mcp/salt-formulas/armband/init.sls
367 + {%- if salt['pkg.version']('python-nova') %}
368 + - armband.nova_libvirt
369 + - armband.nova_config
371 diff --git a/mcp/salt-formulas/armband/nova_config.sls b/mcp/salt-formulas/armband/nova_config.sls
373 index 0000000..674f371
375 +++ b/mcp/salt-formulas/armband/nova_config.sls
377 +{% if grains['virtual'] == 'kvm' %}
380 + - name: "/etc/nova/nova.conf"
381 + - pattern: '^virt_type\s*=.*$'
382 + - repl: "virt_type = qemu"
386 + - name: "/etc/nova/nova.conf"
387 + - pattern: '^#pointer_model\s*=.*$'
388 + - repl: "pointer_model = ps2mouse"
391 + - name: "/etc/nova/nova.conf"
392 + - pattern: '^cpu_mode\s*=\s*host-passthrough'
393 + - repl: "cpu_mode = custom"
396 + - name: "/etc/nova/nova.conf"
397 + - pattern: '^#cpu_model\s*=.*$'
398 + {% if grains['virtual'] == 'kvm' %}
399 + - repl: "cpu_model = cortex-a57"
401 + - repl: "cpu_model = host"
403 +restart_nova-compute:
406 + - name: "service nova-compute restart"
407 diff --git a/mcp/salt-formulas/armband/nova_libvirt.sls b/mcp/salt-formulas/armband/nova_libvirt.sls
409 index 0000000..bc2cbda
411 +++ b/mcp/salt-formulas/armband/nova_libvirt.sls
413 +nova-libvirt-aarch64-rollup:
415 + - name: /usr/lib/python2.7/dist-packages
416 + - source: salt://armband/files/nova-libvirt-aarch64-rollup.diff
419 + - unless: 'test -f /var/cache/salt/minion/files/base/armband/files/nova-libvirt-aarch64-rollup.diff && cd /usr/lib/python2.7/dist-packages && patch -p1 -R --dry-run /var/cache/salt/minion/files/base/armband/files/nova-libvirt-aarch64-rollup.diff'
420 diff --git a/mcp/salt-formulas/armband/qemu_efi.sls b/mcp/salt-formulas/armband/qemu_efi.sls
422 index 0000000..c697dae
424 +++ b/mcp/salt-formulas/armband/qemu_efi.sls
428 diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
430 index 0000000..500c2bc
432 +++ b/mcp/salt-formulas/armband/vgabios.sls
438 +/usr/share/qemu/vgabios-stdvga.bin:
440 + - target: "/usr/share/vgabios/vgabios.bin"