From: Daniel P. Berrange Date: Wed, 22 Sep 2010 11:47:48 +0000 (+0100) Subject: Set sensible defaults for cpu match and feature policy X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=v0.8.4-66-g95ff6b18ec;p=libvirt.git Set sensible defaults for cpu match and feature policy To enable the CPU XML from the capabilities to be pasted directly into the guest XML with no editing, pick a sensible default for match and feature policy. The CPU match will be exact and the feature policy will be require. This should ensure safety for migration and give DWIM semantics for users * src/conf/cpu_conf.c: Default to exact match and require policy * docs/formatdomain.html.in: Document new defaults --- diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 7baa62b6d0..8ec744623f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -276,6 +276,9 @@
The guest will not be created unless the host CPU does exactly match the specification.
+ + Since 0.8.5 the match + attribute can be omitted and will default to exact.
model
@@ -322,6 +325,9 @@
Guest creation will fail if the feature is supported by host CPU.
+ + Since 0.8.5 the policy + attribute can be omitted and will default to require. diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 3274659954..68d3daf772 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -147,12 +147,10 @@ virCPUDefParseXML(const xmlNodePtr node, char *match = virXMLPropString(node, "match"); if (!match) { - if (virXPathBoolean("boolean(./model)", ctxt)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing match attribute for CPU specification")); - goto error; - } - def->match = -1; + if (virXPathBoolean("boolean(./model)", ctxt)) + def->match = VIR_CPU_MATCH_EXACT; + else + def->match = -1; } else { def->match = virCPUMatchTypeFromString(match); VIR_FREE(match); @@ -251,7 +249,10 @@ virCPUDefParseXML(const xmlNodePtr node, char *strpolicy; strpolicy = virXMLPropString(nodes[i], "policy"); - policy = virCPUFeaturePolicyTypeFromString(strpolicy); + if (strpolicy == NULL) + policy = VIR_CPU_FEATURE_REQUIRE; + else + policy = virCPUFeaturePolicyTypeFromString(strpolicy); VIR_FREE(strpolicy); if (policy < 0) {