From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> Update the CPU helper APIs to use virReportError instead of the virCPUReportError custom macor Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- cfg.mk | 1 - src/cpu/cpu.c | 86 ++++++++++++++++---------------- src/cpu/cpu.h | 5 -- src/cpu/cpu_generic.c | 18 +++---- src/cpu/cpu_map.c | 22 ++++----- src/cpu/cpu_x86.c | 132 ++++++++++++++++++++++++------------------------- 6 files changed, 129 insertions(+), 135 deletions(-) diff --git a/cfg.mk b/cfg.mk index 5e433f9..9dfb618 100644 --- a/cfg.mk +++ b/cfg.mk @@ -525,7 +525,6 @@ msg_gen_function += streamsReportError msg_gen_function += vah_error msg_gen_function += vah_warning msg_gen_function += virConfError -msg_gen_function += virCPUReportError msg_gen_function += virGenericReportError msg_gen_function += virLibConnError msg_gen_function += virLibDomainError diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 0ccbd4c..c7a08c0 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -54,8 +54,8 @@ cpuGetSubDriver(const char *arch) unsigned int j; if (arch == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("undefined hardware architecture")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("undefined hardware architecture")); return NULL; } @@ -90,8 +90,8 @@ cpuCompareXML(virCPUDefPtr host, goto cleanup; if (!cpu->model) { - virCPUReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("no CPU model specified")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("no CPU model specified")); goto cleanup; } @@ -118,9 +118,9 @@ cpuCompare(virCPUDefPtr host, return VIR_CPU_COMPARE_ERROR; if (driver->compare == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot compare CPUs of %s architecture"), - host->arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot compare CPUs of %s architecture"), + host->arch); return VIR_CPU_COMPARE_ERROR; } @@ -146,14 +146,14 @@ cpuDecode(virCPUDefPtr cpu, } if (models == NULL && nmodels != 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("nonzero nmodels doesn't match with NULL models")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("nonzero nmodels doesn't match with NULL models")); return -1; } if (cpu == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid CPU definition")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("invalid CPU definition")); return -1; } @@ -161,9 +161,9 @@ cpuDecode(virCPUDefPtr cpu, return -1; if (driver->decode == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot decode CPU data for %s architecture"), - cpu->arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot decode CPU data for %s architecture"), + cpu->arch); return -1; } @@ -192,9 +192,9 @@ cpuEncode(const char *arch, return -1; if (driver->encode == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot encode CPU data for %s architecture"), - arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot encode CPU data for %s architecture"), + arch); return -1; } @@ -218,9 +218,9 @@ cpuDataFree(const char *arch, return; if (driver->free == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot free CPU data for %s architecture"), - arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot free CPU data for %s architecture"), + arch); return; } @@ -239,9 +239,9 @@ cpuNodeData(const char *arch) return NULL; if (driver->nodeData == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot get node CPU data for %s architecture"), - arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot get node CPU data for %s architecture"), + arch); return NULL; } @@ -263,9 +263,9 @@ cpuGuestData(virCPUDefPtr host, return VIR_CPU_COMPARE_ERROR; if (driver->guestData == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot compute guest CPU data for %s architecture"), - host->arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot compute guest CPU data for %s architecture"), + host->arch); return VIR_CPU_COMPARE_ERROR; } @@ -297,13 +297,13 @@ cpuBaselineXML(const char **xmlCPUs, } if (xmlCPUs == NULL && ncpus != 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("nonzero ncpus doesn't match with NULL xmlCPUs")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("nonzero ncpus doesn't match with NULL xmlCPUs")); return NULL; } if (ncpus < 1) { - virCPUReportError(VIR_ERR_INVALID_ARG, "%s", _("No CPUs given")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("No CPUs given")); return NULL; } @@ -369,19 +369,19 @@ cpuBaseline(virCPUDefPtr *cpus, } if (cpus == NULL && ncpus != 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("nonzero ncpus doesn't match with NULL cpus")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("nonzero ncpus doesn't match with NULL cpus")); return NULL; } if (ncpus < 1) { - virCPUReportError(VIR_ERR_INVALID_ARG, "%s", _("No CPUs given")); + virReportError(VIR_ERR_INVALID_ARG, "%s", _("No CPUs given")); return NULL; } if (models == NULL && nmodels != 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("nonzero nmodels doesn't match with NULL models")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("nonzero nmodels doesn't match with NULL models")); return NULL; } @@ -389,9 +389,9 @@ cpuBaseline(virCPUDefPtr *cpus, return NULL; if (driver->baseline == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot compute baseline CPU of %s architecture"), - cpus[0]->arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot compute baseline CPU of %s architecture"), + cpus[0]->arch); return NULL; } @@ -411,9 +411,9 @@ cpuUpdate(virCPUDefPtr guest, return -1; if (driver->update == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot update guest CPU data for %s architecture"), - host->arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot update guest CPU data for %s architecture"), + host->arch); return -1; } @@ -434,9 +434,9 @@ cpuHasFeature(const char *arch, return -1; if (driver->hasFeature == NULL) { - virCPUReportError(VIR_ERR_NO_SUPPORT, - _("cannot check guest CPU data for %s architecture"), - arch); + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot check guest CPU data for %s architecture"), + arch); return -1; } diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index d7bc54e..8d6db44 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -30,11 +30,6 @@ # include "cpu_x86_data.h" -# define virCPUReportError(code, ...) \ - virReportErrorHelper(VIR_FROM_CPU, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) - - union cpuData { struct cpuX86Data x86; /* generic driver needs no data */ diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c index 2a31b49..cba6cfa 100644 --- a/src/cpu/cpu_generic.c +++ b/src/cpu/cpu_generic.c @@ -131,9 +131,9 @@ genericBaseline(virCPUDefPtr *cpus, } } if (!found) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU model '%s' is not support by hypervisor"), - cpus[0]->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU model '%s' is not support by hypervisor"), + cpus[0]->model); goto error; } } @@ -154,16 +154,16 @@ genericBaseline(virCPUDefPtr *cpus, virHashTablePtr hash; if (STRNEQ(cpu->arch, cpus[i]->arch)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPUs have incompatible architectures: '%s' != '%s'"), - cpu->arch, cpus[i]->arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPUs have incompatible architectures: '%s' != '%s'"), + cpu->arch, cpus[i]->arch); goto error; } if (STRNEQ(cpu->model, cpus[i]->model)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU models don't match: '%s' != '%s'"), - cpu->model, cpus[i]->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU models don't match: '%s' != '%s'"), + cpu->model, cpus[i]->model); goto error; } diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index b8a6374..9749423 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -86,21 +86,21 @@ int cpuMapLoad(const char *arch, const char *mapfile = (cpumap ? cpumap : CPUMAPFILE); if (arch == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("undefined hardware architecture")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("undefined hardware architecture")); return -1; } if (cb == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no callback provided")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no callback provided")); return -1; } if ((xml = xmlParseFile(mapfile)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse CPU map file: %s"), - mapfile); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse CPU map file: %s"), + mapfile); goto cleanup; } @@ -116,15 +116,15 @@ int cpuMapLoad(const char *arch, ctxt->node = xmlDocGetRootElement(xml); if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find CPU map for %s architecture"), arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find CPU map for %s architecture"), arch); goto cleanup; } for (element = 0; element < CPU_MAP_ELEMENT_LAST; element++) { if (load(ctxt, element, cb, data) < 0) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse CPU map for %s architecture"), arch); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse CPU map for %s architecture"), arch); goto cleanup; } } diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 73e9d7e..dce0a09 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -524,26 +524,26 @@ x86VendorLoad(xmlXPathContextPtr ctxt, vendor->name = virXPathString("string(@name)", ctxt); if (!vendor->name) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU vendor name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU vendor name")); goto ignore; } if (x86VendorFind(map, vendor->name)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU vendor %s already defined"), vendor->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU vendor %s already defined"), vendor->name); goto ignore; } string = virXPathString("string(@string)", ctxt); if (!string) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing vendor string for CPU vendor %s"), vendor->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing vendor string for CPU vendor %s"), vendor->name); goto ignore; } if (strlen(string) != VENDOR_STRING_LENGTH) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid CPU vendor string '%s'"), string); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid CPU vendor string '%s'"), string); goto ignore; } @@ -673,14 +673,14 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, feature->name = virXPathString("string(@name)", ctxt); if (feature->name == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU feature name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU feature name")); goto ignore; } if (x86FeatureFind(map, feature->name)) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU feature %s already defined"), feature->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU feature %s already defined"), feature->name); goto ignore; } @@ -703,8 +703,8 @@ x86FeatureLoad(xmlXPathContextPtr ctxt, if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2 || ret_ecx == -2 || ret_edx == -2) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid cpuid[%d] in %s feature"), i, feature->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid cpuid[%d] in %s feature"), i, feature->name); goto ignore; } @@ -816,8 +816,8 @@ x86ModelFromCPU(const virCPUDefPtr cpu, if (policy == VIR_CPU_FEATURE_REQUIRE) { if ((model = x86ModelFind(map, cpu->model)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU model %s"), cpu->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown CPU model %s"), cpu->model); goto error; } @@ -837,8 +837,8 @@ x86ModelFromCPU(const virCPUDefPtr cpu, continue; if ((feature = x86FeatureFind(map, cpu->features[i].name)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU feature %s"), cpu->features[i].name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown CPU feature %s"), cpu->features[i].name); goto error; } @@ -866,9 +866,9 @@ x86ModelSubtractCPU(struct x86_model *model, unsigned int i; if (!(cpu_model = x86ModelFind(map, cpu->model))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU model %s"), - cpu->model); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown CPU model %s"), + cpu->model); return -1; } @@ -878,9 +878,9 @@ x86ModelSubtractCPU(struct x86_model *model, const struct x86_feature *feature; if (!(feature = x86FeatureFind(map, cpu->features[i].name))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU feature %s"), - cpu->features[i].name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown CPU feature %s"), + cpu->features[i].name); return -1; } @@ -953,8 +953,8 @@ x86ModelLoad(xmlXPathContextPtr ctxt, model->name = virXPathString("string(@name)", ctxt); if (model->name == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU model name")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Missing CPU model name")); goto ignore; } @@ -964,16 +964,16 @@ x86ModelLoad(xmlXPathContextPtr ctxt, name = virXPathString("string(./model/@name)", ctxt); if (name == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing ancestor's name in CPU model %s"), - model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing ancestor's name in CPU model %s"), + model->name); goto ignore; } if ((ancestor = x86ModelFind(map, name)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Ancestor model %s not found for CPU model %s"), - name, model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Ancestor model %s not found for CPU model %s"), + name, model->name); VIR_FREE(name); goto ignore; } @@ -989,16 +989,16 @@ x86ModelLoad(xmlXPathContextPtr ctxt, if (virXPathBoolean("boolean(./vendor)", ctxt)) { vendor = virXPathString("string(./vendor/@name)", ctxt); if (!vendor) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vendor element in CPU model %s"), - model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid vendor element in CPU model %s"), + model->name); goto ignore; } if (!(model->vendor = x86VendorFind(map, vendor))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown vendor %s referenced by CPU model %s"), - vendor, model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown vendor %s referenced by CPU model %s"), + vendor, model->name); goto ignore; } } @@ -1012,15 +1012,15 @@ x86ModelLoad(xmlXPathContextPtr ctxt, char *name; if ((name = virXMLPropString(nodes[i], "name")) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing feature name for CPU model %s"), model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing feature name for CPU model %s"), model->name); goto ignore; } if ((feature = x86FeatureFind(map, name)) == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Feature %s required by CPU model %s not found"), - name, model->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Feature %s required by CPU model %s not found"), + name, model->name); VIR_FREE(name); goto ignore; } @@ -1336,9 +1336,9 @@ x86Decode(virCPUDefPtr cpu, if (!allowed) { if (preferred && STREQ(candidate->name, preferred)) { if (cpu->fallback != VIR_CPU_FALLBACK_ALLOW) { - virCPUReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("CPU model %s is not supported by hypervisor"), - preferred); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("CPU model %s is not supported by hypervisor"), + preferred); goto out; } else { VIR_WARN("Preferred CPU model %s not allowed by" @@ -1395,8 +1395,8 @@ x86Decode(virCPUDefPtr cpu, } if (cpuModel == NULL) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Cannot find suitable CPU model for given data")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Cannot find suitable CPU model for given data")); goto out; } @@ -1490,8 +1490,8 @@ x86Encode(const virCPUDefPtr cpu, const struct x86_vendor *v = NULL; if (cpu->vendor && !(v = x86VendorFind(map, cpu->vendor))) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - _("CPU vendor %s not found"), cpu->vendor); + virReportError(VIR_ERR_OPERATION_FAILED, + _("CPU vendor %s not found"), cpu->vendor); goto error; } @@ -1646,8 +1646,8 @@ x86Baseline(virCPUDefPtr *cpus, if (!cpus[0]->vendor) outputVendor = false; else if (!(vendor = x86VendorFind(map, cpus[0]->vendor))) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - _("Unknown CPU vendor %s"), cpus[0]->vendor); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Unknown CPU vendor %s"), cpus[0]->vendor); goto error; } @@ -1659,9 +1659,9 @@ x86Baseline(virCPUDefPtr *cpus, if (cpus[i]->vendor && model->vendor && STRNEQ(cpus[i]->vendor, model->vendor->name)) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - _("CPU vendor %s of model %s differs from vendor %s"), - model->vendor->name, model->name, cpus[i]->vendor); + virReportError(VIR_ERR_OPERATION_FAILED, + _("CPU vendor %s of model %s differs from vendor %s"), + model->vendor->name, model->name, cpus[i]->vendor); goto error; } @@ -1676,13 +1676,13 @@ x86Baseline(virCPUDefPtr *cpus, if (vn) { if (!vendor) { if (!(vendor = x86VendorFind(map, vn))) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - _("Unknown CPU vendor %s"), vn); + virReportError(VIR_ERR_OPERATION_FAILED, + _("Unknown CPU vendor %s"), vn); goto error; } } else if (STRNEQ(vendor->name, vn)) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("CPU vendors do not match")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("CPU vendors do not match")); goto error; } } @@ -1693,8 +1693,8 @@ x86Baseline(virCPUDefPtr *cpus, } if (x86DataIsEmpty(base_model->data)) { - virCPUReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("CPUs are incompatible")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("CPUs are incompatible")); goto error; } @@ -1742,9 +1742,9 @@ x86UpdateCustom(virCPUDefPtr guest, if (guest->features[i].policy == VIR_CPU_FEATURE_OPTIONAL) { const struct x86_feature *feature; if (!(feature = x86FeatureFind(map, guest->features[i].name))) { - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown CPU feature %s"), - guest->features[i].name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown CPU feature %s"), + guest->features[i].name); goto cleanup; } @@ -1792,8 +1792,8 @@ x86Update(virCPUDefPtr guest, break; } - virCPUReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected CPU mode: %d"), guest->mode); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU mode: %d"), guest->mode); return -1; } -- 1.7.10.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list