]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_conf: Don't format empty model for host-model CPUs
authorJiri Denemark <jdenemar@redhat.com>
Tue, 12 Nov 2019 14:54:12 +0000 (15:54 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 25 Nov 2019 14:29:19 +0000 (15:29 +0100)
Most likely for historical reasons our CPU def formatting code is
happily adding useless <model fallback='allow'/> for host-model CPUs. We
can just drop it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/cpu_conf.c
tests/cputestdata/ppc64-host+guest-compat-none.xml
tests/qemuxml2xmloutdata/cpu-check-default-partial.xml
tests/qemuxml2xmloutdata/cpu-host-model-features.xml

index 3641b5ef4c7054ce3e53e4b7b3e97c4200870baf..4542bcb7bda1833b7b9794b0de6ff060f9babc54 100644 (file)
@@ -751,16 +751,12 @@ virCPUDefFormatBuf(virBufferPtr buf,
 {
     size_t i;
     bool formatModel;
-    bool formatFallback;
 
     if (!def)
         return 0;
 
     formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
                    def->mode == VIR_CPU_MODE_HOST_MODEL);
-    formatFallback = (def->type == VIR_CPU_TYPE_GUEST &&
-                      (def->mode == VIR_CPU_MODE_HOST_MODEL ||
-                       (def->mode == VIR_CPU_MODE_CUSTOM && def->model)));
 
     if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM && def->nfeatures) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -768,9 +764,10 @@ virCPUDefFormatBuf(virBufferPtr buf,
         return -1;
     }
 
-    if ((formatModel && def->model) || formatFallback) {
+    if (formatModel && def->model) {
         virBufferAddLit(buf, "<model");
-        if (formatFallback) {
+
+        if (def->type == VIR_CPU_TYPE_GUEST) {
             const char *fallback;
 
             fallback = virCPUFallbackTypeToString(def->fallback);
@@ -784,11 +781,8 @@ virCPUDefFormatBuf(virBufferPtr buf,
             if (def->vendor_id)
                 virBufferEscapeString(buf, " vendor_id='%s'", def->vendor_id);
         }
-        if (formatModel && def->model) {
-            virBufferEscapeString(buf, ">%s</model>\n", def->model);
-        } else {
-            virBufferAddLit(buf, "/>\n");
-        }
+
+        virBufferEscapeString(buf, ">%s</model>\n", def->model);
     }
 
     if (formatModel && def->vendor)
index 188ebebb7230828786e3f28f8f4a85ac8bee52a3..fd50c03a79e9dc56282cb2ccfe9287203eb6ed22 100644 (file)
@@ -1,3 +1 @@
-<cpu mode='host-model'>
-  <model fallback='allow'/>
-</cpu>
+<cpu mode='host-model'/>
index 4e5fa44832f75e86947d2fb20b572f482427b5cd..b64a1f0ef7032ab11b51ef7161fa57c6a3e21db2 100644 (file)
@@ -8,9 +8,7 @@
     <type arch='x86_64' machine='pc'>hvm</type>
     <boot dev='network'/>
   </os>
-  <cpu mode='host-model' check='partial'>
-    <model fallback='allow'/>
-  </cpu>
+  <cpu mode='host-model' check='partial'/>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
index a5de9ea38d3ed4846222075462334e8228e08c23..6480bd549409f59d35bb8b8e18f410e6f98dab1b 100644 (file)
@@ -14,7 +14,6 @@
     <boot dev='hd'/>
   </os>
   <cpu mode='host-model' check='partial'>
-    <model fallback='allow'/>
     <feature policy='require' name='abm'/>
     <feature policy='force' name='ds'/>
     <feature policy='disable' name='invtsc'/>