summaryrefslogtreecommitdiffstats
path: root/patches/opnfv-fuel/0001-mcp-salt-formulas-Add-enable-armband-formula.patch
blob: c09d21a71e2d4c64197291ea06d0e995330a3481 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Copyright (c) 2017 Enea AB and others.
:
: All rights reserved. This program and the accompanying materials
: are made available under the terms of the Apache License, Version 2.0
: which accompanies this distribution, and is available at
: http://www.apache.org/licenses/LICENSE-2.0
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
From: Guillermo Herrero <Guillermo.Herrero@enea.com>
Date: Tue, 25 Jul 2017 00:58:32 +0200
Subject: [PATCH] mcp: salt-formulas: Add & enable armband formula

FIXME: Re-enable apparmor.
FIXME: Detect baremetal and re-enable acceleration.

- install qemu-efi;
- install vgabios;
- disable apparmor as security driver for libvirt (temporary);
- fix missing link for vgabios binary blob;
- nova: virt_type=qemu (temporary, until we support baremetal too);
- nova: pointer_model=ps2mouse since AArch64 has no USB tablet;
- nova: cpu_model=cortex-a57;
- nova: libvirt driver: Add ttyAMA0 by default on AArch64;
- nova: libvirt driver: Use VGA video type by default on AArch64;
- nova: libvirt driver: AArch64: ACPI depends on AAVMF;

Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
---
 mcp/config/states/openstack                        |  2 +
 mcp/config/states/openstack_ha                     |  1 +
 mcp/config/states/virtual_control_plane            |  1 +
 ...ate-vga-console-defaults-for-armv7-aarch64.diff | 48 ++++++++++++++++++++++
 ...nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff | 45 ++++++++++++++++++++
 mcp/salt-formulas/armband/init.sls                 |  6 +++
 mcp/salt-formulas/armband/libvirt_driver.sls       | 11 +++++
 mcp/salt-formulas/armband/nova.sls                 | 30 ++++++++++++++
 mcp/salt-formulas/armband/qemu.sls                 |  7 ++++
 mcp/salt-formulas/armband/vgabios.sls              |  6 +++
 10 files changed, 157 insertions(+)
 create mode 100644 mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
 create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
 create mode 100644 mcp/salt-formulas/armband/init.sls
 create mode 100644 mcp/salt-formulas/armband/libvirt_driver.sls
 create mode 100644 mcp/salt-formulas/armband/nova.sls
 create mode 100644 mcp/salt-formulas/armband/qemu.sls
 create mode 100644 mcp/salt-formulas/armband/vgabios.sls

diff --git a/mcp/config/states/openstack b/mcp/config/states/openstack
index 9683103..624b08e 100755
--- a/mcp/config/states/openstack
+++ b/mcp/config/states/openstack
@@ -41,3 +41,5 @@ salt -I 'ceilometer:server' state.sls ceilometer
 salt -I 'ceilometer:agent' state.sls ceilometer

 salt -I 'horizon:server' state.sls horizon
+
+salt -I 'nova:compute' state.sls armband
diff --git a/mcp/config/states/openstack_ha b/mcp/config/states/openstack_ha
index 230288f..921b216 100755
--- a/mcp/config/states/openstack_ha
+++ b/mcp/config/states/openstack_ha
@@ -50,6 +50,7 @@ salt -I 'neutron:server' state.sls neutron -b 1
 salt -I 'neutron:gateway' state.sls neutron.gateway

 salt -I 'nova:compute' state.sls nova
+salt -I 'nova:compute' state.sls armband

 salt -I 'mongodb:server' state.sls mongodb
 wait_for 90 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
index 58ae335..c645ffd 100755
--- a/mcp/config/states/virtual_control_plane
+++ b/mcp/config/states/virtual_control_plane
@@ -18,6 +18,7 @@ wait_for 90 "! salt 'kvm*' test.ping | tee /dev/stderr | grep -Fq 'Not connected

 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp

+salt -C 'kvm*' state.sls armband
 salt -C 'kvm*' state.sls libvirt

 salt -C '* and not cfg01* and not mas01*' state.apply salt
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
new file mode 100644
index 0000000..a5b08da
--- /dev/null
+++ b/mcp/salt-formulas/armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
@@ -0,0 +1,48 @@
+From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
+Date: Tue, 22 Mar 2016 12:05:09 +0100
+Subject: [PATCH] nova: Update vga, console defaults for armv7, aarch64
+
+Nova hardcodes default options for both video=cirrus and console.
+armv7 and aarch64 VMs require video=vga, and since most applications
+use PL011 serial driver for guests, adding console=ttyAMA0 is also
+a nice UX addition.
+
+Signed-off-by: Stanislaw Kardach <stanislaw.kardach@cavium.com>
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
+
+---
+ usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+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
+index bba9b00..99e86be 100644
+--- a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
++++ b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
+@@ -4179,7 +4179,12 @@ class LibvirtDriver(driver.ComputeDriver):
+         if virt_type == "xen":
+             guest.os_cmdline = "ro root=%s" % root_device_name
+         else:
++            guestarch = libvirt_utils.get_arch(image_meta)
+             guest.os_cmdline = ("root=%s %s" % (root_device_name, CONSOLE))
++            if guestarch in (fields.Architecture.ARMV7,
++                             fields.Architecture.AARCH64):
++                # NOTE(armband): ARM v7/v8 use PL011 drv, add ttyAMA0 console
++                guest.os_cmdline += " console=ttyAMA0"
+             if virt_type == "qemu":
+                 guest.os_cmdline += " no_timer_check"
+         if instance.ramdisk_id:
+@@ -4288,9 +4293,12 @@ class LibvirtDriver(driver.ComputeDriver):
+             video.type = 'xen'
+         elif CONF.libvirt.virt_type == 'parallels':
+             video.type = 'vga'
+-        elif guestarch in (fields.Architecture.PPC,
++        elif guestarch in (fields.Architecture.ARMV7,
++                           fields.Architecture.AARCH64,
++                           fields.Architecture.PPC,
+                            fields.Architecture.PPC64,
+                            fields.Architecture.PPC64LE):
++            # NOTE(armband): Added ARM v7/v8, same as on PPC.
+             # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
+             # so use 'vga' instead when running on Power hardware.
+             video.type = 'vga'
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
new file mode 100644
index 0000000..7c1b78a
--- /dev/null
+++ b/mcp/salt-formulas/armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
@@ -0,0 +1,45 @@
+From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Date: Thu, 24 Aug 2017 10:57:28 +0200
+Subject: [PATCH] libvirt: AArch64: ACPI depends on AAVMF
+
+On AArch64, ACPI should be added to domain XML only if guest UEFI
+(AAVMF) is also used.
+
+Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
+Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
+
+---
+
+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
+--- a/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
++++ b/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
+@@ -4255,7 +4255,7 @@
+             tmhyperv.present = True
+             clk.add_timer(tmhyperv)
+
+-    def _set_features(self, guest, os_type, caps, virt_type):
++    def _set_features(self, guest, os_type, image_meta, caps, virt_type):
+         if virt_type == "xen":
+             # PAE only makes sense in X86
+             if caps.host.cpu.arch in (fields.Architecture.I686,
+@@ -4264,7 +4264,10 @@
+
+         if (virt_type not in ("lxc", "uml", "parallels", "xen") or
+                 (virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
+-            guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
++            guestarch = libvirt_utils.get_arch(image_meta)
++            if (guestarch not in (fields.Architecture.ARMV7, fields.Architecture.AARCH64) or
++                image_meta.properties.get('hw_firmware_type') == 'uefi'):
++                    guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
+             guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
+
+         if (virt_type in ("qemu", "kvm") and
+@@ -4799,7 +4802,7 @@
+             self._conf_non_lxc_uml(virt_type, guest, root_device_name, rescue,
+                     instance, inst_path, image_meta, disk_info)
+
+-        self._set_features(guest, instance.os_type, caps, virt_type)
++        self._set_features(guest, instance.os_type, image_meta, caps, virt_type)
+         self._set_clock(guest, instance.os_type, image_meta, virt_type)
+
+         storage_configs = self._get_guest_storage_config(
diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
new file mode 100644
index 0000000..6e7b6ad
--- /dev/null
+++ b/mcp/salt-formulas/armband/init.sls
@@ -0,0 +1,6 @@
+include:
+ - armband.qemu
+ - armband.vgabios
+ - armband.nova
+ - armband.libvirt_driver
+
diff --git a/mcp/salt-formulas/armband/libvirt_driver.sls b/mcp/salt-formulas/armband/libvirt_driver.sls
new file mode 100644
index 0000000..9b47e2f
--- /dev/null
+++ b/mcp/salt-formulas/armband/libvirt_driver.sls
@@ -0,0 +1,11 @@
+nova-libvirt-vga-console:
+  file.patch:
+  - name: /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
+  - source: salt://armband/files/nova-Update-vga-console-defaults-for-armv7-aarch64.diff
+  - hash: "71b22839913e6351edc70b6d59505f17"
+
+nova-libvirt-ACPI-AAVMF:
+  file.patch:
+  - name: /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
+  - source: salt://armband/files/nova-libvirt-AArch64-ACPI-depends-on-AAVMF.diff
+  - hash: "c02969d59f16f57242eb74a75e46b0cf"
diff --git a/mcp/salt-formulas/armband/nova.sls b/mcp/salt-formulas/armband/nova.sls
new file mode 100644
index 0000000..674f371
--- /dev/null
+++ b/mcp/salt-formulas/armband/nova.sls
@@ -0,0 +1,30 @@
+{% if grains['virtual'] == 'kvm' %}
+nova_virt_type:
+  file.replace:
+    - name: "/etc/nova/nova.conf"
+    - pattern: '^virt_type\s*=.*$'
+    - repl: "virt_type = qemu"
+{% endif %}
+nova_pointer_model:
+  file.replace:
+    - name: "/etc/nova/nova.conf"
+    - pattern: '^#pointer_model\s*=.*$'
+    - repl: "pointer_model = ps2mouse"
+nova_cpu_mode:
+  file.replace:
+    - name: "/etc/nova/nova.conf"
+    - pattern:  '^cpu_mode\s*=\s*host-passthrough'
+    - repl: "cpu_mode = custom"
+nova_cpu_model:
+  file.replace:
+    - name: "/etc/nova/nova.conf"
+    - pattern: '^#cpu_model\s*=.*$'
+    {% if grains['virtual'] == 'kvm' %}
+    - repl: "cpu_model = cortex-a57"
+    {% else %}
+    - repl: "cpu_model = host"
+    {% endif %}
+restart_nova-compute:
+  cmd:
+    - run
+    - name: "service nova-compute restart"
diff --git a/mcp/salt-formulas/armband/qemu.sls b/mcp/salt-formulas/armband/qemu.sls
new file mode 100644
index 0000000..ecdb5ae
--- /dev/null
+++ b/mcp/salt-formulas/armband/qemu.sls
@@ -0,0 +1,7 @@
+qemu-efi:
+  pkg.installed
+/etc/libvirt/qemu.conf:
+  file.replace:
+    - pattern: ^#security_driver =.*$
+    - repl: "security_driver = \"none\""
+
diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
new file mode 100644
index 0000000..a31eafa
--- /dev/null
+++ b/mcp/salt-formulas/armband/vgabios.sls
@@ -0,0 +1,6 @@
+vgabios:
+  pkg.installed
+/usr/share/qemu/vgabios-stdvga.bin:
+  file.symlink:
+    - target: "/usr/share/vgabios/vgabios.bin"
+