The virCPUDefFormat* methods were relying on the VIR_DOMAIN_XML_* flag definitions. It is not desirable for low level internal functions to be coupled to flags for the public API, since they may need to be called from several different contexts where the flags would not be appropriate. --- src/conf/capabilities.c | 2 +- src/conf/cpu_conf.c | 14 +++++++------- src/conf/cpu_conf.h | 6 +++--- src/conf/domain_conf.c | 3 ++- src/cpu/cpu.c | 2 +- tests/cputest.c | 11 +++++------ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 6c11a7f..b66c6dd 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -867,7 +867,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</features>\n"); } - virCPUDefFormatBuf(&buf, caps->host.cpu, 0); + virCPUDefFormatBuf(&buf, caps->host.cpu, false); 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 3af0f44..b4283b6 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -536,11 +536,11 @@ virCPUDefParseXML(xmlNodePtr node, char * virCPUDefFormat(virCPUDefPtr def, - unsigned int flags) + bool updateCPU) { virBuffer buf = VIR_BUFFER_INITIALIZER; - if (virCPUDefFormatBufFull(&buf, def, flags) < 0) + if (virCPUDefFormatBufFull(&buf, def, updateCPU) < 0) goto cleanup; if (virBufferCheckError(&buf) < 0) @@ -557,7 +557,7 @@ virCPUDefFormat(virCPUDefPtr def, int virCPUDefFormatBufFull(virBufferPtr buf, virCPUDefPtr def, - unsigned int flags) + bool updateCPU) { if (!def) return 0; @@ -577,7 +577,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (def->model && (def->mode == VIR_CPU_MODE_CUSTOM || - (flags & VIR_DOMAIN_XML_UPDATE_CPU))) { + updateCPU)) { if (!(tmp = virCPUMatchTypeToString(def->match))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected CPU match policy %d"), @@ -593,7 +593,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (def->arch) virBufferAsprintf(buf, "<arch>%s</arch>\n", virArchToString(def->arch)); - if (virCPUDefFormatBuf(buf, def, flags) < 0) + if (virCPUDefFormatBuf(buf, def, updateCPU) < 0) return -1; virBufferAdjustIndent(buf, -2); @@ -605,7 +605,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, int virCPUDefFormatBuf(virBufferPtr buf, virCPUDefPtr def, - unsigned int flags) + bool updateCPU) { size_t i; bool formatModel; @@ -616,7 +616,7 @@ virCPUDefFormatBuf(virBufferPtr buf, formatModel = (def->mode == VIR_CPU_MODE_CUSTOM || def->mode == VIR_CPU_MODE_HOST_MODEL || - (flags & VIR_DOMAIN_XML_UPDATE_CPU)); + updateCPU); 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 5bcf101..46fce25 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -158,16 +158,16 @@ virCPUDefIsEqual(virCPUDefPtr src, char * virCPUDefFormat(virCPUDefPtr def, - unsigned int flags); + bool updateCPU); int virCPUDefFormatBuf(virBufferPtr buf, virCPUDefPtr def, - unsigned int flags); + bool updateCPU); int virCPUDefFormatBufFull(virBufferPtr buf, virCPUDefPtr def, - unsigned int flags); + bool updateCPU); int virCPUDefAddFeature(virCPUDefPtr cpu, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d1a483a..1e3bede 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19877,7 +19877,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAddLit(buf, "</features>\n"); } - if (virCPUDefFormatBufFull(buf, def->cpu, flags) < 0) + if (virCPUDefFormatBufFull(buf, def->cpu, + !!(flags & VIR_DOMAIN_XML_UPDATE_CPU)) < 0) goto error; virBufferAsprintf(buf, "<clock offset='%s'", diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 788f688..6976b7b 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -472,7 +472,7 @@ cpuBaselineXML(const char **xmlCPUs, if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels, flags))) goto error; - cpustr = virCPUDefFormat(cpu, 0); + cpustr = virCPUDefFormat(cpu, false); cleanup: if (cpus) { diff --git a/tests/cputest.c b/tests/cputest.c index a507576..e49ae24 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -153,7 +153,7 @@ static int cpuTestCompareXML(const char *arch, virCPUDef *cpu, const char *name, - unsigned int flags) + bool updateCPU) { char *xml = NULL; char *expected = NULL; @@ -167,7 +167,7 @@ cpuTestCompareXML(const char *arch, if (virtTestLoadFile(xml, &expected) < 0) goto cleanup; - if (!(actual = virCPUDefFormat(cpu, flags))) + if (!(actual = virCPUDefFormat(cpu, updateCPU))) goto cleanup; if (STRNEQ(expected, actual)) { @@ -303,7 +303,7 @@ cpuTestGuestData(const void *arg) } result = virBufferContentAndReset(&buf); - ret = cpuTestCompareXML(data->arch, guest, result, 0); + ret = cpuTestCompareXML(data->arch, guest, result, false); cleanup: VIR_FREE(result); @@ -351,7 +351,7 @@ cpuTestBaseline(const void *arg) if (virAsprintf(&result, "%s-%s", data->name, suffix) < 0) goto cleanup; - if (cpuTestCompareXML(data->arch, baseline, result, 0) < 0) + if (cpuTestCompareXML(data->arch, baseline, result, false) < 0) goto cleanup; for (i = 0; i < ncpus; i++) { @@ -403,8 +403,7 @@ cpuTestUpdate(const void *arg) if (virAsprintf(&result, "%s+%s", data->host, data->name) < 0) goto cleanup; - ret = cpuTestCompareXML(data->arch, cpu, result, - VIR_DOMAIN_XML_UPDATE_CPU); + ret = cpuTestCompareXML(data->arch, cpu, result, true); cleanup: virCPUDefFree(host); -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list