Merge lp:~raharper/curtin/trunk.uefi.v2 into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Merged
Merged at revision: 355
Proposed branch: lp:~raharper/curtin/trunk.uefi.v2
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 667 lines (+300/-88)
12 files modified
curtin/commands/curthooks.py (+6/-0)
examples/tests/basic.yaml (+1/-1)
examples/tests/uefi_basic.yaml (+42/-0)
helpers/common (+20/-8)
tests/vmtests/__init__.py (+39/-2)
tests/vmtests/test_basic.py (+1/-1)
tests/vmtests/test_lvm.py (+5/-5)
tests/vmtests/test_mdadm_bcache.py (+54/-53)
tests/vmtests/test_raid5_bcache.py (+2/-2)
tests/vmtests/test_uefi_basic.py (+83/-0)
tools/launch (+46/-16)
tools/vmtest-system-setup (+1/-0)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.uefi.v2
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser (community) Needs Fixing
Review via email: mp+286810@code.launchpad.net

Description of the change

  vmtests: implement uefi boot mode via pflash

  Add support for uefi to tools/launch and teach vmtests to switch to uefi
  pflash mode it requested. vmtests generates and supplies the writable
  nvram file that's passed to launch now. The basic uefi test currently
  checks that expected files are in /sys/firmware/efi/*.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

some comments inline.
And one general one.
I think that adding this will break vmtest on venonat (our vmtest host). That is because it is most likely trusty and has qemu at trusty level which I think does not support -pflash and uefi in this manner. :-(

So... I think to deal with that we almost have to skip these tests somehow.

review: Needs Fixing
Revision history for this message
Scott Moser (smoser) wrote :

wrt to the --no-nvram, i actually want to have a way to tell curtin that it should or should not do that, rather than just always *not* doing it (as maas wants).

Then we could config this behavior so that it would update nvram in our tests, but the default would be to not do it.

lp:~raharper/curtin/trunk.uefi.v2 updated
354. By Ryan Harper

drop debug in uefi yaml

355. By Ryan Harper

Install ovmf in system-setup

356. By Ryan Harper

vmtest: Add comment for using yaml.dump() when assembling cloud-config-archive

357. By Ryan Harper

tools/launch: quote ovmf/nvram file variables

358. By Ryan Harper

vmtests: fix uefi booting on trusty host

Handle trusty OVMF package which does not split code from vars.
Introduce a new grub config variable 'update_nvram', default to False
to allow MAAS use retain control over host boot. In vmtest export a
config file which tests update_nvram to True to allow grub to set
the boot value.

359. By Ryan Harper

vmtests: fix up uefi launching on hosts with split uefi code/vars

360. By Ryan Harper

from trunk

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~raharper/curtin/trunk.uefi.v2 updated
361. By Ryan Harper

pep8 fix formatting

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

This passes all tests on diglett; however, merge with trunk 2 tests fail due to the HWE changes which break the Psuedo test classes (hwe support added an additional required parameter krel).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'curtin/commands/curthooks.py'
2--- curtin/commands/curthooks.py 2016-01-07 16:21:29 +0000
3+++ curtin/commands/curthooks.py 2016-02-22 23:00:54 +0000
4@@ -395,6 +395,12 @@
5 args = ['install-grub']
6 if util.is_uefi_bootable():
7 args.append("--uefi")
8+ if grubcfg.get('update_nvram', False):
9+ LOG.debug("GRUB UEFI enabling NVRAM updates")
10+ args.append("--update-nvram")
11+ else:
12+ LOG.debug("NOT enabling UEFI nvram updates")
13+ LOG.debug("Target system may not boot")
14 args.append(target)
15 util.subp(args + instdevs, env=env)
16
17
18=== modified file 'examples/tests/basic.yaml'
19--- examples/tests/basic.yaml 2016-02-12 04:13:45 +0000
20+++ examples/tests/basic.yaml 2016-02-22 23:00:54 +0000
21@@ -57,7 +57,7 @@
22 - id: pnum_disk
23 type: disk
24 path: /dev/vde
25- name: sparedisk
26+ name: pnum_disk
27 wipe: superblock
28 ptable: gpt
29 - id: pnum_disk_p1
30
31=== added file 'examples/tests/uefi_basic.yaml'
32--- examples/tests/uefi_basic.yaml 1970-01-01 00:00:00 +0000
33+++ examples/tests/uefi_basic.yaml 2016-02-22 23:00:54 +0000
34@@ -0,0 +1,42 @@
35+storage:
36+ config:
37+ - id: id_disk0
38+ type: disk
39+ name: main_disk
40+ path: /dev/vdb
41+ ptable: gpt
42+ wipe: superblock
43+ grub_device: true
44+ - device: id_disk0
45+ flag: boot
46+ id: id_disk0_part1
47+ number: 1
48+ offset: 1M
49+ size: 499M
50+ type: partition
51+ wipe: superblock
52+ - device: id_disk0
53+ id: id_disk0_part2
54+ number: 2
55+ size: 3G
56+ type: partition
57+ wipe: superblock
58+ - fstype: fat32
59+ id: id_efi_format
60+ label: efi
61+ type: format
62+ volume: id_disk0_part1
63+ - fstype: ext4
64+ id: id_root_format
65+ label: root
66+ type: format
67+ volume: id_disk0_part2
68+ - device: id_root_format
69+ id: id_root_mount
70+ path: /
71+ type: mount
72+ - device: id_efi_format
73+ id: id_efi_mount
74+ path: /boot/efi
75+ type: mount
76+ version: 1
77
78=== modified file 'helpers/common'
79--- helpers/common 2015-09-25 02:02:07 +0000
80+++ helpers/common 2016-02-22 23:00:54 +0000
81@@ -34,7 +34,8 @@
82 perform grub-install with mount-point onto target-dev.
83
84 options:
85- --uefi install grub-efi instead of grub-pc
86+ --uefi install grub-efi instead of grub-pc
87+ --update-nvram request grub to update nvram
88 EOF
89 [ $# -eq 0 ] || echo "$@"
90 }
91@@ -536,18 +537,20 @@
92 }
93
94 install_grub() {
95- local long_opts="uefi"
96+ local long_opts="uefi,update-nvram"
97 local getopt_out="" mp_efi=""
98 getopt_out=$(getopt --name "${0##*/}" \
99 --options "" --long "${long_opts}" -- "$@") &&
100 eval set -- "${getopt_out}"
101
102 local uefi=0
103+ local update_nvram=0
104
105 while [ $# -ne 0 ]; do
106 cur="$1"; next="$2";
107 case "$cur" in
108 --uefi) uefi=$((${uefi}+1));;
109+ --update-nvram) update_nvram=$((${update_nvram}+1));;
110 --) shift; break;;
111 esac
112 shift;
113@@ -665,17 +668,26 @@
114 grubdevs=( "${grubdevs_new[@]}" )
115
116 if [ "$uefi" -ge 1 ]; then
117+ nvram="--no-nvram"
118+ if [ "$update_nvram" -ge 1 ]; then
119+ nvram=""
120+ fi
121 debug 1 "installing ${grub_name} to: /boot/efi"
122 chroot "$mp" env DEBIAN_FRONTEND=noninteractive sh -ec '
123 dpkg-reconfigure "$1"
124 update-grub
125- # grub-install in 12.04 does not contain --no-nvram
126- no_nvram="--no-nvram"
127- grub-install --help | grep -q -- "$no_nvram" ||
128- no_nvram=""
129- grub-install --target=$2 --efi-directory=/boot/efi \
130+ # grub-install in 12.04 does not contain --no-nvram, --target,
131+ # or --efi-directory
132+ target="--target=$2"
133+ no_nvram="$3"
134+ efi_dir="--efi-directory=/boot/efi"
135+ gi_out=$(grub-install --help 2>&1)
136+ echo "$gi_out" | grep -q -- "$no_nvram" || no_nvram=""
137+ echo "$gi_out" | grep -q -- "--target" || target=""
138+ echo "$gi_out" | grep -q -- "--efi-directory" || efi_dir=""
139+ grub-install $target $efi_dir \
140 --bootloader-id=ubuntu --recheck $no_nvram' -- \
141- "${grub_name}" "${grub_target}" </dev/null ||
142+ "${grub_name}" "${grub_target}" "$nvram" </dev/null ||
143 { error "failed to install grub!"; return 1; }
144 else
145 debug 1 "installing ${grub_name} to: ${grubdevs[*]}"
146
147=== modified file 'tests/vmtests/__init__.py'
148--- tests/vmtests/__init__.py 2016-02-22 12:50:17 +0000
149+++ tests/vmtests/__init__.py 2016-02-22 23:00:54 +0000
150@@ -11,6 +11,7 @@
151 import subprocess
152 import textwrap
153 import time
154+import yaml
155 import curtin.net as curtin_net
156 import curtin.util as util
157
158@@ -36,6 +37,13 @@
159 KEEP_DATA = {"pass": "none", "fail": "all"}
160 INSTALL_PASS_MSG = "Installation finished. No error reported."
161 IMAGE_SYNCS = []
162+OVMF_CODE = "/usr/share/OVMF/OVMF_CODE.fd"
163+OVMF_VARS = "/usr/share/OVMF/OVMF_VARS.fd"
164+# precise -> vivid don't have split UEFI firmware, fallback
165+if not os.path.exists(OVMF_CODE):
166+ OVMF_CODE = "/usr/share/ovmf/OVMF.fd"
167+ OVMF_VARS = OVMF_CODE
168+
169
170 DEFAULT_BRIDGE = os.environ.get("CURTIN_VMTEST_BRIDGE", "user")
171
172@@ -345,6 +353,7 @@
173 extra_disks = []
174 boot_timeout = 300
175 install_timeout = 600
176+ uefi = False
177
178 # these get set from base_vm_classes
179 release = None
180@@ -432,6 +441,20 @@
181 fp.write(json.dumps({'apt_proxy': proxy}) + "\n")
182 configs.append(proxy_config)
183
184+ if cls.uefi:
185+ logger.debug("Testcase requested launching with UEFI")
186+
187+ # always attempt to update target nvram (via grub)
188+ grub_config = os.path.join(cls.td.install, 'grub.cfg')
189+ with open(grub_config, "w") as fp:
190+ fp.write(json.dumps({'grub': {'update_nvram': True}}))
191+ configs.append(grub_config)
192+
193+ # make our own copy so we can store guest modified values
194+ nvram = os.path.join(cls.td.disks, "ovmf_vars.fd")
195+ shutil.copy(OVMF_VARS, nvram)
196+ cmd.extend(["--uefi", nvram])
197+
198 cmd.extend(netdevs + ["--disk", cls.td.target_disk] + extra_disks +
199 [boot_img, "--kernel=%s" % boot_kernel, "--initrd=%s" %
200 boot_initrd, "--", "curtin", "-vv", "install"] +
201@@ -491,6 +514,16 @@
202 if not cls.interactive:
203 cmd.extend(["-nographic", "-serial", "file:" + cls.boot_log])
204
205+ if cls.uefi:
206+ logger.debug("Testcase requested booting with UEFI")
207+ uefi_opts = ["-drive", "if=pflash,format=raw,file=" + nvram]
208+ if OVMF_CODE != OVMF_VARS:
209+ # reorder opts, code then writable space
210+ uefi_opts = (["-drive",
211+ "if=pflash,format=raw,readonly,file=" +
212+ OVMF_CODE] + uefi_opts)
213+ cmd.extend(uefi_opts)
214+
215 # run vm with installed system, fail if timeout expires
216 try:
217 logger.info('Booting target image: {}'.format(cls.boot_log))
218@@ -629,7 +662,7 @@
219 if (os.path.exists(fpath) and self.disk_to_check is not None):
220 with open(fpath, "r") as fp:
221 contents = fp.read().splitlines()
222- for diskname, part in self.disk_to_check.items():
223+ for diskname, part in self.disk_to_check:
224 if part is not 0:
225 link = diskname + "-part" + str(part)
226 self.assertIn(link, contents)
227@@ -809,8 +842,12 @@
228
229 ssh_keys, _err = util.subp(['tools/ssh-keys-list', 'cloud-config'],
230 capture=True)
231+ # precises' cloud-init version has limited support for cloud-config-archive
232+ # and expects cloud-config pieces to be appendable to a single file and
233+ # yaml.load()'able. Resolve this by using yaml.dump() when generating
234+ # a list of parts
235 parts = [{'type': 'text/cloud-config',
236- 'content': json.dumps(base_cloudconfig, indent=1)},
237+ 'content': yaml.dump(base_cloudconfig, indent=1)},
238 {'type': 'text/cloud-config', 'content': ssh_keys}]
239
240 output_dir_macro = 'OUTPUT_COLLECT_D'
241
242=== modified file 'tests/vmtests/test_basic.py'
243--- tests/vmtests/test_basic.py 2016-02-22 16:50:13 +0000
244+++ tests/vmtests/test_basic.py 2016-02-22 23:00:54 +0000
245@@ -14,7 +14,7 @@
246 install_timeout = 600
247 boot_timeout = 120
248 extra_disks = ['128G', '128G', '4G']
249- disk_to_check = {'main_disk': 1, 'main_disk': 2}
250+ disk_to_check = [('main_disk', 1), ('main_disk', 2)]
251 collect_scripts = [textwrap.dedent("""
252 cd OUTPUT_COLLECT_D
253 blkid -o export /dev/vda > blkid_output_vda
254
255=== modified file 'tests/vmtests/test_lvm.py'
256--- tests/vmtests/test_lvm.py 2016-02-22 17:27:07 +0000
257+++ tests/vmtests/test_lvm.py 2016-02-22 23:00:54 +0000
258@@ -21,11 +21,11 @@
259 '/dev/vg1/lv1': '/srv/data',
260 '/dev/vg1/lv2': '/srv/backup',
261 }
262- disk_to_check = {'main_disk': 1,
263- 'main_disk': 5,
264- 'main_disk': 6,
265- 'vg1-lv1': 0,
266- 'vg1-lv2': 0}
267+ disk_to_check = [('main_disk', 1),
268+ ('main_disk', 5),
269+ ('main_disk', 6),
270+ ('vg1-lv1', 0),
271+ ('vg1-lv2', 0)]
272
273 def test_lvs(self):
274 self.check_file_strippedline("lvs", "lv1=vg1")
275
276=== modified file 'tests/vmtests/test_mdadm_bcache.py'
277--- tests/vmtests/test_mdadm_bcache.py 2015-12-17 22:07:00 +0000
278+++ tests/vmtests/test_mdadm_bcache.py 2016-02-22 23:00:54 +0000
279@@ -34,15 +34,15 @@
280
281 class TestMdadmBcacheAbs(TestMdadmAbs):
282 conf_file = "examples/tests/mdadm_bcache.yaml"
283- disk_to_check = {'main_disk': 1,
284- 'main_disk': 2,
285- 'main_disk': 3,
286- 'main_disk': 4,
287- 'main_disk': 5,
288- 'main_disk': 6,
289- 'md0': 0,
290- 'cached_array': 0,
291- 'cached_array_2': 0}
292+ disk_to_check = [('main_disk', 1),
293+ ('main_disk', 2),
294+ ('main_disk', 3),
295+ ('main_disk', 4),
296+ ('main_disk', 5),
297+ ('main_disk', 6),
298+ ('md0', 0),
299+ ('cached_array', 0),
300+ ('cached_array_2', 0)]
301
302 collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
303 cd OUTPUT_COLLECT_D
304@@ -113,10 +113,10 @@
305 conf_file = "examples/tests/mirrorboot.yaml"
306 # initialize secondary disk
307 extra_disks = ['4G']
308- disk_to_check = {'main_disk': 1,
309- 'main_disk': 2,
310- 'second_disk': 1,
311- 'md0': 0}
312+ disk_to_check = [('main_disk', 1),
313+ ('main_disk', 2),
314+ ('second_disk', 1),
315+ ('md0', 0)]
316
317
318 class VividTestMirrorboot(relbase.vivid, TestMirrorbootAbs):
319@@ -132,11 +132,11 @@
320 conf_file = "examples/tests/raid5boot.yaml"
321 # initialize secondary disk
322 extra_disks = ['4G', '4G']
323- disk_to_check = {'main_disk': 1,
324- 'main_disk': 2,
325- 'second_disk': 1,
326- 'third_disk': 1,
327- 'md0': 0}
328+ disk_to_check = [('main_disk', 1),
329+ ('main_disk', 2),
330+ ('second_disk', 1),
331+ ('third_disk', 1),
332+ ('md0', 0)]
333
334
335 class VividTestRaid5boot(relbase.vivid, TestRaid5bootAbs):
336@@ -152,12 +152,12 @@
337 conf_file = "examples/tests/raid6boot.yaml"
338 # initialize secondary disk
339 extra_disks = ['4G', '4G', '4G']
340- disk_to_check = {'main_disk': 1,
341- 'main_disk': 2,
342- 'second_disk': 1,
343- 'third_disk': 1,
344- 'fourth_disk': 1,
345- 'md0': 0}
346+ disk_to_check = [('main_disk', 1),
347+ ('main_disk', 2),
348+ ('second_disk', 1),
349+ ('third_disk', 1),
350+ ('fourth_disk', 1),
351+ ('md0', 0)]
352 collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
353 cd OUTPUT_COLLECT_D
354 mdadm --detail --scan > mdadm_detail
355@@ -185,12 +185,12 @@
356 conf_file = "examples/tests/raid10boot.yaml"
357 # initialize secondary disk
358 extra_disks = ['4G', '4G', '4G']
359- disk_to_check = {'main_disk': 1,
360- 'main_disk': 2,
361- 'second_disk': 1,
362- 'third_disk': 1,
363- 'fourth_disk': 1,
364- 'md0': 0}
365+ disk_to_check = [('main_disk', 1),
366+ ('main_disk', 2),
367+ ('second_disk', 1),
368+ ('third_disk', 1),
369+ ('fourth_disk', 1),
370+ ('md0', 0)]
371
372
373 class VividTestRaid10boot(relbase.vivid, TestRaid10bootAbs):
374@@ -212,29 +212,30 @@
375 active_mdadm = "4"
376 # initialize secondary disk
377 extra_disks = ['5G', '5G', '5G']
378- disk_to_check = {'main_disk': 1,
379- 'main_disk': 2,
380- 'main_disk': 3,
381- 'main_disk': 4,
382- 'main_disk': 5,
383- 'second_disk': 1,
384- 'second_disk': 2,
385- 'second_disk': 3,
386- 'second_disk': 4,
387- 'third_disk': 1,
388- 'third_disk': 2,
389- 'third_disk': 3,
390- 'third_disk': 4,
391- 'fourth_disk': 1,
392- 'fourth_disk': 2,
393- 'fourth_disk': 3,
394- 'fourth_disk': 4,
395- 'md0': 0,
396- 'md1': 0,
397- 'md2': 0,
398- 'md3': 0,
399- 'vg1-lv1': 0,
400- 'vg1-lv2': 0}
401+ disk_to_check = [('main_disk', 1),
402+ ('main_disk', 2),
403+ ('main_disk', 3),
404+ ('main_disk', 4),
405+ ('main_disk', 5),
406+ ('second_disk', 1),
407+ ('second_disk', 2),
408+ ('second_disk', 3),
409+ ('second_disk', 4),
410+ ('third_disk', 1),
411+ ('third_disk', 2),
412+ ('third_disk', 3),
413+ ('third_disk', 4),
414+ ('fourth_disk', 1),
415+ ('fourth_disk', 2),
416+ ('fourth_disk', 3),
417+ ('fourth_disk', 4),
418+ ('md0', 0),
419+ ('md1', 0),
420+ ('md2', 0),
421+ ('md3', 0),
422+ ('vg1-lv1', 0),
423+ ('vg1-lv2', 0)]
424+
425 collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
426 cd OUTPUT_COLLECT_D
427 pvdisplay -C --separator = -o vg_name,pv_name --noheadings > pvs
428
429=== modified file 'tests/vmtests/test_raid5_bcache.py'
430--- tests/vmtests/test_raid5_bcache.py 2016-02-22 16:50:13 +0000
431+++ tests/vmtests/test_raid5_bcache.py 2016-02-22 23:00:54 +0000
432@@ -34,7 +34,7 @@
433
434 class TestMdadmBcacheAbs(TestMdadmAbs):
435 conf_file = "examples/tests/raid5bcache.yaml"
436- disk_to_check = {'md0': 0, 'sda': 2}
437+ disk_to_check = [('md0', 0), ('sda', 2)]
438
439 collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
440 cd OUTPUT_COLLECT_D
441@@ -78,7 +78,7 @@
442 # FIXME(LP: #1523037): dname does not work on trusty, so we cannot expect
443 # sda-part2 to exist in /dev/disk/by-dname as we can on other releases
444 # when dname works on trusty, then we need to re-enable by removing line.
445- disk_to_check = {'md0': 0}
446+ disk_to_check = [('md0', 0)]
447
448
449 class TrustyHWEUTestRaid5Bcache(relbase.trusty_hwe_u, TrustyTestRaid5Bcache):
450
451=== added file 'tests/vmtests/test_uefi_basic.py'
452--- tests/vmtests/test_uefi_basic.py 1970-01-01 00:00:00 +0000
453+++ tests/vmtests/test_uefi_basic.py 2016-02-22 23:00:54 +0000
454@@ -0,0 +1,83 @@
455+from . import (VMBaseClass)
456+
457+from .releases import base_vm_classes as relbase
458+
459+import os
460+import textwrap
461+
462+
463+class TestBasicAbs(VMBaseClass):
464+ interactive = False
465+ conf_file = "examples/tests/uefi_basic.yaml"
466+ install_timeout = 600
467+ boot_timeout = 120
468+ extra_disks = []
469+ uefi = True
470+ disk_to_check = [('main_disk', 1), ('main_disk', 2)]
471+ collect_scripts = [textwrap.dedent("""
472+ cd OUTPUT_COLLECT_D
473+ blkid -o export /dev/vda > blkid_output_vda
474+ blkid -o export /dev/vda1 > blkid_output_vda1
475+ blkid -o export /dev/vda2 > blkid_output_vda2
476+ cat /proc/partitions > proc_partitions
477+ ls -al /dev/disk/by-uuid/ > ls_uuid
478+ cat /etc/fstab > fstab
479+ mkdir -p /dev/disk/by-dname
480+ ls /dev/disk/by-dname/ > ls_dname
481+ ls /sys/firmware/efi/ > ls_sys_firmware_efi
482+ """)]
483+
484+ def test_output_files_exist(self):
485+ self.output_files_exist(
486+ ["blkid_output_vda", "blkid_output_vda1", "blkid_output_vda2",
487+ "fstab", "ls_dname", "ls_uuid", "ls_sys_firmware_efi",
488+ "proc_partitions"])
489+
490+ def test_sys_firmware_efi(self):
491+ sys_efi_expected = [
492+ 'config_table',
493+ 'efivars',
494+ 'fw_platform_size',
495+ 'fw_vendor',
496+ 'runtime',
497+ 'runtime-map',
498+ 'systab',
499+ 'vars',
500+ ]
501+ sys_efi = self.td.collect + "ls_sys_firmware_efi"
502+ if (os.path.exists(sys_efi)):
503+ with open(sys_efi) as fp:
504+ efi_lines = fp.read().strip().split('\n')
505+ self.assertEqual(sorted(sys_efi_expected),
506+ sorted(efi_lines))
507+
508+
509+class PreciseUefiTestBasic(relbase.precise, TestBasicAbs):
510+ __test__ = True
511+
512+ def test_ptable(self):
513+ print("test_ptable does not work for Precise")
514+
515+ def test_dname(self):
516+ print("test_dname does not work for Precise")
517+
518+
519+class TrustyUefiTestBasic(relbase.trusty, TestBasicAbs):
520+ __test__ = True
521+
522+ # FIXME(LP: #1523037): dname does not work on trusty, so we cannot expect
523+ # sda-part2 to exist in /dev/disk/by-dname as we can on other releases
524+ # when dname works on trusty, then we need to re-enable by removing line.
525+ def test_dname(self):
526+ print("test_dname does not work for Trusty")
527+
528+ def test_ptable(self):
529+ print("test_ptable does not work for Trusty")
530+
531+
532+class WilyUefiTestBasic(relbase.wily, TestBasicAbs):
533+ __test__ = True
534+
535+
536+class XenialUefiTestBasic(relbase.xenial, TestBasicAbs):
537+ __test__ = True
538
539=== modified file 'tools/launch'
540--- tools/launch 2015-12-18 20:10:04 +0000
541+++ tools/launch 2016-02-22 23:00:54 +0000
542@@ -23,7 +23,7 @@
543 --add F[:T] add file 'F' to the curtin archive at T
544 -a | --append append args to kernel cmdline (--kernel)
545 -d | --disk D add a disk 'D' format (path[:size])
546- --uefi enable uefi boot method
547+ --uefi N enable uefi boot method, store nvram at N
548 -h | --help show this message
549 -i | --initrd F use initramfs F
550 -k | --kernel F use kernel K
551@@ -236,7 +236,7 @@
552
553 main() {
554 local short_opts="a:d:h:i:k:n:p:v"
555- local long_opts="add:,append:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,silent,serial-log:,uefi,verbose,vnc:"
556+ local long_opts="add:,append:,bios:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,silent,serial-log:,uefi:,verbose,vnc:"
557 local getopt_out=""
558 getopt_out=$(getopt --name "${0##*/}" \
559 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
560@@ -249,7 +249,7 @@
561 local tmp="" top_d
562 local initrd="" kernel="" uappend="" iargs="" disk_args=""
563 local pubs="" disks="" pstate="null"
564- local uefi=0
565+ local uefi="" bios=""
566 local netdevs="" install_deps="--install-deps"
567 local video="-curses -vga std" serial_log="file:serial.log"
568 # dowait: run xkvm with a '&' and then 'wait' on the pid.
569@@ -290,7 +290,8 @@
570 shift;;
571 -n|--netdev) netdevs[${#netdevs[@]}]="$next"; shift;;
572 -p|--publish) pubs[${#pub[@]}]="$next"; shift;;
573- --uefi) uefi=1;;
574+ --uefi) uefi="$2"; shift;;
575+ --bios) bios="$2"; shift;;
576 --silent) video="-nographic";;
577 --vnc)
578 video="-vnc $next"
579@@ -325,17 +326,43 @@
580 local bios_opts=""
581
582 bios_opts=( )
583- if [ $uefi -eq 1 ]; then
584- local ovmf_bios="/usr/share/qemu/OVMF.fd"
585- [ -f "$ovmf_bios" ] || {
586+ if [ -n "$bios" ]; then
587+ bios_opts=( -drive "if=pflash,format=raw,file=$bios" )
588+ elif [ -n "$uefi" ]; then
589+ case `lsb_release -sc` in
590+ precise|trusty|vivid)
591+ # for non-split UEFI firmware, the code and
592+ # var space are in the same file. We must
593+ # make a copy so we can retain modifications.
594+ local ovmf_code="/usr/share/ovmf/OVMF.fd"
595+ local ovmf_var=$ovmf_code
596+ ;;
597+ *)
598+ # anything newer than vivid has split UEFI firmware
599+ local ovmf_code="/usr/share/OVMF/OVMF_CODE.fd"
600+ local ovmf_var="/usr/share/OVMF/OVMF_VARS.fd"
601+ ;;
602+ esac
603+ [ -f "$ovmf_code" ] || {
604 error "no --uefi requires ovmf bios: apt-get install ovmf"
605 return 1;
606 }
607- bios_opts=( -bios "$ovmf_bios" )
608- # this is here because in this bios, it goes into graphics mode
609- # rendering the display on curses mode useless. Would be nice
610- # if we could find a fix.
611- video=""
612+ # user specified where to write nvram data in --uefi param
613+ # pre-populate it with the OVMF_VARS.fd template
614+ local nvram=${uefi}
615+ cp -a "${ovmf_var}" "${nvram}" || {
616+ error "failed to create OVMF nvram file: '$nvram'"
617+ return 1;
618+ }
619+ # default to the rw copy of UEFI code
620+ local uefi_opts="-drive file=$nvram,if=pflash,format=raw"
621+ # if firmware is split, use readonly-code section
622+ if [ "$ovmf_code" != "$ovmf_var" ]; then
623+ # to ensure bootability, re-order firmware, code then variables
624+ uefi_opts="-drive file=$ovmf_code,if=pflash,format=raw,readonly $uefi_opts"
625+ fi
626+
627+ bios_opts=( $uefi_opts )
628 fi
629
630 if [ "${#disks[@]}" -eq 0 ]; then
631@@ -507,17 +534,20 @@
632 local netargs
633 netargs=( )
634 for dev in "${netdevs[@]}"; do
635- netargs=( "${netargs[@]}" "-n" "${dev}" )
636+ netargs=( "${netargs[@]}" "--netdev=${dev}" )
637 done
638
639 local cmd
640+ [ "${serial_log}" = "file:none" ] && serial_log=""
641+ [ "${serial_log}" = "file:stdio" ] && serial_log="stdio"
642 cmd=(
643- xkvm "${pt[@]}" "${netargs[@]}" --
644+ xkvm "${pt[@]}" "${netargs[@]}" --
645 "${bios_opts[@]}"
646 -m ${mem} ${serial_log:+-serial "${serial_log}"} ${video}
647- -drive "file=$bootimg,if=virtio,cache=unsafe"
648+ -drive "file=$bootimg,if=virtio,cache=unsafe,format=qcow2"
649+ "${disk_args[@]}"
650 "${seedargs[@]}"
651- "${disk_args[@]}" )
652+ )
653
654 debug 1 "running with dowait=$dowait: ${cmd[*]}"
655 local sstart=$SECONDS
656
657=== modified file 'tools/vmtest-system-setup'
658--- tools/vmtest-system-setup 2016-02-09 21:54:27 +0000
659+++ tools/vmtest-system-setup 2016-02-22 23:00:54 +0000
660@@ -16,6 +16,7 @@
661 python3-nose
662 python3-simplestreams
663 python3-yaml
664+ ovmf
665 simplestreams
666 $qemu
667 ubuntu-cloudimage-keyring

Subscribers

People subscribed via source and target branches