From 65fa7bba1a7b57e727bee51525d309c9afbc786b Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 12 Nov 2019 15:26:23 +0100 Subject: [PATCH] cpu_conf: Fix default value for CPU match attribute MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit v0.8.4-66-g95ff6b18ec (9 years ago) changed the default value for the cpu/@match attribute to 'exact' in a rather complicated way. It did so only if subelement was present and set -1 otherwise (which is not expected to ever happen). Thus the following two equivalent XML elements: and would be parsed differently. The former would end up with match == -1 while the latter would have match == 1 ('exact'). This is not a big deal since the match attribute is ignored for host-model CPUs, but we can simplify the code and make it a little bit saner anyway. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- src/conf/cpu_conf.c | 9 ++------- src/conf/cpu_conf.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 2a1bd7c9b2..3641b5ef4c 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -46,8 +46,8 @@ VIR_ENUM_IMPL(virCPUMode, VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST, - "minimum", "exact", + "minimum", "strict", ); @@ -388,12 +388,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, char *match = virXMLPropString(ctxt->node, "match"); char *check; - if (!match) { - if (virXPathBoolean("boolean(./model)", ctxt)) - def->match = VIR_CPU_MATCH_EXACT; - else - def->match = -1; - } else { + if (match) { def->match = virCPUMatchTypeFromString(match); VIR_FREE(match); diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index e41d47d1ae..96fda3e6b3 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -52,8 +52,8 @@ typedef enum { VIR_ENUM_DECL(virCPUMode); typedef enum { - VIR_CPU_MATCH_MINIMUM, VIR_CPU_MATCH_EXACT, + VIR_CPU_MATCH_MINIMUM, VIR_CPU_MATCH_STRICT, VIR_CPU_MATCH_LAST -- 2.39.5