From 48235219f85976236a88e516a114616cb59239fa Mon Sep 17 00:00:00 2001 From: Zheng Xiang Date: Tue, 22 May 2018 22:34:56 +0800 Subject: [PATCH] aavmf: add aavmf and aavmf_vars_template paramters It is convenient for us to select the aavmf for different guests, such as 32-bit guest or 64-bit guest. Signed-off-by: Zheng Xiang --- virttest/qemu_devices/qcontainer.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/virttest/qemu_devices/qcontainer.py b/virttest/qemu_devices/qcontainer.py index cf799576e0..c149e5cee7 100644 --- a/virttest/qemu_devices/qcontainer.py +++ b/virttest/qemu_devices/qcontainer.py @@ -893,17 +893,22 @@ def get_aavmf_vars(params): devices = [] devices.append(qdevices.QStringDevice('machine', cmdline=cmd)) # EFI pflash - aavmf_code = ("-drive file=/usr/share/AAVMF/AAVMF_CODE.fd," - "if=pflash,format=raw,unit=0,readonly=on") + aavmf = params.get("aavmf") + if not aavmf: + aavmf = "/usr/share/AAVMF/AAVMF_CODE.fd" + aavmf_code = ("-drive file=%s,if=pflash,format=raw,unit=0,readonly=on" % aavmf) devices.append(qdevices.QStringDevice('AAVMF_CODE', cmdline=aavmf_code)) + aavmf_vars_template = params.get("aavmf_vars_template") + if not aavmf_vars_template: + aavmf_vars_template = "/usr/share/AAVMF/AAVMF_VARS.fd" 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!)", aavmf_vars) - shutil.copy2('/usr/share/AAVMF/AAVMF_VARS.fd', aavmf_vars) + shutil.copy2(aavmf_vars_template, aavmf_vars) aavmf_vars = ("-drive file=%s,if=pflash,format=raw,unit=1" % aavmf_vars) devices.append(qdevices.QStringDevice('AAVMF_VARS', @@ -943,17 +948,22 @@ def get_aavmf_vars(params): devices = [] devices.append(qdevices.QStringDevice('machine', cmdline=cmd)) # EFI pflash - aavmf_code = ("-drive file=/usr/share/AAVMF/AAVMF_CODE.fd," - "if=pflash,format=raw,unit=0,readonly=on") + aavmf = params.get("aavmf") + if not aavmf: + aavmf = "/usr/share/AAVMF/AAVMF_CODE.fd" + aavmf_code = ("-drive file=%s,if=pflash,format=raw,unit=0,readonly=on" % aavmf) devices.append(qdevices.QStringDevice('AAVMF_CODE', cmdline=aavmf_code)) + aavmf_vars_template = params.get("aavmf_vars_template") + if not aavmf_vars_template: + aavmf_vars_template = "/usr/share/AAVMF/AAVMF_VARS.fd" 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!)", aavmf_vars) - shutil.copy2('/usr/share/AAVMF/AAVMF_VARS.fd', aavmf_vars) + shutil.copy2(aavmf_vars_template, aavmf_vars) aavmf_vars = ("-drive file=%s,if=pflash,format=raw,unit=1" % aavmf_vars) devices.append(qdevices.QStringDevice('AAVMF_VARS',