]> xenbits.xensource.com Git - libvirt.git/commitdiff
Set sensible defaults for cpu match and feature policy
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 22 Sep 2010 11:47:48 +0000 (12:47 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 12 Oct 2010 10:27:58 +0000 (11:27 +0100)
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
src/conf/cpu_conf.c

index 7baa62b6d03e6f7a8e5ee1f16c7b021f50da79be..8ec744623f10d491e03b4e7eb54ac9ec9891f74d 100644 (file)
           <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>
           <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>
 
index 32746599541aaf5e616e79d64a17226c7074f0a3..68d3daf772e78c680a5bd8e44dcc583db7d81f55 100644 (file)
@@ -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) {