提交 350e3fee 编写于 作者: J Jiri Denemark

cpuGetModels: Switch to virArch

Our internal APIs mostly use virArch rather than strings. Switching
cpuGetModels to virArch will save us from unnecessary conversions in the
future.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 1fc90ae9
...@@ -747,7 +747,7 @@ cpuModelIsAllowed(const char *model, ...@@ -747,7 +747,7 @@ cpuModelIsAllowed(const char *model,
/** /**
* cpuGetModels: * cpuGetModels:
* *
* @archName: CPU architecture string * @arch: CPU architecture
* @models: where to store the NULL-terminated list of supported models * @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.
...@@ -755,26 +755,17 @@ cpuModelIsAllowed(const char *model, ...@@ -755,26 +755,17 @@ cpuModelIsAllowed(const char *model,
* Returns number of supported CPU models or -1 on error. * Returns number of supported CPU models or -1 on error.
*/ */
int int
cpuGetModels(const char *archName, char ***models) cpuGetModels(virArch arch, char ***models)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
virArch arch;
VIR_DEBUG("arch=%s", archName);
arch = virArchFromString(archName); VIR_DEBUG("arch=%s", virArchToString(arch));
if (arch == VIR_ARCH_NONE) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot find architecture %s"),
archName);
return -1;
}
driver = cpuGetSubDriver(arch); driver = cpuGetSubDriver(arch);
if (driver == NULL) { if (driver == NULL) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("cannot find a driver for the architecture %s"), _("cannot find a driver for the architecture %s"),
archName); virArchToString(arch));
return -1; return -1;
} }
......
...@@ -199,8 +199,7 @@ cpuModelIsAllowed(const char *model, ...@@ -199,8 +199,7 @@ cpuModelIsAllowed(const char *model,
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int int
cpuGetModels(const char *arch, char ***models) cpuGetModels(virArch arch, char ***models);
ATTRIBUTE_NONNULL(1);
/* cpuDataFormat and cpuDataParse are implemented for unit tests only and /* cpuDataFormat and cpuDataParse are implemented for unit tests only and
* have no real-life usage * have no real-life usage
......
...@@ -678,7 +678,7 @@ typedef char * ...@@ -678,7 +678,7 @@ typedef char *
typedef int typedef int
(*virDrvConnectGetCPUModelNames)(virConnectPtr conn, (*virDrvConnectGetCPUModelNames)(virConnectPtr conn,
const char *args, const char *archName,
char ***models, char ***models,
unsigned int flags); unsigned int flags);
......
...@@ -18369,14 +18369,23 @@ qemuNodeSuspendForDuration(virConnectPtr conn, ...@@ -18369,14 +18369,23 @@ qemuNodeSuspendForDuration(virConnectPtr conn,
static int static int
qemuConnectGetCPUModelNames(virConnectPtr conn, qemuConnectGetCPUModelNames(virConnectPtr conn,
const char *arch, const char *archName,
char ***models, char ***models,
unsigned int flags) unsigned int flags)
{ {
virArch arch;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (virConnectGetCPUModelNamesEnsureACL(conn) < 0) if (virConnectGetCPUModelNamesEnsureACL(conn) < 0)
return -1; return -1;
if (!(arch = virArchFromString(archName))) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot find architecture %s"),
archName);
return -1;
}
return cpuGetModels(arch, models); return cpuGetModels(arch, models);
} }
......
...@@ -5893,11 +5893,21 @@ testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED, ...@@ -5893,11 +5893,21 @@ testDomainScreenshot(virDomainPtr dom ATTRIBUTE_UNUSED,
static int static int
testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED, testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
const char *arch, const char *archName,
char ***models, char ***models,
unsigned int flags) unsigned int flags)
{ {
virArch arch;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(arch = virArchFromString(archName))) {
virReportError(VIR_ERR_INVALID_ARG,
_("cannot find architecture %s"),
archName);
return -1;
}
return cpuGetModels(arch, models); return cpuGetModels(arch, models);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册