Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 36 ++++++++++++++++++++++++++++++++++++
src/qemu/qemu_capabilities.h | 3 +++
2 files changed, 39 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 802d3f7e1a..9d5eaf0c1a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2171,6 +2171,42 @@ bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
}
+const char *
+virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
+ const char *name,
+ virDomainVirtType type)
+{
+ qemuMonitorCPUDefsPtr defs;
+ const char *cpuType = NULL;
+ size_t i;
+
+ if (type == VIR_DOMAIN_VIRT_KVM)
+ defs = qemuCaps->kvmCPUModels;
+ else
+ defs = qemuCaps->tcgCPUModels;
+
+ if (!name || !defs)
+ return NULL;
+
+ for (i = 0; i < qemuCaps->nmachineTypes; i++) {
+ if (STREQ(qemuCaps->machineTypes[i].name, name)) {
+ cpuType = qemuCaps->machineTypes[i].defaultCPU;
+ break;
+ }
+ }
+
+ if (!cpuType)
+ return NULL;
+
+ for (i = 0; i < defs->ncpus; i++) {
+ if (STREQ(defs->cpus[i].type, cpuType))
+ return defs->cpus[i].name;
+ }
+
+ return NULL;
+}
+
+
/**
* virQEMUCapsSetGICCapabilities:
* @qemuCaps: QEMU capabilities
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index f1510f3a7b..beed927f06 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -599,6 +599,9 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
const char *name);
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
const char *name);
+const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
+ const char *name,
+ virDomainVirtType type);
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines,
virCapsGuestMachinePtr **machines);
--
2.23.0