Skip to content

Commit

Permalink
virttest.qemu_devices: Use per-image based AAVMF vars on ARM
Browse files Browse the repository at this point in the history
The UEFI storage (AAVMF variables files) is bound to base image to be
able to boot the image it needs to be configured properly. This is a
very simple implementation which bounds the AAVMF file to the first
image of the VM. The same VMs would share the single AAVMF file. This
should work fine as they are only modified during installation.

The result of this patch is that when you use multiple VMs of the same
base_image, they'll start properly. In case the file is missing, it's
created and WARNING message is printed into the log file informing about
the consequences.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
  • Loading branch information
ldoktor committed Mar 4, 2015
1 parent 65ca64c commit eeb6838
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,18 @@ def machine_aarch64(cmd=False):
:param cmd: If set uses "-M $cmd" to force this machine type
:return: List of added devices (including default buses)
"""
def get_aavmf_vars(params):
"""
Naive implementation of obtaining the main (first) image name
"""
try:
first_image = params.objects('images')[0]
name = params.object_params(first_image).get('image_name')
return os.path.join(data_dir.DATA_DIR,
name + "_AAVMF_VARS.fd")
except IndexError:
raise DeviceError("Unable to map main image name to "
"AAVMF variables file.")
logging.warn('Support for aarch64 is highly experimental!')
devices = []
devices.append(qdevices.QStringDevice('machine', cmdline=cmd))
Expand All @@ -833,9 +845,12 @@ def machine_aarch64(cmd=False):
"if=pflash,format=raw,unit=0,readonly=on")
devices.append(qdevices.QStringDevice('AAVMF_CODE',
cmdline=aavmf_code))
aavmf_vars = os.path.join(data_dir.DATA_DIR, 'images',
'%s_AAVMF_VARS.fd' % self.vmname)
aavmf_vars = get_aavmf_vars(params)
if not os.path.exists(aavmf_vars):
logging.warn("AAVMF variables file '%s' doesn't exist, "
"recreating it from the template (this should "
"only happen when you install the machine as "
"there is no default boot in EFI!)")
shutil.copy2('/usr/share/AAVMF/AAVMF_VARS.fd', aavmf_vars)
aavmf_vars = ("-drive file=%s,if=pflash,format=raw,unit=1"
% aavmf_vars)
Expand Down

0 comments on commit eeb6838

Please sign in to comment.