提交 116e2fac 编写于 作者: D Daniel P. Berrange

Add ability to store other metadata in the qemu capabilities object

Add struct fields and APIs to allow the qemu capabilities object
to store version, arch, machines & cpu names, etc
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 c29ce35a
......@@ -183,6 +183,18 @@ struct _qemuCaps {
virObject object;
virBitmapPtr flags;
unsigned int version;
unsigned int kvmVersion;
char *arch;
size_t ncpuDefinitions;
char **cpuDefinitions;
size_t nmachineTypes;
char **machineTypes;
char **machineAliases;
};
......@@ -1718,6 +1730,21 @@ no_memory:
void qemuCapsDispose(void *obj)
{
qemuCapsPtr caps = obj;
size_t i;
VIR_FREE(caps->arch);
for (i = 0 ; i < caps->nmachineTypes ; i++) {
VIR_FREE(caps->machineTypes[i]);
VIR_FREE(caps->machineAliases[i]);
}
VIR_FREE(caps->machineTypes);
VIR_FREE(caps->machineAliases);
for (i = 0 ; i < caps->ncpuDefinitions ; i++) {
VIR_FREE(caps->cpuDefinitions[i]);
}
VIR_FREE(caps->cpuDefinitions);
virBitmapFree(caps->flags);
}
......@@ -1768,3 +1795,54 @@ qemuCapsGet(qemuCapsPtr caps,
else
return b;
}
const char *qemuCapsGetArch(qemuCapsPtr caps)
{
return caps->arch;
}
unsigned int qemuCapsGetVersion(qemuCapsPtr caps)
{
return caps->version;
}
unsigned int qemuCapsGetKVMVersion(qemuCapsPtr caps)
{
return caps->kvmVersion;
}
size_t qemuCapsGetCPUDefinitions(qemuCapsPtr caps,
char ***names)
{
*names = caps->cpuDefinitions;
return caps->ncpuDefinitions;
}
size_t qemuCapsGetMachineTypes(qemuCapsPtr caps,
char ***names)
{
*names = caps->machineTypes;
return caps->nmachineTypes;
}
const char *qemuCapsGetCanonicalMachine(qemuCapsPtr caps,
const char *name)
{
size_t i;
for (i = 0 ; i < caps->nmachineTypes ; i++) {
if (!caps->machineAliases[i])
continue;
if (STREQ(caps->machineAliases[i], name))
return caps->machineTypes[i];
}
return name;
}
......@@ -164,6 +164,16 @@ bool qemuCapsGet(qemuCapsPtr caps,
char *qemuCapsFlagsString(qemuCapsPtr caps);
const char *qemuCapsGetArch(qemuCapsPtr caps);
unsigned int qemuCapsGetVersion(qemuCapsPtr caps);
unsigned int qemuCapsGetKVMVersion(qemuCapsPtr caps);
size_t qemuCapsGetCPUDefinitions(qemuCapsPtr caps,
char ***names);
size_t qemuCapsGetMachineTypes(qemuCapsPtr caps,
char ***names);
const char *qemuCapsGetCanonicalMachine(qemuCapsPtr caps,
const char *name);
virCapsPtr qemuCapsInit(virCapsPtr old_caps);
int qemuCapsProbeMachineTypes(const char *binary,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册