dfcf75848b058678c2744e0e0879dae612cf94d3
[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 conf: cpu_model=cortex-a57 (only for virtual deploys);
19 - nova conf: virt_type=qemu (only for virtual deploys);
20 - nova compute conf: virt_type=qemu (only for virtual deploys);
21 - nova conf: pointer_model=ps2mouse since AArch64 has no USB tablet;
22
23 [1] https://github.com/openstack/nova/commit/f0f0953
24
25 Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
26 Signed-off-by: Charalampos Kominos <Charalampos.Kominos@enea.com>
27 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
28 ---
29  mcp/config/states/openstack_ha                     |  1 +
30  mcp/config/states/openstack_noha                   |  2 +
31  mcp/config/states/virtual_control_plane            |  1 +
32  .../armband/files/nova-libvirt-aarch64-rollup.diff | 76 ++++++++++++++++++++++
33  mcp/salt-formulas/armband/init.sls                 |  7 ++
34  mcp/salt-formulas/armband/nova_config.sls          | 35 ++++++++++
35  mcp/salt-formulas/armband/nova_libvirt.sls         |  7 ++
36  mcp/salt-formulas/armband/qemu_efi.sls             |  2 +
37  mcp/salt-formulas/armband/vgabios.sls              |  7 ++
38  9 files changed, 138 insertions(+)
39  create mode 100644 mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
40  create mode 100644 mcp/salt-formulas/armband/init.sls
41  create mode 100644 mcp/salt-formulas/armband/nova_config.sls
42  create mode 100644 mcp/salt-formulas/armband/nova_libvirt.sls
43  create mode 100644 mcp/salt-formulas/armband/qemu_efi.sls
44  create mode 100644 mcp/salt-formulas/armband/vgabios.sls
45
46 diff --git a/mcp/config/states/openstack_ha b/mcp/config/states/openstack_ha
47 index 07bd6b48..7b37bd97 100755
48 --- a/mcp/config/states/openstack_ha
49 +++ b/mcp/config/states/openstack_ha
50 @@ -52,6 +52,7 @@ salt -I 'neutron:server' state.sls neutron -b 1
51  salt -I 'neutron:gateway' state.sls neutron.gateway
52
53  salt -I 'nova:compute' state.sls nova
54 +wait_for 5.0 "salt -I 'nova:compute' state.sls armband"
55
56  salt -C 'I@mongodb:server and *01*' state.sls mongodb || true
57  wait_for 10.0 "salt -C 'I@mongodb:server and *01*' cmd.run 'mongo localhost:27017/admin'"
58 diff --git a/mcp/config/states/openstack_noha b/mcp/config/states/openstack_noha
59 index 4c8cbcf8..1cf54240 100755
60 --- a/mcp/config/states/openstack_noha
61 +++ b/mcp/config/states/openstack_noha
62 @@ -53,6 +53,8 @@ salt -I 'ceilometer:agent' state.sls ceilometer
63
64  salt -I 'horizon:server' state.sls horizon
65
66 +salt -I 'nova:compute' state.sls armband
67 +
68  # workaround for the pike horizon is missing css, FUEL-324
69  salt -I 'horizon:server' file.symlink \
70    /var/lib/openstack-dashboard/static \
71 diff --git a/mcp/config/states/virtual_control_plane b/mcp/config/states/virtual_control_plane
72 index c391cfe6..02a813c9 100755
73 --- a/mcp/config/states/virtual_control_plane
74 +++ b/mcp/config/states/virtual_control_plane
75 @@ -27,6 +27,7 @@ if [ "${ERASE_ENV}" -eq 1 ]; then
76  fi
77
78  # KVM libvirt first, VCP deployment
79 +wait_for 5.0 "salt -C 'kvm*' state.sls armband"
80  wait_for 5.0 "salt -C 'kvm*' state.sls libvirt"
81
82  salt -C 'kvm* or cmp*' state.apply salt
83 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 new file mode 100644
85 index 00000000..36ddf72b
86 --- /dev/null
87 +++ b/mcp/salt-formulas/armband/files/nova-libvirt-aarch64-rollup.diff
88 @@ -0,0 +1,76 @@
89 +From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
90 +Date: Thu, 24 Aug 2017 10:57:28 +0200
91 +Subject: [PATCH] libvirt: AArch64: ACPI depends on AAVMF
92 +
93 +On AArch64, ACPI should be added to domain XML only if guest UEFI
94 +(AAVMF) is also used.
95 +
96 +[ Alexandru.Avadanii@enea.com ]
97 +- pike rebase: minor context adj
98 +
99 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
100 +Signed-off-by: Ciprian Barbu <ciprian.barbu@enea.com>
101 +
102 +---
103 +
104 +diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
105 +--- a/nova/virt/libvirt/driver.py
106 ++++ b/nova/virt/libvirt/driver.py
107 +@@ -4314,7 +4314,10 @@
108 +
109 +         if (virt_type not in ("lxc", "uml", "parallels", "xen") or
110 +                 (virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
111 +-            guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
112 ++            guestarch = libvirt_utils.get_arch(image_meta)
113 ++            if (guestarch not in (fields.Architecture.ARMV7, fields.Architecture.AARCH64) or
114 ++                image_meta.properties.get('hw_firmware_type') == 'uefi'):
115 ++                    guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
116 +             guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
117 +
118 +         if (virt_type in ("qemu", "kvm") and
119 +--
120 +
121 +From f0f09530ee9169eb29bc28d4f118676d7dc6640e Mon Sep 17 00:00:00 2001
122 +From: Kevin Zhao <kevin.zhao@arm.com>
123 +Date: Tue, 15 Aug 2017 09:52:09 +0000
124 +Subject: [PATCH] Add video type virtio for AArch64
125 +
126 +Currently only "virtio" type is supported on AArch64, and the
127 +other "virrus", "qxl" and "vga" don't work on AArch64 according to
128 +libvirt upstream:
129 +https://www.redhat.com/archives/libvir-list/2016-September/msg00546.html
130 +Then this patch adds the virtio for AArch64 and tweaks the related test cases.
131 +
132 +Closes-bug: #1710766
133 +
134 +[ Alexandru.Avadanii@enea.com ]
135 +Dropped test changes so it applies cleanly on Newton without more backports.
136 +
137 +Change-Id: Iba8a1e671f2b5759b3d9178aa1871d0cf888b26b
138 +Signed-off-by: Kevin Zhao <kevin.zhao@arm.com>
139 +Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
140 +---
141 +
142 +--- a/nova/virt/libvirt/driver.py
143 ++++ b/nova/virt/libvirt/driver.py
144 +@@ -4342,7 +4342,8 @@ def _check_number_of_serial_console(self, num_ports):
145 +                 allowed=ALLOWED_QEMU_SERIAL_PORTS, virt_type=virt_type)
146 +
147 +     def _add_video_driver(self, guest, image_meta, flavor):
148 +-        VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga", "xen", "qxl")
149 ++        VALID_VIDEO_DEVICES = ("vga", "cirrus", "vmvga",
150 ++                               "xen", "qxl", "virtio")
151 +         video = vconfig.LibvirtConfigGuestVideo()
152 +         # NOTE(ldbragst): The following logic sets the video.type
153 +         # depending on supported defaults given the architecture,
154 +@@ -4360,6 +4361,10 @@ def _add_video_driver(self, guest, image_meta, flavor):
155 +             # NOTE(ldbragst): PowerKVM doesn't support 'cirrus' be default
156 +             # so use 'vga' instead when running on Power hardware.
157 +             video.type = 'vga'
158 ++        elif guestarch in (fields.Architecture.AARCH64):
159 ++            # NOTE(kevinz): Only virtio device type is supported by AARCH64
160 ++            # so use 'virtio' instead when running on AArch64 hardware.
161 ++            video.type = 'virtio'
162 +         elif CONF.spice.enabled:
163 +             video.type = 'qxl'
164 +         if image_meta.properties.get('hw_video_model'):
165 diff --git a/mcp/salt-formulas/armband/init.sls b/mcp/salt-formulas/armband/init.sls
166 new file mode 100644
167 index 00000000..8a8cf2ab
168 --- /dev/null
169 +++ b/mcp/salt-formulas/armband/init.sls
170 @@ -0,0 +1,7 @@
171 +include:
172 + - armband.qemu_efi
173 + - armband.vgabios
174 + {%- if salt['pkg.version']('python-nova') %}
175 + - armband.nova_libvirt
176 + - armband.nova_config
177 + {%- endif %}
178 diff --git a/mcp/salt-formulas/armband/nova_config.sls b/mcp/salt-formulas/armband/nova_config.sls
179 new file mode 100644
180 index 00000000..31fa031a
181 --- /dev/null
182 +++ b/mcp/salt-formulas/armband/nova_config.sls
183 @@ -0,0 +1,35 @@
184 +{% if grains['virtual'] == 'kvm' %}
185 +nova_virt_type:
186 +  file.replace:
187 +    - name: "/etc/nova/nova.conf"
188 +    - pattern: '^virt_type\s*=.*$'
189 +    - repl: "virt_type = qemu"
190 +nova_compute_virt_type:
191 +  file.replace:
192 +    - name: "/etc/nova/nova-compute.conf"
193 +    - pattern: '^virt_type\s*=.*$'
194 +    - repl: "virt_type = qemu"
195 +{% endif %}
196 +nova_pointer_model:
197 +  file.replace:
198 +    - name: "/etc/nova/nova.conf"
199 +    - pattern: '^#pointer_model\s*=.*$'
200 +    - repl: "pointer_model = ps2mouse"
201 +nova_cpu_mode:
202 +  file.replace:
203 +    - name: "/etc/nova/nova.conf"
204 +    - pattern:  '^cpu_mode\s*=\s*host-passthrough'
205 +    - repl: "cpu_mode = custom"
206 +nova_cpu_model:
207 +  file.replace:
208 +    - name: "/etc/nova/nova.conf"
209 +    - pattern: '^#cpu_model\s*=.*$'
210 +    {% if grains['virtual'] == 'kvm' %}
211 +    - repl: "cpu_model = cortex-a57"
212 +    {% else %}
213 +    - repl: "cpu_model = host"
214 +    {% endif %}
215 +restart_nova-compute:
216 +  cmd:
217 +    - run
218 +    - name: "service nova-compute restart"
219 diff --git a/mcp/salt-formulas/armband/nova_libvirt.sls b/mcp/salt-formulas/armband/nova_libvirt.sls
220 new file mode 100644
221 index 00000000..ff93db80
222 --- /dev/null
223 +++ b/mcp/salt-formulas/armband/nova_libvirt.sls
224 @@ -0,0 +1,7 @@
225 +nova-libvirt-aarch64-rollup:
226 +  file.patch:
227 +  - name: /usr/lib/python2.7/dist-packages
228 +  - source: salt://armband/files/nova-libvirt-aarch64-rollup.diff
229 +  - hash: False
230 +  - options: '-p1'
231 +  - 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 -r - < /var/cache/salt/minion/files/base/armband/files/nova-libvirt-aarch64-rollup.diff'
232 diff --git a/mcp/salt-formulas/armband/qemu_efi.sls b/mcp/salt-formulas/armband/qemu_efi.sls
233 new file mode 100644
234 index 00000000..c697dae9
235 --- /dev/null
236 +++ b/mcp/salt-formulas/armband/qemu_efi.sls
237 @@ -0,0 +1,2 @@
238 +qemu-efi:
239 +  pkg.installed
240 diff --git a/mcp/salt-formulas/armband/vgabios.sls b/mcp/salt-formulas/armband/vgabios.sls
241 new file mode 100644
242 index 00000000..500c2bcf
243 --- /dev/null
244 +++ b/mcp/salt-formulas/armband/vgabios.sls
245 @@ -0,0 +1,7 @@
246 +vgabios:
247 +  pkg.installed
248 +/usr/share/qemu:
249 +  file.directory
250 +/usr/share/qemu/vgabios-stdvga.bin:
251 +  file.symlink:
252 +    - target: "/usr/share/vgabios/vgabios.bin"