[PATCH v2 10/36] cpu_map: Properly group models in index.xml

Jiri Denemark posted 36 patches 1 week, 4 days ago
[PATCH v2 10/36] cpu_map: Properly group models in index.xml
Posted by Jiri Denemark 1 week, 4 days ago
We already visually group the included models using comments. This patch
introduces a new <group name='...'> element for doing it properly in a
machine friendly way.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---

Notes:
    Best viewed with "git show -w".
    
    Version 2:
    - use <group name='...'> for all groups rather than a strange mix of
      <group name='...'> and <group vendor='...'>

 src/cpu/cpu_map.c     |   2 +-
 src/cpu_map/index.xml | 226 ++++++++++++++++++++++--------------------
 2 files changed, 121 insertions(+), 107 deletions(-)

diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 16795a9a0a..83ebee16a8 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -116,7 +116,7 @@ loadIncludes(xmlXPathContextPtr ctxt,
     int n;
     size_t i;
 
-    n = virXPathNodeSet("include", ctxt, &nodes);
+    n = virXPathNodeSet("include|group[@name]/include", ctxt, &nodes);
     if (n < 0)
         return -1;
 
diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index 15cb63afe5..65128be377 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -3,122 +3,136 @@
     <include filename='x86_vendors.xml'/>
     <include filename='x86_features.xml'/>
 
-    <!-- models -->
-    <include filename='x86_486.xml'/>
-
-    <!-- Intel-based QEMU generic CPU models -->
-    <include filename='x86_pentium.xml'/>
-    <include filename='x86_pentium2.xml'/>
-    <include filename='x86_pentium3.xml'/>
-    <include filename='x86_pentiumpro.xml'/>
-    <include filename='x86_coreduo.xml'/>
-    <include filename='x86_n270.xml'/>
-    <include filename='x86_core2duo.xml'/>
-
-    <!-- Generic QEMU CPU models -->
-    <include filename='x86_qemu32.xml'/>
-    <include filename='x86_kvm32.xml'/>
-    <include filename='x86_cpu64-rhel5.xml'/>
-    <include filename='x86_cpu64-rhel6.xml'/>
-    <include filename='x86_qemu64.xml'/>
-    <include filename='x86_kvm64.xml'/>
-
-    <!-- Intel CPU models -->
-    <include filename='x86_Conroe.xml'/>
-    <include filename='x86_Penryn.xml'/>
-    <include filename='x86_Nehalem.xml'/>
-    <include filename='x86_Nehalem-IBRS.xml'/>
-    <include filename='x86_Westmere.xml'/>
-    <include filename='x86_Westmere-IBRS.xml'/>
-    <include filename='x86_SandyBridge.xml'/>
-    <include filename='x86_SandyBridge-IBRS.xml'/>
-    <include filename='x86_IvyBridge.xml'/>
-    <include filename='x86_IvyBridge-IBRS.xml'/>
-    <include filename='x86_Haswell-noTSX.xml'/>
-    <include filename='x86_Haswell-noTSX-IBRS.xml'/>
-    <include filename='x86_Haswell.xml'/>
-    <include filename='x86_Haswell-IBRS.xml'/>
-    <include filename='x86_Broadwell-noTSX.xml'/>
-    <include filename='x86_Broadwell-noTSX-IBRS.xml'/>
-    <include filename='x86_Broadwell.xml'/>
-    <include filename='x86_Broadwell-IBRS.xml'/>
-    <include filename='x86_Skylake-Client.xml'/>
-    <include filename='x86_Skylake-Client-IBRS.xml'/>
-    <include filename='x86_Skylake-Client-noTSX-IBRS.xml'/>
-    <include filename='x86_Skylake-Server.xml'/>
-    <include filename='x86_Skylake-Server-IBRS.xml'/>
-    <include filename='x86_Skylake-Server-noTSX-IBRS.xml'/>
-    <include filename='x86_Cascadelake-Server.xml'/>
-    <include filename='x86_Cascadelake-Server-noTSX.xml'/>
-    <include filename='x86_Icelake-Client.xml'/>
-    <include filename='x86_Icelake-Client-noTSX.xml'/>
-    <include filename='x86_Icelake-Server.xml'/>
-    <include filename='x86_Icelake-Server-noTSX.xml'/>
-    <include filename='x86_Cooperlake.xml'/>
-    <include filename='x86_Snowridge.xml'/>
-    <include filename='x86_SapphireRapids.xml'/>
-    <include filename='x86_GraniteRapids.xml'/>
-    <include filename='x86_SierraForest.xml'/>
-
-    <!-- AMD CPUs -->
-    <include filename='x86_athlon.xml'/>
-    <include filename='x86_phenom.xml'/>
-    <include filename='x86_Opteron_G1.xml'/>
-    <include filename='x86_Opteron_G2.xml'/>
-    <include filename='x86_Opteron_G3.xml'/>
-    <include filename='x86_Opteron_G4.xml'/>
-    <include filename='x86_Opteron_G5.xml'/>
-    <include filename='x86_EPYC.xml'/>
-    <include filename='x86_EPYC-IBPB.xml'/>
-    <include filename='x86_EPYC-Rome.xml'/>
-    <include filename='x86_EPYC-Milan.xml'/>
-    <include filename='x86_EPYC-Genoa.xml'/>
-
-    <!-- Hygon CPU models -->
-    <include filename='x86_Dhyana.xml'/>
+    <group name='generic'>
+      <include filename='x86_486.xml'/>
+    </group>
+
+    <group name='Intel-based QEMU generic CPU models'>
+      <include filename='x86_pentium.xml'/>
+      <include filename='x86_pentium2.xml'/>
+      <include filename='x86_pentium3.xml'/>
+      <include filename='x86_pentiumpro.xml'/>
+      <include filename='x86_coreduo.xml'/>
+      <include filename='x86_n270.xml'/>
+      <include filename='x86_core2duo.xml'/>
+    </group>
+
+    <group name='Generic QEMU CPU models'>
+      <include filename='x86_qemu32.xml'/>
+      <include filename='x86_kvm32.xml'/>
+      <include filename='x86_cpu64-rhel5.xml'/>
+      <include filename='x86_cpu64-rhel6.xml'/>
+      <include filename='x86_qemu64.xml'/>
+      <include filename='x86_kvm64.xml'/>
+    </group>
+
+    <group name='Intel CPU models'>
+      <include filename='x86_Conroe.xml'/>
+      <include filename='x86_Penryn.xml'/>
+      <include filename='x86_Nehalem.xml'/>
+      <include filename='x86_Nehalem-IBRS.xml'/>
+      <include filename='x86_Westmere.xml'/>
+      <include filename='x86_Westmere-IBRS.xml'/>
+      <include filename='x86_SandyBridge.xml'/>
+      <include filename='x86_SandyBridge-IBRS.xml'/>
+      <include filename='x86_IvyBridge.xml'/>
+      <include filename='x86_IvyBridge-IBRS.xml'/>
+      <include filename='x86_Haswell-noTSX.xml'/>
+      <include filename='x86_Haswell-noTSX-IBRS.xml'/>
+      <include filename='x86_Haswell.xml'/>
+      <include filename='x86_Haswell-IBRS.xml'/>
+      <include filename='x86_Broadwell-noTSX.xml'/>
+      <include filename='x86_Broadwell-noTSX-IBRS.xml'/>
+      <include filename='x86_Broadwell.xml'/>
+      <include filename='x86_Broadwell-IBRS.xml'/>
+      <include filename='x86_Skylake-Client.xml'/>
+      <include filename='x86_Skylake-Client-IBRS.xml'/>
+      <include filename='x86_Skylake-Client-noTSX-IBRS.xml'/>
+      <include filename='x86_Skylake-Server.xml'/>
+      <include filename='x86_Skylake-Server-IBRS.xml'/>
+      <include filename='x86_Skylake-Server-noTSX-IBRS.xml'/>
+      <include filename='x86_Cascadelake-Server.xml'/>
+      <include filename='x86_Cascadelake-Server-noTSX.xml'/>
+      <include filename='x86_Icelake-Client.xml'/>
+      <include filename='x86_Icelake-Client-noTSX.xml'/>
+      <include filename='x86_Icelake-Server.xml'/>
+      <include filename='x86_Icelake-Server-noTSX.xml'/>
+      <include filename='x86_Cooperlake.xml'/>
+      <include filename='x86_Snowridge.xml'/>
+      <include filename='x86_SapphireRapids.xml'/>
+      <include filename='x86_GraniteRapids.xml'/>
+      <include filename='x86_SierraForest.xml'/>
+    </group>
+
+    <group name='AMD CPU models'>
+      <include filename='x86_athlon.xml'/>
+      <include filename='x86_phenom.xml'/>
+      <include filename='x86_Opteron_G1.xml'/>
+      <include filename='x86_Opteron_G2.xml'/>
+      <include filename='x86_Opteron_G3.xml'/>
+      <include filename='x86_Opteron_G4.xml'/>
+      <include filename='x86_Opteron_G5.xml'/>
+      <include filename='x86_EPYC.xml'/>
+      <include filename='x86_EPYC-IBPB.xml'/>
+      <include filename='x86_EPYC-Rome.xml'/>
+      <include filename='x86_EPYC-Milan.xml'/>
+      <include filename='x86_EPYC-Genoa.xml'/>
+    </group>
+
+    <group name='Hygon CPU models'>
+      <include filename='x86_Dhyana.xml'/>
+    </group>
   </arch>
 
   <arch name='ppc64'>
     <include filename='ppc64_vendors.xml'/>
 
-    <!-- IBM-based CPU models -->
-    <include filename='ppc64_POWER6.xml'/>
-    <include filename='ppc64_POWER7.xml'/>
-    <include filename='ppc64_POWER8.xml'/>
-    <include filename='ppc64_POWER9.xml'/>
-    <include filename='ppc64_POWER10.xml'/>
-
-    <!-- Freescale-based CPU models -->
-    <include filename='ppc64_POWERPC_e5500.xml'/>
-    <include filename='ppc64_POWERPC_e6500.xml'/>
+    <group name='IBM-based CPU models'>
+      <include filename='ppc64_POWER6.xml'/>
+      <include filename='ppc64_POWER7.xml'/>
+      <include filename='ppc64_POWER8.xml'/>
+      <include filename='ppc64_POWER9.xml'/>
+      <include filename='ppc64_POWER10.xml'/>
+    </group>
+
+    <group name='Freescale-based CPU models'>
+      <include filename='ppc64_POWERPC_e5500.xml'/>
+      <include filename='ppc64_POWERPC_e6500.xml'/>
+    </group>
   </arch>
 
   <arch name='arm'>
     <include filename='arm_vendors.xml'/>
     <include filename='arm_features.xml'/>
 
-    <!-- ARM-based CPU models -->
-    <include filename='arm_cortex-a53.xml'/>
-    <include filename='arm_cortex-a57.xml'/>
-    <include filename='arm_cortex-a72.xml'/>
-    <include filename='arm_Neoverse-N1.xml'/>
-    <include filename='arm_Neoverse-N2.xml'/>
-    <include filename='arm_Neoverse-V1.xml'/>
-
-    <!-- Qualcomm-based CPU models -->
-    <include filename='arm_Falkor.xml'/>
-
-    <!-- Cavium-based CPU models -->
-    <include filename='arm_ThunderX299xx.xml'/>
-
-    <!-- Fujitsu-based CPU models -->
-    <include filename='arm_a64fx.xml'/>
-
-    <!-- Hisilicon-based CPU models -->
-    <include filename='arm_Kunpeng-920.xml'/>
-
-    <!-- Phytium-based CPU models -->
-    <include filename='arm_FT-2000plus.xml'/>
-    <include filename='arm_Tengyun-S2500.xml'/>
+    <group name='ARM-based CPU models'>
+      <include filename='arm_cortex-a53.xml'/>
+      <include filename='arm_cortex-a57.xml'/>
+      <include filename='arm_cortex-a72.xml'/>
+      <include filename='arm_Neoverse-N1.xml'/>
+      <include filename='arm_Neoverse-N2.xml'/>
+      <include filename='arm_Neoverse-V1.xml'/>
+    </group>
+
+    <group name='Qualcomm-based CPU models'>
+      <include filename='arm_Falkor.xml'/>
+    </group>
+
+    <group name='Cavium-based CPU models'>
+      <include filename='arm_ThunderX299xx.xml'/>
+    </group>
+
+    <group name='Fujitsu-based CPU models'>
+      <include filename='arm_a64fx.xml'/>
+    </group>
+
+    <group name='Hisilicon-based CPU models'>
+      <include filename='arm_Kunpeng-920.xml'/>
+    </group>
+
+    <group name='Phytium-based CPU models'>
+      <include filename='arm_FT-2000plus.xml'/>
+      <include filename='arm_Tengyun-S2500.xml'/>
+    </group>
   </arch>
 </cpus>
-- 
2.47.0
Re: [PATCH v2 10/36] cpu_map: Properly group models in index.xml
Posted by Daniel P. Berrangé 1 week, 1 day ago
On Fri, Nov 22, 2024 at 10:32:50PM +0100, Jiri Denemark wrote:
> We already visually group the included models using comments. This patch
> introduces a new <group name='...'> element for doing it properly in a
> machine friendly way.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|