[PATCH 2/6] cpu_conf: Drop updateCPU from virCPUDefFormat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/bhyve/bhyve_driver.c                             |  2 +-
 src/conf/capabilities.c                              |  2 +-
 src/conf/cpu_conf.c                                  | 20 +++++++-------------
 src/conf/cpu_conf.h                                  |  9 +++------
 src/conf/domain_capabilities.c                       |  2 +-
 src/conf/domain_conf.c                               |  3 +--
 src/libxl/libxl_driver.c                             |  2 +-
 src/qemu/qemu_domain.c                               |  4 ++--
 src/qemu/qemu_driver.c                               |  2 +-
 src/qemu/qemu_migration_cookie.c                     |  2 +-
 src/test/test_driver.c                               |  2 +-
 src/vz/vz_driver.c                                   |  2 +-
 tests/cputest.c                                      | 15 +++++++--------
 .../ppc64-host+guest-compat-incompatible.xml         |  2 +-
 .../cputestdata/ppc64-host+guest-compat-invalid.xml  |  2 +-
 tests/cputestdata/ppc64-host+guest-compat-valid.xml  |  2 +-
 16 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index e8241f39ff..c096b5562f 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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);
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index ba554535ae..9920a675ac 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -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",
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 0bd56c9d28..6058d26fa5 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -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)));
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index d3e2c84102..b1a512b19a 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -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,
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 35f8128e70..f62038b96c 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -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");
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cc5e79b70b..35adce95b5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25720,8 +25720,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'",
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 4861e5db21..bf3625e34a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -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);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 50b536eec7..aba4111ba2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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");
@@ -9803,7 +9803,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;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e1a0dd553e..77308d547e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13019,7 +13019,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);
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 4914c77ef0..eef40a6cd0 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -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");
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6e8a4b5782..599c5ed545 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1551,7 +1551,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);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index daeed5f114..9ebb51d60a 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -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);
diff --git a/tests/cputest.c b/tests/cputest.c
index d325b5315c..913ca77231 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -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);
diff --git a/tests/cputestdata/ppc64-host+guest-compat-incompatible.xml b/tests/cputestdata/ppc64-host+guest-compat-incompatible.xml
index 1fab751ada..0595ba0efd 100644
--- a/tests/cputestdata/ppc64-host+guest-compat-incompatible.xml
+++ b/tests/cputestdata/ppc64-host+guest-compat-incompatible.xml
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power8</model>
 </cpu>
diff --git a/tests/cputestdata/ppc64-host+guest-compat-invalid.xml b/tests/cputestdata/ppc64-host+guest-compat-invalid.xml
index bc0d829673..edf874f4f4 100644
--- a/tests/cputestdata/ppc64-host+guest-compat-invalid.xml
+++ b/tests/cputestdata/ppc64-host+guest-compat-invalid.xml
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power7+</model>
 </cpu>
diff --git a/tests/cputestdata/ppc64-host+guest-compat-valid.xml b/tests/cputestdata/ppc64-host+guest-compat-valid.xml
index da9cc91885..f32cd93093 100644
--- a/tests/cputestdata/ppc64-host+guest-compat-valid.xml
+++ b/tests/cputestdata/ppc64-host+guest-compat-valid.xml
@@ -1,3 +1,3 @@
-<cpu mode='host-model' match='exact'>
+<cpu mode='host-model'>
   <model fallback='allow'>power6</model>
 </cpu>
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux