[libvirt] [PATCH] 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 --- docs/formatdomain.html.in | 6 ++++++ src/conf/cpu_conf.c | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5e56dae..45709e4 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -268,6 +268,9 @@ <dd>The guest will not be created unless the host CPU does exactly match the specification.</dd> </dl> + + <span class="since">Since 0.8.5</span> the <code>match</code> + attribute can be omitted and will default to <code>exact</code>. </dd> <dt><code>model</code></dt> @@ -314,6 +317,9 @@ <dd>Guest creation will fail if the feature is supported by host CPU.</dd> </dl> + + <span class="since">Since 0.8.5</span> the <code>policy</code> + attribute can be omitted and will default to <code>require</code>. </dd> </dl> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 3274659..68d3daf 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) { -- 1.7.2.3

On 09/22/2010 10:50 AM, Daniel P. Berrange wrote:
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
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Wed, Sep 22, 2010 at 05:50:10PM +0100, Daniel P. Berrange wrote:
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
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Eric Blake