]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_conf: Drop updateCPU from virCPUDefFormat
authorJiri Denemark <jdenemar@redhat.com>
Fri, 30 Jun 2017 13:47:23 +0000 (15:47 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 21 Sep 2017 13:23:39 +0000 (15:23 +0200)
In the past we updated host-model CPUs with host CPU data by adding a
model and features, but keeping the host-model mode. And since the CPU
model is not normally formatted for host-model CPU defs, we had to pass
the updateCPU flag to the formatting code to be able to properly output
updated host-model CPUs. Libvirt doesn't do this anymore, host-model
CPUs are turned into custom mode CPUs once updated with host CPU data
and thus there's no reason for keeping the hacks inside CPU XML
formatters.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
16 files changed:
src/bhyve/bhyve_driver.c
src/conf/capabilities.c
src/conf/cpu_conf.c
src/conf/cpu_conf.h
src/conf/domain_capabilities.c
src/conf/domain_conf.c
src/libxl/libxl_driver.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c
src/qemu/qemu_migration_cookie.c
src/test/test_driver.c
src/vz/vz_driver.c
tests/cputest.c
tests/cputestdata/ppc64-host+guest-compat-incompatible.xml
tests/cputestdata/ppc64-host+guest-compat-invalid.xml
tests/cputestdata/ppc64-host+guest-compat-valid.xml

index e8241f39ffcc89be5c06c0b41ad2ba4d5d19db43..c096b5562f7b3b46e21d688a106c3089c8630a5c 100644 (file)
@@ -1441,7 +1441,7 @@ bhyveConnectBaselineCPU(virConnectPtr conn,
         virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
         goto cleanup;
 
-    cpustr = virCPUDefFormat(cpu, NULL, false);
+    cpustr = virCPUDefFormat(cpu, NULL);
 
  cleanup:
     virCPUDefListFree(cpus);
index ba554535ae5dca746fa83802ffcbdfb6a5783723..9920a675aca335e0b0361e84b7384666ea909514 100644 (file)
@@ -984,7 +984,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
         virBufferAdjustIndent(&buf, -2);
         virBufferAddLit(&buf, "</features>\n");
     }
-    virCPUDefFormatBuf(&buf, caps->host.cpu, false);
+    virCPUDefFormatBuf(&buf, caps->host.cpu);
 
     for (i = 0; i < caps->host.nPagesSize; i++) {
         virBufferAsprintf(&buf, "<pages unit='KiB' size='%u'/>\n",
index 0bd56c9d28c92d52713ba2ba0066a40fdea47eca..6058d26fa50e2db482d4e202b2ba13d8a8c2470d 100644 (file)
@@ -574,12 +574,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
 
 char *
 virCPUDefFormat(virCPUDefPtr def,
-                virDomainNumaPtr numa,
-                bool updateCPU)
+                virDomainNumaPtr numa)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-    if (virCPUDefFormatBufFull(&buf, def, numa, updateCPU) < 0)
+    if (virCPUDefFormatBufFull(&buf, def, numa) < 0)
         goto cleanup;
 
     if (virBufferCheckError(&buf) < 0)
@@ -596,8 +595,7 @@ virCPUDefFormat(virCPUDefPtr def,
 int
 virCPUDefFormatBufFull(virBufferPtr buf,
                        virCPUDefPtr def,
-                       virDomainNumaPtr numa,
-                       bool updateCPU)
+                       virDomainNumaPtr numa)
 {
     int ret = -1;
     virBuffer attributeBuf = VIR_BUFFER_INITIALIZER;
@@ -619,9 +617,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
             virBufferAsprintf(&attributeBuf, " mode='%s'", tmp);
         }
 
-        if (def->model &&
-            (def->mode == VIR_CPU_MODE_CUSTOM ||
-             updateCPU)) {
+        if (def->model && def->mode == VIR_CPU_MODE_CUSTOM) {
             if (!(tmp = virCPUMatchTypeToString(def->match))) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Unexpected CPU match policy %d"),
@@ -642,7 +638,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
     if (def->type == VIR_CPU_TYPE_HOST && def->arch)
         virBufferAsprintf(&childrenBuf, "<arch>%s</arch>\n",
                           virArchToString(def->arch));
-    if (virCPUDefFormatBuf(&childrenBuf, def, updateCPU) < 0)
+    if (virCPUDefFormatBuf(&childrenBuf, def) < 0)
         goto cleanup;
 
     if (virDomainNumaDefCPUFormat(&childrenBuf, numa) < 0)
@@ -677,8 +673,7 @@ virCPUDefFormatBufFull(virBufferPtr buf,
 
 int
 virCPUDefFormatBuf(virBufferPtr buf,
-                   virCPUDefPtr def,
-                   bool updateCPU)
+                   virCPUDefPtr def)
 {
     size_t i;
     bool formatModel;
@@ -688,8 +683,7 @@ virCPUDefFormatBuf(virBufferPtr buf,
         return 0;
 
     formatModel = (def->mode == VIR_CPU_MODE_CUSTOM ||
-                   def->mode == VIR_CPU_MODE_HOST_MODEL ||
-                   updateCPU);
+                   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)));
index d3e2c8410230035d4fb50f1d99cfcf3a2a5c0fb8..b1a512b19a265982e9716bc4d6f71f50dffe7baf 100644 (file)
@@ -195,18 +195,15 @@ virCPUDefIsEqual(virCPUDefPtr src,
 
 char *
 virCPUDefFormat(virCPUDefPtr def,
-                virDomainNumaPtr numa,
-                bool updateCPU);
+                virDomainNumaPtr numa);
 
 int
 virCPUDefFormatBuf(virBufferPtr buf,
-                   virCPUDefPtr def,
-                   bool updateCPU);
+                   virCPUDefPtr def);
 int
 virCPUDefFormatBufFull(virBufferPtr buf,
                        virCPUDefPtr def,
-                       virDomainNumaPtr numa,
-                       bool updateCPU);
+                       virDomainNumaPtr numa);
 
 int
 virCPUDefAddFeature(virCPUDefPtr cpu,
index 35f8128e70dd0cbf47ea28ef726d018070bb0e81..f62038b96cde02ba4563f4921757518246cdf1d2 100644 (file)
@@ -413,7 +413,7 @@ virDomainCapsCPUFormat(virBufferPtr buf,
         virBufferAddLit(buf, "supported='yes'>\n");
         virBufferAdjustIndent(buf, 2);
 
-        virCPUDefFormatBuf(buf, cpu->hostModel, false);
+        virCPUDefFormatBuf(buf, cpu->hostModel);
 
         virBufferAdjustIndent(buf, -2);
         virBufferAddLit(buf, "</mode>\n");
index f3b4dd33daf408b92ef4945ca216c3f2ce3536e7..f4c2f26ff84ab29a1c71d8a94f3b3763bf130721 100644 (file)
@@ -25744,8 +25744,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         virBufferAddLit(buf, "</features>\n");
     }
 
-    if (virCPUDefFormatBufFull(buf, def->cpu, def->numa,
-                               !!(flags & VIR_DOMAIN_DEF_FORMAT_UPDATE_CPU)) < 0)
+    if (virCPUDefFormatBufFull(buf, def->cpu, def->numa) < 0)
         goto error;
 
     virBufferAsprintf(buf, "<clock offset='%s'",
index 4861e5db219f4621174304679c4385d3d0d67a9c..bf3625e34afff8d0d727467c8a93a0f215185cbc 100644 (file)
@@ -6471,7 +6471,7 @@ libxlConnectBaselineCPU(virConnectPtr conn,
         virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
         goto cleanup;
 
-    cpustr = virCPUDefFormat(cpu, NULL, false);
+    cpustr = virCPUDefFormat(cpu, NULL);
 
  cleanup:
     virCPUDefListFree(cpus);
index e09d848db69eca234c9a622e54524e154f0c0a7d..3111675a059e4e5c86f4f27943a9b8eeb3d04a51 100644 (file)
@@ -1945,7 +1945,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
     virBufferEscapeString(buf, "<channelTargetDir path='%s'/>\n",
                           priv->channelTargetDir);
 
-    virCPUDefFormatBufFull(buf, priv->origCPU, NULL, false);
+    virCPUDefFormatBufFull(buf, priv->origCPU, NULL);
 
     if (priv->chardevStdioLogd)
         virBufferAddLit(buf, "<chardevStdioLogd/>\n");
@@ -9811,7 +9811,7 @@ qemuDomainSaveCookieFormat(virBufferPtr buf,
     qemuDomainSaveCookiePtr cookie = (qemuDomainSaveCookiePtr) obj;
 
     if (cookie->cpu &&
-        virCPUDefFormatBufFull(buf, cookie->cpu, NULL, false) < 0)
+        virCPUDefFormatBufFull(buf, cookie->cpu, NULL) < 0)
         return -1;
 
     return 0;
index 9a219959ba7b8f2aec133e44f2ad767216b4dbb7..da98770dc11123bd62cd360ff348a2d02d50e056 100644 (file)
@@ -13031,7 +13031,7 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
         virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
         goto cleanup;
 
-    cpustr = virCPUDefFormat(cpu, NULL, false);
+    cpustr = virCPUDefFormat(cpu, NULL);
 
  cleanup:
     virCPUDefListFree(cpus);
index 4914c77ef0cea4970fafd72c92cb1c1ed0449d2f..eef40a6cd055b263b559c0364ee984ae36675362 100644 (file)
@@ -771,7 +771,7 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
         qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo);
 
     if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu)
-        virCPUDefFormatBufFull(buf, mig->cpu, NULL, false);
+        virCPUDefFormatBufFull(buf, mig->cpu, NULL);
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</qemu-migration>\n");
index 660626406e94c623e7e792380896acc9a5f723e3..9b434e9a04780476e2e190c1e2a72f754a5f1e7f 100644 (file)
@@ -1552,7 +1552,7 @@ testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
         virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
         goto cleanup;
 
-    cpustr = virCPUDefFormat(cpu, NULL, false);
+    cpustr = virCPUDefFormat(cpu, NULL);
 
  cleanup:
     virCPUDefListFree(cpus);
index daeed5f114f38ac3ffdcbd7b3c641cbf212ff715..9ebb51d60a00b2b8021106307447666e78be03c9 100644 (file)
@@ -964,7 +964,7 @@ vzConnectBaselineCPU(virConnectPtr conn,
         virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
         goto cleanup;
 
-    cpustr = virCPUDefFormat(cpu, NULL, false);
+    cpustr = virCPUDefFormat(cpu, NULL);
 
  cleanup:
     virCPUDefListFree(cpus);
index d325b5315cb4c497dbbc4de64bd9ce95542e407c..913ca77231b17d50770068cab882703148241a89 100644 (file)
@@ -150,8 +150,7 @@ cpuTestLoadMultiXML(virArch arch,
 static int
 cpuTestCompareXML(virArch arch,
                   virCPUDef *cpu,
-                  const char *name,
-                  bool updateCPU)
+                  const char *name)
 {
     char *xml = NULL;
     char *actual = NULL;
@@ -161,7 +160,7 @@ cpuTestCompareXML(virArch arch,
                     abs_srcdir, virArchToString(arch), name) < 0)
         goto cleanup;
 
-    if (!(actual = virCPUDefFormat(cpu, NULL, updateCPU)))
+    if (!(actual = virCPUDefFormat(cpu, NULL)))
         goto cleanup;
 
     if (virTestCompareToFile(actual, xml) < 0)
@@ -281,7 +280,7 @@ cpuTestGuestCPU(const void *arg)
     }
     result = virBufferContentAndReset(&buf);
 
-    if (cpuTestCompareXML(data->arch, cpu, result, false) < 0)
+    if (cpuTestCompareXML(data->arch, cpu, result) < 0)
         goto cleanup;
 
     ret = 0;
@@ -355,7 +354,7 @@ cpuTestBaseline(const void *arg)
     if (virAsprintf(&result, "%s-%s", data->name, suffix) < 0)
         goto cleanup;
 
-    if (cpuTestCompareXML(data->arch, baseline, result, false) < 0)
+    if (cpuTestCompareXML(data->arch, baseline, result) < 0)
         goto cleanup;
 
     for (i = 0; i < ncpus; i++) {
@@ -409,7 +408,7 @@ cpuTestUpdate(const void *arg)
     if (virAsprintf(&result, "%s+%s", data->host, data->name) < 0)
         goto cleanup;
 
-    ret = cpuTestCompareXML(data->arch, cpu, result, true);
+    ret = cpuTestCompareXML(data->arch, cpu, result);
 
  cleanup:
     virCPUDefFree(host);
@@ -501,7 +500,7 @@ cpuTestCPUID(bool guest, const void *arg)
                     guest ? "guest" : "host") < 0)
         goto cleanup;
 
-    ret = cpuTestCompareXML(data->arch, cpu, result, false);
+    ret = cpuTestCompareXML(data->arch, cpu, result);
 
  cleanup:
     VIR_FREE(hostFile);
@@ -716,7 +715,7 @@ cpuTestJSONCPUID(const void *arg)
     if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0)
         goto cleanup;
 
-    ret = cpuTestCompareXML(data->arch, cpu, result, false);
+    ret = cpuTestCompareXML(data->arch, cpu, result);
 
  cleanup:
     qemuMonitorCPUModelInfoFree(model);
index 1fab751ada17fbf4fd148a2dde4c9cf3fd57757c..0595ba0efddb74016cfcc0486c8b1be5af87731f 100644 (file)
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power8</model>
 </cpu>
index bc0d82967387ea8442f800240b6a789c587cdfe4..edf874f4f48b88b4f0604cb21e79bc36f200f6da 100644 (file)
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power7+</model>
 </cpu>
index da9cc91885ef01d1490b6e6b57a0608bdacf1a78..f32cd930936b76787866f36ff8f530038508605e 100644 (file)
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power6</model>
 </cpu>