From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> 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@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 10 ++++++ 2 files changed, 88 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b6193d9..1e36e4b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -182,6 +182,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; }; @@ -1714,6 +1726,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); } @@ -1764,3 +1791,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; +} diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 830b283..c6e3756 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -163,6 +163,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, -- 1.7.11.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list