diff mbox series

[RFC,v4,11/15] tests/qemu-iotests: Allow passing a -cpu option in the QEMU cmdline

Message ID 20230119135424.5417-12-farosas@suse.de (mailing list archive)
State New, archived
Headers show
Series target/arm: Allow CONFIG_TCG=n builds | expand

Commit Message

Fabiano Rosas Jan. 19, 2023, 1:54 p.m. UTC
We're removing the default CPU from aarch64. Every QEMU invocation is
expected to have an explicit -cpu value.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qemu-iotests/testenv.py | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Richard Henderson Jan. 19, 2023, 7:09 p.m. UTC | #1
On 1/19/23 03:54, Fabiano Rosas wrote:
> +        cpu_map = (
> +            ('aarch64', 'cortex-a57'),
> +        )

This isn't a map...

> +        for suffix, cpu in cpu_map:
> +            if self.qemu_prog.endswith(f'qemu-system-{suffix}'):
> +                self.qemu_options += f' -cpu {cpu}'

... which causes you to use a loop here, instead of a map lookup.

Also, not keen on cortex-a57 vs max, again.

You want something like

     cpu_map = {
         'aarch64': 'max'
     }

     m = re.match('qemu-system-(.*)', self.qemu_prog)
     if m and m.group(1) in cpu_map:
         self.qemu_options += ' -cpu ' + cpu_map[m.group(1)]


My python is rough, so take that with a lot of testing...


r~
Fabiano Rosas Jan. 19, 2023, 7:21 p.m. UTC | #2
Richard Henderson <richard.henderson@linaro.org> writes:

> On 1/19/23 03:54, Fabiano Rosas wrote:
>> +        cpu_map = (
>> +            ('aarch64', 'cortex-a57'),
>> +        )
>
> This isn't a map...

Right, a dict would be more suitable here. I had just copied the code
from machine_map a few lines above.
diff mbox series

Patch

diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index a864c74b12..4bb80ea656 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -244,6 +244,13 @@  def __init__(self, imgfmt: str, imgproto: str, aiomode: str,
             if self.qemu_prog.endswith(f'qemu-system-{suffix}'):
                 self.qemu_options += f' -machine {machine}'
 
+        cpu_map = (
+            ('aarch64', 'cortex-a57'),
+        )
+        for suffix, cpu in cpu_map:
+            if self.qemu_prog.endswith(f'qemu-system-{suffix}'):
+                self.qemu_options += f' -cpu {cpu}'
+
         # QEMU_DEFAULT_MACHINE
         self.qemu_default_machine = get_default_machine(self.qemu_prog)