if (cpu == NULL)
goto cleanup;
- if (!cpu->model) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("no CPU model specified"));
- goto cleanup;
- }
-
ret = cpuCompare(host, cpu);
cleanup:
VIR_DEBUG("host=%p, cpu=%p", host, cpu);
+ if (!cpu->model) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("no guest CPU model specified"));
+ return VIR_CPU_COMPARE_ERROR;
+ }
+
if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR;
}
if (models == NULL && nmodels != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("nonzero nmodels doesn't match with NULL models"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("nonzero nmodels doesn't match with NULL models"));
return -1;
}
- if (cpu == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("invalid CPU definition"));
+ if (cpu->type > VIR_CPU_TYPE_GUEST ||
+ cpu->mode != VIR_CPU_MODE_CUSTOM) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("invalid CPU definition stub"));
return -1;
}
virArchToString(arch), cpu, forced, required,
optional, disabled, forbidden, vendor);
+ if (!cpu->model) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("no guest CPU model specified"));
+ return -1;
+ }
+
if ((driver = cpuGetSubDriver(arch)) == NULL)
return -1;
VIR_DEBUG("host=%p, guest=%p, data=%p, msg=%p", host, guest, data, msg);
+ if (!guest->model) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("no guest CPU model specified"));
+ return VIR_CPU_COMPARE_ERROR;
+ }
+
if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR;
return NULL;
}
+ for (i = 0; i < ncpus; i++) {
+ if (!cpus[i]) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("invalid CPU definition at index %zu"), i);
+ return NULL;
+ }
+ if (!cpus[i]->model) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("no CPU model specified at index %zu"), i);
+ return NULL;
+ }
+ }
+
if (models == NULL && nmodels != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("nonzero nmodels doesn't match with NULL models"));
extern virCPUCompareResult
cpuCompareXML(virCPUDefPtr host,
- const char *xml);
+ const char *xml)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
extern virCPUCompareResult
cpuCompare (virCPUDefPtr host,
- virCPUDefPtr cpu);
+ virCPUDefPtr cpu)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
extern int
cpuDecode (virCPUDefPtr cpu,
const virCPUData *data,
const char **models,
unsigned int nmodels,
- const char *preferred);
+ const char *preferred)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
extern int
cpuEncode (virArch arch,
virCPUDataPtr *optional,
virCPUDataPtr *disabled,
virCPUDataPtr *forbidden,
- virCPUDataPtr *vendor);
+ virCPUDataPtr *vendor)
+ ATTRIBUTE_NONNULL(2);
extern void
cpuDataFree (virCPUDataPtr data);
cpuGuestData(virCPUDefPtr host,
virCPUDefPtr guest,
virCPUDataPtr *data,
- char **msg);
+ char **msg)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
extern char *
cpuBaselineXML(const char **xmlCPUs,
unsigned int ncpus,
const char **models,
unsigned int nmodels,
- unsigned int flags);
+ unsigned int flags)
+ ATTRIBUTE_NONNULL(1);
extern int
cpuUpdate (virCPUDefPtr guest,
- const virCPUDef *host);
+ const virCPUDef *host)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
extern int
cpuHasFeature(const virCPUData *data,
- const char *feature);
+ const char *feature)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
bool
cpuModelIsAllowed(const char *model,
const char **models,
- unsigned int nmodels);
+ unsigned int nmodels)
+ ATTRIBUTE_NONNULL(1);
extern int
-cpuGetModels(const char *arch, char ***models);
+cpuGetModels(const char *arch, char ***models)
+ ATTRIBUTE_NONNULL(1);
/* cpuDataFormat and cpuDataParse are implemented for unit tests only and
* have no real-life usage
*/
-char *cpuDataFormat(const virCPUData *data);
+char *cpuDataFormat(const virCPUData *data)
+ ATTRIBUTE_NONNULL(1);
virCPUDataPtr cpuDataParse(virArch arch,
- const char *xmlStr);
+ const char *xmlStr)
+ ATTRIBUTE_NONNULL(2);
#endif /* __VIR_CPU_H__ */