Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 538a35d327..0dfc93a373 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17363,6 +17363,58 @@ qemuConnectGetHypervisorCPUModelNames(virConnectPtr conn, } +static int +qemuConnectGetHypervisorCPUModelDefinition(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags) +{ + virQEMUDriver *driver = conn->privateData; + g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); + g_autoptr(qemuProcessQMP) proc = NULL; + g_autoptr(virQEMUCaps) qemuCaps = NULL; + g_autoptr(virCPUDef) cpu = g_new0(virCPUDef, 1); + g_autoptr(qemuMonitorCPUModelInfo) model_info = NULL; + + virCheckFlags(0, -1); + if (virConnectGetHypervisorCPUModelDefinitionEnsureACL(conn) < 0) + return -1; + + qemuCaps = virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, NULL, + arch, NULL, machine, NULL, + NULL, NULL); + if (!qemuCaps) + return -1; + + if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), cfg->libDir, + cfg->user, cfg->group, false))) + return -1; + + if (qemuProcessQMPStart(proc) < 0) + return -1; + + cpu->model = g_strdup(name); + if (qemuMonitorGetCPUModelExpansion(proc->mon, + QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL, + cpu, true, true, &model_info) < 0) + return -1; + + if (!model_info) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown model '%s'"), name); + return -1; + } + + if (qemuConnectStealCPUModelFromInfo(cpu, &model_info) < 0) + return -1; + + *xmlCPU = virCPUDefFormat(cpu, NULL); + return 0; +} + + static int qemuDomainGetHostnameAgent(virQEMUDriver *driver, virDomainObj *vm, @@ -21376,6 +21428,7 @@ static virHypervisorDriver qemuHypervisorDriver = { .domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState = qemuDomainSetLaunchSecurityState, /* 8.0.0 */ .connectGetHypervisorCPUModelNames = qemuConnectGetHypervisorCPUModelNames, /* 8.5.0 */ + .connectGetHypervisorCPUModelDefinition = qemuConnectGetHypervisorCPUModelDefinition, /* 8.5.0 */ }; -- 2.31.1