]>
git.proxmox.com Git - mirror_qemu.git/blob - tests/acceptance/x86_cpu_model_versions.py
3 # Basic validation of x86 versioned CPU models and CPU model aliases
5 # Copyright (c) 2019 Red Hat Inc
8 # Eduardo Habkost <ehabkost@redhat.com>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2 of the License, or (at your option) any later version.
15 # This library is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 class X86CPUModelAliases(avocado_qemu
.Test
):
30 Validation of PC CPU model versions and CPU model aliases
32 :avocado: tags=arch:x86_64
34 def validate_aliases(self
, cpus
):
35 for c
in cpus
.values():
37 # all aliases must point to a valid CPU model name:
38 self
.assertIn(c
['alias-of'], cpus
,
39 '%s.alias-of (%s) is not a valid CPU model name' % (c
['name'], c
['alias-of']))
40 # aliases must not point to aliases
41 self
.assertNotIn('alias-of', cpus
[c
['alias-of']],
42 '%s.alias-of (%s) points to another alias' % (c
['name'], c
['alias-of']))
44 # aliases must not be static
45 self
.assertFalse(c
['static'])
47 def validate_variant_aliases(self
, cpus
):
48 # -noTSX, -IBRS and -IBPB variants of CPU models are special:
49 # they shouldn't have their own versions:
50 self
.assertNotIn("Haswell-noTSX-v1", cpus
,
51 "Haswell-noTSX shouldn't be versioned")
52 self
.assertNotIn("Broadwell-noTSX-v1", cpus
,
53 "Broadwell-noTSX shouldn't be versioned")
54 self
.assertNotIn("Nehalem-IBRS-v1", cpus
,
55 "Nehalem-IBRS shouldn't be versioned")
56 self
.assertNotIn("Westmere-IBRS-v1", cpus
,
57 "Westmere-IBRS shouldn't be versioned")
58 self
.assertNotIn("SandyBridge-IBRS-v1", cpus
,
59 "SandyBridge-IBRS shouldn't be versioned")
60 self
.assertNotIn("IvyBridge-IBRS-v1", cpus
,
61 "IvyBridge-IBRS shouldn't be versioned")
62 self
.assertNotIn("Haswell-noTSX-IBRS-v1", cpus
,
63 "Haswell-noTSX-IBRS shouldn't be versioned")
64 self
.assertNotIn("Haswell-IBRS-v1", cpus
,
65 "Haswell-IBRS shouldn't be versioned")
66 self
.assertNotIn("Broadwell-noTSX-IBRS-v1", cpus
,
67 "Broadwell-noTSX-IBRS shouldn't be versioned")
68 self
.assertNotIn("Broadwell-IBRS-v1", cpus
,
69 "Broadwell-IBRS shouldn't be versioned")
70 self
.assertNotIn("Skylake-Client-IBRS-v1", cpus
,
71 "Skylake-Client-IBRS shouldn't be versioned")
72 self
.assertNotIn("Skylake-Server-IBRS-v1", cpus
,
73 "Skylake-Server-IBRS shouldn't be versioned")
74 self
.assertNotIn("EPYC-IBPB-v1", cpus
,
75 "EPYC-IBPB shouldn't be versioned")
77 def test_4_0_alias_compatibility(self
):
78 """Check if pc-*-4.0 unversioned CPU model won't be reported as aliases"""
79 # pc-*-4.0 won't expose non-versioned CPU models as aliases
80 # We do this to help management software to keep compatibility
81 # with older QEMU versions that didn't have the versioned CPU model
82 self
.vm
.add_args('-S')
83 self
.vm
.set_machine('pc-i440fx-4.0')
85 cpus
= dict((m
['name'], m
) for m
in self
.vm
.command('query-cpu-definitions'))
87 self
.assertFalse(cpus
['Cascadelake-Server']['static'],
88 'unversioned Cascadelake-Server CPU model must not be static')
89 self
.assertNotIn('alias-of', cpus
['Cascadelake-Server'],
90 'Cascadelake-Server must not be an alias')
91 self
.assertNotIn('alias-of', cpus
['Cascadelake-Server-v1'],
92 'Cascadelake-Server-v1 must not be an alias')
94 self
.assertFalse(cpus
['qemu64']['static'],
95 'unversioned qemu64 CPU model must not be static')
96 self
.assertNotIn('alias-of', cpus
['qemu64'],
97 'qemu64 must not be an alias')
98 self
.assertNotIn('alias-of', cpus
['qemu64-v1'],
99 'qemu64-v1 must not be an alias')
101 self
.validate_variant_aliases(cpus
)
103 # On pc-*-4.0, no CPU model should be reported as an alias:
104 for name
,c
in cpus
.items():
105 self
.assertNotIn('alias-of', c
, "%s shouldn't be an alias" % (name
))
107 def test_4_1_alias(self
):
108 """Check if unversioned CPU model is an alias pointing to right version"""
109 self
.vm
.add_args('-S')
110 self
.vm
.set_machine('pc-i440fx-4.1')
113 cpus
= dict((m
['name'], m
) for m
in self
.vm
.command('query-cpu-definitions'))
115 self
.assertFalse(cpus
['Cascadelake-Server']['static'],
116 'unversioned Cascadelake-Server CPU model must not be static')
117 self
.assertEquals(cpus
['Cascadelake-Server'].get('alias-of'), 'Cascadelake-Server-v1',
118 'Cascadelake-Server must be an alias of Cascadelake-Server-v1')
119 self
.assertNotIn('alias-of', cpus
['Cascadelake-Server-v1'],
120 'Cascadelake-Server-v1 must not be an alias')
122 self
.assertFalse(cpus
['qemu64']['static'],
123 'unversioned qemu64 CPU model must not be static')
124 self
.assertEquals(cpus
['qemu64'].get('alias-of'), 'qemu64-v1',
125 'qemu64 must be an alias of qemu64-v1')
126 self
.assertNotIn('alias-of', cpus
['qemu64-v1'],
127 'qemu64-v1 must not be an alias')
129 self
.validate_variant_aliases(cpus
)
131 # On pc-*-4.1, -noTSX and -IBRS models should be aliases:
132 self
.assertEquals(cpus
["Haswell"].get('alias-of'),
134 "Haswell must be an alias")
135 self
.assertEquals(cpus
["Haswell-noTSX"].get('alias-of'),
137 "Haswell-noTSX must be an alias")
138 self
.assertEquals(cpus
["Haswell-IBRS"].get('alias-of'),
140 "Haswell-IBRS must be an alias")
141 self
.assertEquals(cpus
["Haswell-noTSX-IBRS"].get('alias-of'),
143 "Haswell-noTSX-IBRS must be an alias")
145 self
.assertEquals(cpus
["Broadwell"].get('alias-of'),
147 "Broadwell must be an alias")
148 self
.assertEquals(cpus
["Broadwell-noTSX"].get('alias-of'),
150 "Broadwell-noTSX must be an alias")
151 self
.assertEquals(cpus
["Broadwell-IBRS"].get('alias-of'),
153 "Broadwell-IBRS must be an alias")
154 self
.assertEquals(cpus
["Broadwell-noTSX-IBRS"].get('alias-of'),
156 "Broadwell-noTSX-IBRS must be an alias")
158 self
.assertEquals(cpus
["Nehalem"].get('alias-of'),
160 "Nehalem must be an alias")
161 self
.assertEquals(cpus
["Nehalem-IBRS"].get('alias-of'),
163 "Nehalem-IBRS must be an alias")
165 self
.assertEquals(cpus
["Westmere"].get('alias-of'),
167 "Westmere must be an alias")
168 self
.assertEquals(cpus
["Westmere-IBRS"].get('alias-of'),
170 "Westmere-IBRS must be an alias")
172 self
.assertEquals(cpus
["SandyBridge"].get('alias-of'),
174 "SandyBridge must be an alias")
175 self
.assertEquals(cpus
["SandyBridge-IBRS"].get('alias-of'),
177 "SandyBridge-IBRS must be an alias")
179 self
.assertEquals(cpus
["IvyBridge"].get('alias-of'),
181 "IvyBridge must be an alias")
182 self
.assertEquals(cpus
["IvyBridge-IBRS"].get('alias-of'),
184 "IvyBridge-IBRS must be an alias")
186 self
.assertEquals(cpus
["Skylake-Client"].get('alias-of'),
188 "Skylake-Client must be an alias")
189 self
.assertEquals(cpus
["Skylake-Client-IBRS"].get('alias-of'),
191 "Skylake-Client-IBRS must be an alias")
193 self
.assertEquals(cpus
["Skylake-Server"].get('alias-of'),
195 "Skylake-Server must be an alias")
196 self
.assertEquals(cpus
["Skylake-Server-IBRS"].get('alias-of'),
198 "Skylake-Server-IBRS must be an alias")
200 self
.assertEquals(cpus
["EPYC"].get('alias-of'),
202 "EPYC must be an alias")
203 self
.assertEquals(cpus
["EPYC-IBPB"].get('alias-of'),
205 "EPYC-IBPB must be an alias")
207 self
.validate_aliases(cpus
)
209 def test_none_alias(self
):
210 """Check if unversioned CPU model is an alias pointing to some version"""
211 self
.vm
.add_args('-S')
212 self
.vm
.set_machine('none')
215 cpus
= dict((m
['name'], m
) for m
in self
.vm
.command('query-cpu-definitions'))
217 self
.assertFalse(cpus
['Cascadelake-Server']['static'],
218 'unversioned Cascadelake-Server CPU model must not be static')
219 self
.assertTrue(re
.match('Cascadelake-Server-v[0-9]+', cpus
['Cascadelake-Server']['alias-of']),
220 'Cascadelake-Server must be an alias of versioned CPU model')
221 self
.assertNotIn('alias-of', cpus
['Cascadelake-Server-v1'],
222 'Cascadelake-Server-v1 must not be an alias')
224 self
.assertFalse(cpus
['qemu64']['static'],
225 'unversioned qemu64 CPU model must not be static')
226 self
.assertTrue(re
.match('qemu64-v[0-9]+', cpus
['qemu64']['alias-of']),
227 'qemu64 must be an alias of versioned CPU model')
228 self
.assertNotIn('alias-of', cpus
['qemu64-v1'],
229 'qemu64-v1 must not be an alias')
231 self
.validate_aliases(cpus
)