u/fuel: Bump & rebase for VCP state split
[armband.git] / patches / opnfv-fuel / 0001-mcp-salt-formulas-Add-enable-armband-formula.patch
1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 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] mcp: salt-formulas: Add & enable armband formula
12
13 FIXME: Re-enable apparmor.
14 FIXME: Detect baremetal and re-enable acceleration.
15
16 - install qemu-efi;
17 - install vgabios;
18 - disable apparmor as security driver for libvirt (temporary);
19 - fix missing link for vgabios binary blob;
20 - nova: virt_type=qemu (temporary, until we support baremetal too);
21 - nova: pointer_model=ps2mouse since AArch64 has no USB tablet;
22 - nova: cpu_model=cortex-a57;
23 - nova: libvirt driver: Add ttyAMA0 by default on AArch64;
24 - nova: libvirt driver: Use VGA video type by default on AArch64;
25 - nova: libvirt driver: AArch64: ACPI depends on AAVMF;
26
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>
30 ---
31  mcp/config/states/openstack                        |  2 +
32  mcp/config/states/openstack_ha                     |  1 +
33  mcp/config/states/virtual_control_plane            |  1 +
34  ...ate-vga-console-defaults-for-armv7-aarch64.diff | 48 ++++++++++++++++++++++
35  ...nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff | 45 ++++++++++++++++++++
36  mcp/salt-formulas/armband/init.sls                 |  6 +++
37  mcp/salt-formulas/armband/libvirt_driver.sls       | 11 +++++
38  mcp/salt-formulas/armband/nova.sls                 | 30 ++++++++++++++
39  mcp/salt-formulas/armband/qemu.sls                 |  7 ++++
40  mcp/salt-formulas/armband/vgabios.sls              |  6 +++
41  10 files changed, 157 insertions(+)
42  create mode 100644 mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
43  create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
44  create mode 100644 mcp/salt-formulas/armband/init.sls
45  create mode 100644 mcp/salt-formulas/armband/libvirt_driver.sls
46  create mode 100644 mcp/salt-formulas/armband/nova.sls
47  create mode 100644 mcp/salt-formulas/armband/qemu.sls
48  create mode 100644 mcp/salt-formulas/armband/vgabios.sls
49
50 diff --git a/mcp/config/states/openstack b/mcp/config/states/openstack
51 index beb6abb..885f2ac 100755
52 --- a/mcp/config/states/openstack
53 +++ b/mcp/config/states/openstack
54 @@ -35,3 +35,5 @@ salt -I 'ceilometer:server' state.sls ceilometer
55  salt -I 'ceilometer:agent' state.sls ceilometer
56
57  salt -I 'horizon:server' state.sls horizon
58 +
59 +salt -I 'nova:compute' state.sls armband
60 diff --git a/mcp/config/states/openstack_ha b/mcp/config/states/openstack_ha
61 index c4c513d..9084678 100755
62 --- a/mcp/config/states/openstack_ha
63 +++ b/mcp/config/states/openstack_ha
64 @@ -44,6 +44,7 @@ salt -I 'neutron:server' state.sls neutron -b 1
65  salt -I 'neutron:gateway' state.sls neutron.gateway
66
67  salt -I 'nova:compute' state.sls nova
68 +salt -I 'nova:compute' state.sls armband
69
70  salt -I 'mongodb:server' state.sls mongodb
71  wait_for 90 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
72 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
73 index 645009b..79ad880 100755
74 --- a/mcp/config/states/virtual_control_plane
75 +++ b/mcp/config/states/virtual_control_plane
76 @@ -12,6 +12,7 @@ wait_for 90 "! salt 'kvm*' test.ping | tee /dev/stderr | grep -Fq 'Not connected
77
78  salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
79
80 +salt -C 'kvm*' state.sls armband
81  salt -C 'kvm*' state.sls libvirt
82
83  salt -C '* and not cfg01* and not mas01*' state.apply salt
84 diff --git a/mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff b/mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
85 new file mode 100644
86 index 0000000..a5b08da
87 --- /dev/null
88 +++ b/mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
89 @@ -0,0 +1,48 @@
90 +From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
91 +Date: Tue, 22 Mar 2016 12:05:09 +0100
92 +Subject: [PATCH] nova: Update vga, console defaults for armv7, aarch64
93 +
94 +Nova hardcodes default options for both video=cirrus and console.
95 +armv7 and aarch64 VMs require video=vga, and since most applications
96 +use PL011 serial driver for guests, adding console=ttyAMA0 is also
97 +a nice UX addition.
98 +
99 +Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
100 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
101 +Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
102 +
103 +---
104 + usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py | 10 +++++++++-
105 + 1 file changed, 9 insertions(+), 1 deletion(-)
106 +
107 +diff --git a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
108 +index bba9b00..99e86be 100644
109 +--- a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
110 ++++ b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
111 +@@ -4179,7 +4179,12 @@ class LibvirtDriver(driver.ComputeDriver):
112 +         if virt_type == "xen":
113 +             guest.os_cmdline = "ro root=%s" % root_device_name
114 +         else:
115 ++            guestarch = libvirt_utils.get_arch(image_meta)
116 +             guest.os_cmdline = ("root=%s %s" % (root_device_name, CONSOLE))
117 ++            if guestarch in (fields.Architecture.ARMV7,
118 ++                             fields.Architecture.AARCH64):
119 ++                # NOTE(armband): ARM v7/v8 use PL011 drv, add ttyAMA0 console
120 ++                guest.os_cmdline += " console=ttyAMA0"
121 +             if virt_type == "qemu":
122 +                 guest.os_cmdline += " no_timer_check"
123 +         if instance.ramdisk_id:
124 +@@ -4288,9 +4293,12 @@ class LibvirtDriver(driver.ComputeDriver):
125 +             video.type = 'xen'
126 +         elif CONF.libvirt.virt_type == 'parallels':
127 +             video.type = 'vga'
128 +-        elif guestarch in (fields.Architecture.PPC,
129 ++        elif guestarch in (fields.Architecture.ARMV7,
130 ++                           fields.Architecture.AARCH64,
131 ++                           fields.Architecture.PPC,
132 +                            fields.Architecture.PPC64,
133 +                            fields.Architecture.PPC64LE):
134 ++            # NOTE(armband): Added ARM v7/v8, same as on PPC.
135 +             # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
136 +             # so use 'vga' instead when running on Power hardware.
137 +             video.type = 'vga'
138 diff --git a/mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff b/mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
139 new file mode 100644
140 index 0000000..7c1b78a
141 --- /dev/null
142 +++ b/mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
143 @@ -0,0 +1,45 @@
144 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
145 +Date: Thu, 24 Aug 2017 10:57:28 +0200
146 +Subject: [PATCH] libvirt: AArch64: ACPI depends on AAVMF
147 +
148 +On AArch64, ACPI should be added to domain XML only if guest UEFI
149 +(AAVMF) is also used.
150 +
151 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
152 +Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
153 +
154 +---
155 +
156 +diff --git a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
157 +--- a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
158 ++++ b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
159 +@@ -4255,7 +4255,7 @@
160 +             tmhyperv.present = True
161 +             clk.add_timer(tmhyperv)
162 +
163 +-    def _set_features(self, guest, os_type, caps, virt_type):
164 ++    def _set_features(self, guest, os_type, image_meta, caps, virt_type):
165 +         if virt_type == "xen":
166 +             # PAE only makes sense in X86
167 +             if caps.host.cpu.arch in (fields.Architecture.I686,
168 +@@ -4264,7 +4264,10 @@
169 +
170 +         if (virt_type not in ("lxc", "uml", "parallels", "xen") or
171 +                 (virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
172 +-            guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
173 ++            guestarch = libvirt_utils.get_arch(image_meta)
174 ++            if (guestarch not in (fields.Architecture.ARMV7, fields.Architecture.AARCH64) or
175 ++                image_meta.properties.get('hw_firmware_type') == 'uefi'):
176 ++                    guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
177 +             guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
178 +
179 +         if (virt_type in ("qemu", "kvm") and
180 +@@ -4799,7 +4802,7 @@
181 +             self._conf_non_lxc_uml(virt_type, guest, root_device_name, rescue,
182 +                     instance, inst_path, image_meta, disk_info)
183 +
184 +-        self._set_features(guest, instance.os_type, caps, virt_type)
185 ++        self._set_features(guest, instance.os_type, image_meta, caps, virt_type)
186 +         self._set_clock(guest, instance.os_type, image_meta, virt_type)
187 +
188 +         storage_configs = self._get_guest_storage_config(
189 diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
190 new file mode 100644
191 index 0000000..6e7b6ad
192 --- /dev/null
193 +++ b/mcp/salt-formulas/armband/init.sls
194 @@ -0,0 +1,6 @@
195 +include:
196 + - armband.qemu
197 + - armband.vgabios
198 + - armband.nova
199 + - armband.libvirt_driver
200 +
201 diff --git a/mcp/salt-formulas/armband/libvirt_driver.sls b/mcp/salt-formulas/armband/libvirt_driver.sls
202 new file mode 100644
203 index 0000000..9b47e2f
204 --- /dev/null
205 +++ b/mcp/salt-formulas/armband/libvirt_driver.sls
206 @@ -0,0 +1,11 @@
207 +nova-libvirt-vga-console:
208 +  file.patch:
209 +  - name: /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
210 +  - source: salt://armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
211 +  - hash: "71b22839913e6351edc70b6d59505f17"
212 +
213 +nova-libvirt-ACPI-AAVMF:
214 +  file.patch:
215 +  - name: /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
216 +  - source: salt://armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
217 +  - hash: "c02969d59f16f57242eb74a75e46b0cf"
218 diff --git a/mcp/salt-formulas/armband/nova.sls b/mcp/salt-formulas/armband/nova.sls
219 new file mode 100644
220 index 0000000..674f371
221 --- /dev/null
222 +++ b/mcp/salt-formulas/armband/nova.sls
223 @@ -0,0 +1,30 @@
224 +{% if grains['virtual'] == 'kvm' %}
225 +nova_virt_type:
226 +  file.replace:
227 +    - name: "/etc/nova/nova.conf"
228 +    - pattern: '^virt_type\s*=.*$'
229 +    - repl: "virt_type = qemu"
230 +{% endif %}
231 +nova_pointer_model:
232 +  file.replace:
233 +    - name: "/etc/nova/nova.conf"
234 +    - pattern: '^#pointer_model\s*=.*$'
235 +    - repl: "pointer_model = ps2mouse"
236 +nova_cpu_mode:
237 +  file.replace:
238 +    - name: "/etc/nova/nova.conf"
239 +    - pattern:  '^cpu_mode\s*=\s*host-passthrough'
240 +    - repl: "cpu_mode = custom"
241 +nova_cpu_model:
242 +  file.replace:
243 +    - name: "/etc/nova/nova.conf"
244 +    - pattern: '^#cpu_model\s*=.*$'
245 +    {% if grains['virtual'] == 'kvm' %}
246 +    - repl: "cpu_model = cortex-a57"
247 +    {% else %}
248 +    - repl: "cpu_model = host"
249 +    {% endif %}
250 +restart_nova-compute:
251 +  cmd:
252 +    - run
253 +    - name: "service nova-compute restart"
254 diff --git a/mcp/salt-formulas/armband/qemu.sls b/mcp/salt-formulas/armband/qemu.sls
255 new file mode 100644
256 index 0000000..ecdb5ae
257 --- /dev/null
258 +++ b/mcp/salt-formulas/armband/qemu.sls
259 @@ -0,0 +1,7 @@
260 +qemu-efi:
261 +  pkg.installed
262 +/etc/libvirt/qemu.conf:
263 +  file.replace:
264 +    - pattern: ^#security_driver =.*$
265 +    - repl: "security_driver = \"none\""
266 +
267 diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
268 new file mode 100644
269 index 0000000..a31eafa
270 --- /dev/null
271 +++ b/mcp/salt-formulas/armband/vgabios.sls
272 @@ -0,0 +1,6 @@
273 +vgabios:
274 +  pkg.installed
275 +/usr/share/qemu/vgabios-stdvga.bin:
276 +  file.symlink:
277 +    - target: "/usr/share/vgabios/vgabios.bin"
278 +