a219e4b5b411cddc1e1d1abb0e0f6afd3d4a80e2
[armband.git] / patches / opnfv-fuel / 0002-salt-formulas-Add-enable-armband-formula.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Enea AB and others.
3 :
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
12
13 - prereq: install qemu-efi;
14 - prereq: install vgabios;
15 - prereq: fix missing link for vgabios binary blob;
16 - nova patch: Add video type virtio for AArch64 (backport from [1]);
17 - nova patch: libvirt driver: AArch64: ACPI depends on AAVMF;
18 - nova patch: force creation of pty device;
19 - nova conf: cpu_model=cortex-a57 (only for virtual deploys);
20 - nova conf: virt_type=qemu (only for virtual deploys);
21 - nova compute conf: virt_type=qemu (only for virtual deploys);
22 - nova conf: pointer_model=ps2mouse since AArch64 has no USB tablet;
23
24 [1] https://github.com/openstack/nova/commit/f0f0953
25
26 Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
27 Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
28 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
29 ---
30  mcp/config/states/openstack_ha                     |   1 +
31  mcp/config/states/openstack_noha                   |   2 +
32  mcp/config/states/virtual_control_plane            |   1 +
33  .../armband/files/nova-libvirt-aarch64-rollup.diff | 165 +++++++++++++++++++++
34  mcp/salt-formulas/armband/init.sls                 |   7 +
35  mcp/salt-formulas/armband/nova_config.sls          |  35 +++++
36  mcp/salt-formulas/armband/nova_libvirt.sls         |   7 +
37  mcp/salt-formulas/armband/qemu_efi.sls             |   2 +
38  mcp/salt-formulas/armband/vgabios.sls              |   7 +
39  9 files changed, 226 insertions(+)
40  create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
41  create mode 100644 mcp/salt-formulas/armband/init.sls
42  create mode 100644 mcp/salt-formulas/armband/nova_config.sls
43  create mode 100644 mcp/salt-formulas/armband/nova_libvirt.sls
44  create mode 100644 mcp/salt-formulas/armband/qemu_efi.sls
45  create mode 100644 mcp/salt-formulas/armband/vgabios.sls
46
47 diff --git a/mcp/config/states/openstack_ha b/mcp/config/states/openstack_ha
48 index 4f3760f6..115a56c1 100755
49 --- a/mcp/config/states/openstack_ha
50 +++ b/mcp/config/states/openstack_ha
51 @@ -52,6 +52,7 @@ salt -I 'neutron:server' state.sls neutron -b 1
52  salt -I 'neutron:gateway' state.sls neutron.gateway
53
54  salt -I 'nova:compute' state.sls nova
55 +wait_for 5.0 "salt -I 'nova:compute' state.sls armband"
56
57  salt -C 'I@mongodb:server and *01*' state.sls mongodb || true
58  wait_for 10 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
59 diff --git a/mcp/config/states/openstack_noha b/mcp/config/states/openstack_noha
60 index 4c8cbcf8..1cf54240 100755
61 --- a/mcp/config/states/openstack_noha
62 +++ b/mcp/config/states/openstack_noha
63 @@ -53,6 +53,8 @@ salt -I 'ceilometer:agent' state.sls ceilometer
64
65  salt -I 'horizon:server' state.sls horizon
66
67 +salt -I 'nova:compute' state.sls armband
68 +
69  # workaround for the pike horizon is missing css, FUEL-324
70  salt -I 'horizon:server' file.symlink \
71    /var/lib/openstack-dashboard/static \
72 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
73 index c391cfe6..02a813c9 100755
74 --- a/mcp/config/states/virtual_control_plane
75 +++ b/mcp/config/states/virtual_control_plane
76 @@ -27,6 +27,7 @@ if [ "${ERASE_ENV}" -eq 1 ]; then
77  fi
78
79  # KVM libvirt first, VCP deployment
80 +wait_for 5.0 "salt -C 'kvm*' state.sls armband"
81  wait_for 5.0 "salt -C 'kvm*' state.sls libvirt"
82
83  salt -C 'kvm* or cmp*' state.apply salt
84 diff --git a/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff b/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
85 new file mode 100644
86 index 00000000..a480a20c
87 --- /dev/null
88 +++ b/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
89 @@ -0,0 +1,165 @@
90 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
91 +Date: Thu, 24 Aug 2017 10:57:28 +0200
92 +Subject: [PATCH] libvirt: AArch64: ACPI depends on AAVMF
93 +
94 +On AArch64, ACPI should be added to domain XML only if guest UEFI
95 +(AAVMF) is also used.
96 +
97 +[ Alexandru.Avadanii@enea.com ]
98 +- pike rebase: minor context adj
99 +
100 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
101 +Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
102 +
103 +---
104 +
105 +diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
106 +--- a/nova/virt/libvirt/driver.py
107 ++++ b/nova/virt/libvirt/driver.py
108 +@@ -4314,7 +4314,10 @@
109 +
110 +         if (virt_type not in ("lxc", "uml", "parallels", "xen") or
111 +                 (virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
112 +-            guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
113 ++            guestarch = libvirt_utils.get_arch(image_meta)
114 ++            if (guestarch not in (fields.Architecture.ARMV7, fields.Architecture.AARCH64) or
115 ++                image_meta.properties.get('hw_firmware_type') == 'uefi'):
116 ++                    guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
117 +             guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
118 +
119 +         if (virt_type in ("qemu", "kvm") and
120 +--
121 +
122 +From f0f09530ee9169eb29bc28d4f118676d7dc6640e Mon Sep 17 00:00:00 2001
123 +From: Kevin Zhao <kevin.zhao@arm.com>
124 +Date: Tue, 15 Aug 2017 09:52:09 +0000
125 +Subject: [PATCH] Add video type virtio for AArch64
126 +
127 +Currently only "virtio" type is supported on AArch64, and the
128 +other "virrus", "qxl" and "vga" don't work on AArch64 according to
129 +libvirt upstream:
130 +https://www.redhat.com/archives/libvir-list/2016-September/msg00546.html
131 +Then this patch adds the virtio for AArch64 and tweaks the related test cases.
132 +
133 +Closes-bug: #1710766
134 +
135 +[ Alexandru.Avadanii@enea.com ]
136 +Dropped test changes so it applies cleanly on Newton without more backports.
137 +
138 +Change-Id: Iba8a1e671f2b5759b3d9178aa1871d0cf888b26b
139 +Signed-off-by: Kevin Zhao <kevin.zhao@arm.com>
140 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
141 +---
142 +
143 +--- a/nova/virt/libvirt/driver.py
144 ++++ b/nova/virt/libvirt/driver.py
145 +@@ -4342,7 +4342,8 @@ def _check_number_of_serial_console(self, num_ports):
146 +                 allowed=ALLOWED_QEMU_SERIAL_PORTS, virt_type=virt_type)
147 +
148 +     def _add_video_driver(self, guest, image_meta, flavor):
149 +-        VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga", "xen", "qxl")
150 ++        VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga",
151 ++                               "xen", "qxl", "virtio")
152 +         video = vconfig.LibvirtConfigGuestVideo()
153 +         # NOTE(ldbragst): The following logic sets the video.type
154 +         # depending on supported defaults given the architecture,
155 +@@ -4360,6 +4361,10 @@ def _add_video_driver(self, guest, image_meta, flavor):
156 +             # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
157 +             # so use 'vga' instead when running on Power hardware.
158 +             video.type = 'vga'
159 ++        elif guestarch in (fields.Architecture.AARCH64):
160 ++            # NOTE(kevinz): Only virtio device type is supported by AARCH64
161 ++            # so use 'virtio' instead when running on AArch64 hardware.
162 ++            video.type = 'virtio'
163 +         elif CONF.spice.enabled:
164 +             video.type = 'qxl'
165 +         if image_meta.properties.get('hw_video_model'):
166 +---
167 +
168 +From ac6d3cd85ffe94115f15134406ba0d366e938764 Mon Sep 17 00:00:00 2001
169 +From: Charalampos Kominos <Charalampos.Kominos@enea.com>
170 +Date: Tue, 13 Mar 2018 17:02:56 +0100
171 +Subject: [PATCH] Allow nova to create a pty device for aarch64VM
172 +
173 +Armband relies on Ubuntu Xenial and UCA Pike packages. The Nova package in UCA
174 +explicitly disables AArch64 serial console access by removing the second pty
175 +device due to libvirt/QEMU limitations in the Xenial release / UCA Pike.
176 +Since Armband provides newer versions for the core virtualization packages,
177 +we can safely bring back the serial console in Nova.
178 +
179 +JIRA: ARMBAND-352
180 +
181 +Signed-off-by: Charalampos Kominos <charalampos.kominos@enea.com>
182 +---
183 +
184 +--- a/nova/virt/libvirt/driver.py
185 ++++ b/nova/virt/libvirt/driver.py
186 +@@ -4666,13 +4666,11 @@
187 +                   self._is_s390x_guest(image_meta)):
188 +             self._create_consoles_s390x(guest_cfg, instance,
189 +                                         flavor, image_meta)
190 +-        elif (virt_type in ("qemu", "kvm") and
191 +-                  self._is_arm_guest(image_meta)):
192 +-            # NOTE(jamespage): libvirt 2.5.0 as shipped in Ubuntu zesty
193 +-            #                  and the Pike UCA needs to be configured
194 +-            #                  for compatibility on arm64.
195 +-            self._create_consoles_arm(guest_cfg, instance,
196 +-                                      flavor, image_meta)
197 ++
198 ++        #ARMband: Canonical applies a patch to align with libvirt 2.5.0 in UCA repos
199 ++        #         which removes the console on aarch64. Since ARMband uses a newer
200 ++        #         libvirt version we can safely revert that change.
201 ++
202 +         elif virt_type in ("qemu", "kvm"):
203 +             self._create_consoles_qemu_kvm(guest_cfg, instance,
204 +                                         flavor, image_meta)
205 +@@ -4681,12 +4679,6 @@
206 +         s390x_archs = (fields.Architecture.S390, fields.Architecture.S390X)
207 +         return libvirt_utils.get_arch(image_meta) in s390x_archs
208 +
209 +-    def _is_arm_guest(self, image_meta):
210 +-        arm_archs = (fields.Architecture.AARCH64,
211 +-                     fields.Architecture.ARMV7B,
212 +-                     fields.Architecture.ARMV7)
213 +-        return libvirt_utils.get_arch(image_meta) in arm_archs
214 +-
215 +     def _create_consoles_qemu_kvm(self, guest_cfg, instance, flavor,
216 +                                   image_meta):
217 +         char_dev_cls = vconfig.LibvirtConfigGuestSerial
218 +@@ -4716,25 +4708,6 @@
219 +                                     "sclplm")
220 +        self._create_pty_device(guest_cfg, char_dev_cls, "sclp", log_path)
221 +
222 +-    def _create_consoles_arm(self, guest_cfg, instance, flavor, image_meta):
223 +-        char_dev_cls = vconfig.LibvirtConfigGuestConsole
224 +-        log_path = self._get_console_log_path(instance)
225 +-        if CONF.serial_console.enabled:
226 +-            if not self._serial_ports_already_defined(instance):
227 +-                num_ports = hardware.get_number_of_serial_ports(flavor,
228 +-                                                                image_meta)
229 +-                self._check_number_of_serial_console(num_ports)
230 +-                self._create_serial_consoles(guest_cfg, num_ports,
231 +-                                             char_dev_cls, log_path)
232 +-        else:
233 +-            # NOTE(jamespage): Force creation of file device for compatibility
234 +-            #                  with aarch64 + libvirt 2.5.0
235 +-            self._create_file_device(guest_cfg, instance, char_dev_cls,
236 +-                                     force=True)
237 +-        # NOTE(jamespage): Skip creation of pty devices; they only work with
238 +-        #                  the virtio driver which does not capture early
239 +-        #                  boot on aarch64
240 +-
241 +     def _create_pty_device(self, guest_cfg, char_dev_cls, target_type=None,
242 +                            log_path=None):
243 +         def _create_base_dev():
244 +@@ -4772,8 +4745,8 @@
245 +                guest_cfg.add_device(_create_base_dev())
246 +
247 +     def _create_file_device(self, guest_cfg, instance, char_dev_cls,
248 +-                            target_type=None, force=False):
249 +-        if self._is_virtlogd_available() and not force:
250 ++                            target_type=None):
251 ++        if self._is_virtlogd_available():
252 +             return
253 +
254 +         consolelog = char_dev_cls()
255 diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
256 new file mode 100644
257 index 00000000..8a8cf2ab
258 --- /dev/null
259 +++ b/mcp/salt-formulas/armband/init.sls
260 @@ -0,0 +1,7 @@
261 +include:
262 + - armband.qemu_efi
263 + - armband.vgabios
264 + {%- if salt['pkg.version']('python-nova') %}
265 + - armband.nova_libvirt
266 + - armband.nova_config
267 + {%- endif %}
268 diff --git a/mcp/salt-formulas/armband/nova_config.sls b/mcp/salt-formulas/armband/nova_config.sls
269 new file mode 100644
270 index 00000000..31fa031a
271 --- /dev/null
272 +++ b/mcp/salt-formulas/armband/nova_config.sls
273 @@ -0,0 +1,35 @@
274 +{% if grains['virtual'] == 'kvm' %}
275 +nova_virt_type:
276 +  file.replace:
277 +    - name: "/etc/nova/nova.conf"
278 +    - pattern: '^virt_type\s*=.*$'
279 +    - repl: "virt_type = qemu"
280 +nova_compute_virt_type:
281 +  file.replace:
282 +    - name: "/etc/nova/nova-compute.conf"
283 +    - pattern: '^virt_type\s*=.*$'
284 +    - repl: "virt_type = qemu"
285 +{% endif %}
286 +nova_pointer_model:
287 +  file.replace:
288 +    - name: "/etc/nova/nova.conf"
289 +    - pattern: '^#pointer_model\s*=.*$'
290 +    - repl: "pointer_model = ps2mouse"
291 +nova_cpu_mode:
292 +  file.replace:
293 +    - name: "/etc/nova/nova.conf"
294 +    - pattern:  '^cpu_mode\s*=\s*host-passthrough'
295 +    - repl: "cpu_mode = custom"
296 +nova_cpu_model:
297 +  file.replace:
298 +    - name: "/etc/nova/nova.conf"
299 +    - pattern: '^#cpu_model\s*=.*$'
300 +    {% if grains['virtual'] == 'kvm' %}
301 +    - repl: "cpu_model = cortex-a57"
302 +    {% else %}
303 +    - repl: "cpu_model = host"
304 +    {% endif %}
305 +restart_nova-compute:
306 +  cmd:
307 +    - run
308 +    - name: "service nova-compute restart"
309 diff --git a/mcp/salt-formulas/armband/nova_libvirt.sls b/mcp/salt-formulas/armband/nova_libvirt.sls
310 new file mode 100644
311 index 00000000..bc2cbda9
312 --- /dev/null
313 +++ b/mcp/salt-formulas/armband/nova_libvirt.sls
314 @@ -0,0 +1,7 @@
315 +nova-libvirt-aarch64-rollup:
316 +  file.patch:
317 +  - name: /usr/lib/python2.7/dist-packages
318 +  - source: salt://armband/files/nova-libvirt-aarch64-rollup.diff
319 +  - hash: False
320 +  - options: '-p1'
321 +  - 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'
322 diff --git a/mcp/salt-formulas/armband/qemu_efi.sls b/mcp/salt-formulas/armband/qemu_efi.sls
323 new file mode 100644
324 index 00000000..c697dae9
325 --- /dev/null
326 +++ b/mcp/salt-formulas/armband/qemu_efi.sls
327 @@ -0,0 +1,2 @@
328 +qemu-efi:
329 +  pkg.installed
330 diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
331 new file mode 100644
332 index 00000000..500c2bcf
333 --- /dev/null
334 +++ b/mcp/salt-formulas/armband/vgabios.sls
335 @@ -0,0 +1,7 @@
336 +vgabios:
337 +  pkg.installed
338 +/usr/share/qemu:
339 +  file.directory
340 +/usr/share/qemu/vgabios-stdvga.bin:
341 +  file.symlink:
342 +    - target: "/usr/share/vgabios/vgabios.bin"