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: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-08-22 11:11:28 +01:00
parent c29ce35af6
commit 116e2facde
2 changed files with 88 additions and 0 deletions

View File

@ -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;
}

View File

@ -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,