From aa1b19c3c0a1d71f5dc4212d2fece3a41e3c2714 Mon Sep 17 00:00:00 2001
From: Michal Nasiadka <mnasiadka@gmail.com>
Date: Fri, 14 Oct 2022 12:22:22 +0200
Subject: [PATCH] CI: set cpu_model to Nehalem for kvm jobs

RHEL 9 are being compiled for the x86_64-v2 architecture which is
newer than the qemu default of qemu64. Nehalem is apparently the
oldest model that works for x86_64-v2 and is expected to work on
Intel and AMD cpus with kvm or qemu.

See devstack change [0].

[0]: Ibd6e11b59f3c8655bc60ace7383a08458b2177f2

Change-Id: Ia0a3620bae21984933756331bb5937ce681d3237
---
 tests/templates/nova-compute-overrides.j2 | 9 +++++++++
 zuul.d/base.yaml                          | 1 +
 2 files changed, 10 insertions(+)

diff --git a/tests/templates/nova-compute-overrides.j2 b/tests/templates/nova-compute-overrides.j2
index 209c050ac7..6d52544622 100644
--- a/tests/templates/nova-compute-overrides.j2
+++ b/tests/templates/nova-compute-overrides.j2
@@ -3,4 +3,13 @@
 cpu_mode=custom
 # cpu_model=max fails to boot multiple images with QEMU 7.0 and -M virt (works with "-M virt-6.2")
 cpu_model=cortex-a72
+{% elif ansible_architecture == 'x86_64' %}
+# RHEL 9 are being compiled for the x86_64-v2 architecture which is
+# newer than the qemu default of qemu64. Nehalem is apparently the
+# oldest model that works for x86_64-v2 and is expected to work on
+# Intel and AMD cpus with kvm or qemu.
+{% if virt_type == 'kvm' %}
+cpu_mode=custom
+cpu_model=Nehalem
+{% endif %}
 {% endif %}
diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml
index d0517b8adc..ba006f8f6d 100644
--- a/zuul.d/base.yaml
+++ b/zuul.d/base.yaml
@@ -52,6 +52,7 @@
     voting: false
     files:
       - ^ansible/roles/(nova-cell)/
+      - ^tests/templates/nova-compute-overrides.j2
     vars:
       virt_type: kvm