From nobody Mon Dec 15 23:21:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526460019929812.2861128521484; Wed, 16 May 2018 01:40:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2D44F56F1; Wed, 16 May 2018 08:40:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9274720155E6; Wed, 16 May 2018 08:40:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 28803EEF7; Wed, 16 May 2018 08:40:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4G8dlxK018437 for ; Wed, 16 May 2018 04:39:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 371FC2166BAE; Wed, 16 May 2018 08:39:47 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 164332166BAD for ; Wed, 16 May 2018 08:39:47 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id EF9F4102EF2; Wed, 16 May 2018 10:39:42 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 16 May 2018 10:39:40 +0200 Message-Id: <73706d940919cff2cc5ae18bef47e941edab81af.1526459534.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/22] qemu: Implement virConnectBaselineHypervisorCPU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 16 May 2018 08:40:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Collin Walling Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_driver.c | 91 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e036764f92..d702e8a8ff 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13206,6 +13206,96 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUT= E_UNUSED, } =20 =20 +static char * +qemuConnectBaselineHypervisorCPU(virConnectPtr conn, + const char *emulator, + const char *archStr, + const char *machine, + const char *virttypeStr, + const char **xmlCPUs, + unsigned int ncpus, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D conn->privateData; + virCPUDefPtr *cpus =3D NULL; + virQEMUCapsPtr qemuCaps =3D NULL; + virArch arch; + virDomainVirtType virttype; + virDomainCapsCPUModelsPtr cpuModels; + bool migratable; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; + char **features =3D NULL; + + virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | + VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); + + if (virConnectBaselineHypervisorCPUEnsureACL(conn) < 0) + goto cleanup; + + migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); + + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_AUTO))) + goto cleanup; + + qemuCaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, + emulator, + archStr, + virttypeStr, + machine, + &arch, &virttype, NULL); + if (!qemuCaps) + goto cleanup; + + if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) = || + cpuModels->nmodels =3D=3D 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("QEMU '%s' does not support any CPU models for " + "virttype '%s'"), + virQEMUCapsGetBinary(qemuCaps), + virDomainVirtTypeToString(virttype)); + goto cleanup; + } + + if (ARCH_IS_X86(arch)) { + int rc =3D virQEMUCapsGetCPUFeatures(qemuCaps, virttype, + migratable, &features); + if (rc < 0) + goto cleanup; + if (features && rc =3D=3D 0) { + /* We got only migratable features from QEMU if we asked for t= hem, + * no further filtering in virCPUBaseline is desired. */ + migratable =3D false; + } + + if (!(cpu =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, + (const char **)features, migratable))) + goto cleanup; + } else { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("computing baseline hypervisor CPU is not support= ed " + "for arch %s"), virArchToString(arch)); + goto cleanup; + } + + cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL); + + cleanup: + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + virObjectUnref(qemuCaps); + virStringListFree(features); + + return cpustr; +} + + static int qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -21386,6 +21476,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold, /* 3.2.0 */ .domainSetLifecycleAction =3D qemuDomainSetLifecycleAction, /* 3.9.0 */ .connectCompareHypervisorCPU =3D qemuConnectCompareHypervisorCPU, /* 4= .4.0 */ + .connectBaselineHypervisorCPU =3D qemuConnectBaselineHypervisorCPU, /*= 4.4.0 */ }; =20 =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list