From ab2dcdf9e8cfd0f884cd0ed62e6705aeaeb4dac7 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 17 Sep 2015 18:25:45 -0300 Subject: [PATCH] cpuid: Handle VMCreateError when CPU can't be run avocado-vt will throw VMCreateError if QEMU refuses to start, so handle both VMStartError and VMCreateError, to catch errors when a CPU model can't run. Signed-off-by: Eduardo Habkost --- qemu/tests/cpuid.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/qemu/tests/cpuid.py b/qemu/tests/cpuid.py index 7e0599fc..1d3ee28a 100644 --- a/qemu/tests/cpuid.py +++ b/qemu/tests/cpuid.py @@ -535,12 +535,13 @@ def run(test, params, env): out = get_guest_cpuid( self, cpu_model, cpu_model_flags + ',enforce', extra_params=dict(machine_type=machine_type, smp=1)) - except virt_vm.VMStartError, e: - if "host doesn't support requested feature:" in e.reason \ - or ("host cpuid" in e.reason and - ("lacks requested flag" in e.reason or - "flag restricted to guest" in e.reason)) \ - or ("Unable to find CPU definition:" in e.reason): + except (virt_vm.VMStartError, virt_vm.VMCreateError) as e: + output = getattr(e, 'reason', getattr(e, 'output', '')) + if "host doesn't support requested feature:" in output \ + or ("host cpuid" in output and + ("lacks requested flag" in output or + "flag restricted to guest" in output)) \ + or ("Unable to find CPU definition:" in output): raise error.TestNAError( "Can't run CPU model %s on this host" % (full_cpu_model_name)) else: -- GitLab