/**
* cpuGetModels:
*
- * @archName: CPU architecture string
+ * @arch: CPU architecture
* @models: where to store the NULL-terminated list of supported models
*
* Fetches all CPU models supported by libvirt on @archName.
* Returns number of supported CPU models or -1 on error.
*/
int
-cpuGetModels(const char *archName, char ***models)
+cpuGetModels(virArch arch, char ***models)
{
struct cpuArchDriver *driver;
- virArch arch;
-
- VIR_DEBUG("arch=%s", archName);
- arch = virArchFromString(archName);
- if (arch == VIR_ARCH_NONE) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("cannot find architecture %s"),
- archName);
- return -1;
- }
+ VIR_DEBUG("arch=%s", virArchToString(arch));
driver = cpuGetSubDriver(arch);
if (driver == NULL) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot find a driver for the architecture %s"),
- archName);
+ virArchToString(arch));
return -1;
}
ATTRIBUTE_NONNULL(1);
int
-cpuGetModels(const char *arch, char ***models)
- ATTRIBUTE_NONNULL(1);
+cpuGetModels(virArch arch, char ***models);
/* cpuDataFormat and cpuDataParse are implemented for unit tests only and
* have no real-life usage
static int
qemuConnectGetCPUModelNames(virConnectPtr conn,
- const char *arch,
+ const char *archName,
char ***models,
unsigned int flags)
{
+ virArch arch;
+
virCheckFlags(0, -1);
if (virConnectGetCPUModelNamesEnsureACL(conn) < 0)
return -1;
+ if (!(arch = virArchFromString(archName))) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cannot find architecture %s"),
+ archName);
+ return -1;
+ }
+
return cpuGetModels(arch, models);
}
static int
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
- const char *arch,
+ const char *archName,
char ***models,
unsigned int flags)
{
+ virArch arch;
+
virCheckFlags(0, -1);
+
+ if (!(arch = virArchFromString(archName))) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cannot find architecture %s"),
+ archName);
+ return -1;
+ }
+
return cpuGetModels(arch, models);
}