* @arch: CPU architecture
* @models: where to store the NULL-terminated list of supported models
*
- * Fetches all CPU models supported by libvirt on @archName.
+ * Fetches all CPU models supported by libvirt on @archName. If there are
+ * no restrictions on CPU models on @archName (i.e., the CPU model is just
+ * passed directly to a hypervisor), this function returns 0 and sets
+ * @models to NULL.
*
- * Returns number of supported CPU models or -1 on error.
+ * Returns number of supported CPU models, 0 if any CPU model is supported,
+ * or -1 on error.
*/
int
cpuGetModels(virArch arch, char ***models)
}
if (!driver->getModels) {
- virReportError(VIR_ERR_NO_SUPPORT,
- _("CPU driver for %s has no CPU model support"),
- virArchToString(arch));
- return -1;
+ if (models)
+ *models = NULL;
+ return 0;
}
return driver->getModels(models);
*
* Get the list of supported CPU models for a specific architecture.
*
- * Returns -1 on error, number of elements in @models on success.
+ * Returns -1 on error, number of elements in @models on success (0 means
+ * libvirt accepts any CPU model).
*/
int
virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models,
return false;
}
- for (i = 0; i < nmodels; i++) {
- vshPrint(ctl, "%s\n", models[i]);
- VIR_FREE(models[i]);
+ if (nmodels == 0) {
+ vshPrintExtra(ctl, "%s\n", _("all CPU models are accepted"));
+ } else {
+ for (i = 0; i < nmodels; i++) {
+ vshPrint(ctl, "%s\n", models[i]);
+ VIR_FREE(models[i]);
+ }
}
VIR_FREE(models);