mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
cpu_conf: Drop updateCPU from virCPUDefFormat
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>
This commit is contained in:
parent
c3d265424d
commit
4fd179f518
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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)));
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -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'",
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -1,3 +1,3 @@
|
||||
<cpu mode='host-model' match='exact'>
|
||||
<cpu mode='host-model'>
|
||||
<model fallback='allow'>power8</model>
|
||||
</cpu>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<cpu mode='host-model' match='exact'>
|
||||
<cpu mode='host-model'>
|
||||
<model fallback='allow'>power7+</model>
|
||||
</cpu>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<cpu mode='host-model' match='exact'>
|
||||
<cpu mode='host-model'>
|
||||
<model fallback='allow'>power6</model>
|
||||
</cpu>
|
||||
|
Loading…
Reference in New Issue
Block a user