From nobody Thu Jul 10 00:37:47 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507129875046610.9338149485877; Wed, 4 Oct 2017 08:11:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F5D8C059B7C; Wed, 4 Oct 2017 15:11:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC6CE5C8B2; Wed, 4 Oct 2017 15:11:13 +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 6851718355C5; Wed, 4 Oct 2017 15:11:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v94Ewsx7006805 for ; Wed, 4 Oct 2017 10:58:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DC9E5C8B2; Wed, 4 Oct 2017 14:58:54 +0000 (UTC) Received: from mamuti.net (unknown [10.34.246.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF80F5C8BA for ; Wed, 4 Oct 2017 14:58:51 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 2DA5410174C; Wed, 4 Oct 2017 16:58:50 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F5D8C059B7C Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 4 Oct 2017 16:58:26 +0200 Message-Id: <323787c916bf5c1f05909ff206778332d434e37e.1507128897.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/23] conf: Add usability blockers to virDomainCapsCPUModel 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 04 Oct 2017 15:11:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When a hypervisor marks a CPU model as unusable on the current host, it may also give us a list of features which prevent the model from being usable. Storing this list in virDomainCapsCPUModel will help the CPU driver with creating a host-model CPU configuration. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- src/conf/domain_capabilities.c | 30 ++++++++++++++++++++++-------- src/conf/domain_capabilities.h | 7 +++++-- src/qemu/qemu_capabilities.c | 11 ++++++----- tests/domaincapstest.c | 6 +++--- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index f62038b96c..be34576204 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -163,7 +163,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr ol= d) for (i =3D 0; i < old->nmodels; i++) { if (virDomainCapsCPUModelsAdd(cpuModels, old->models[i].name, -1, - old->models[i].usable) < 0) + old->models[i].usable, + old->models[i].blockers) < 0) goto error; } =20 @@ -195,7 +196,8 @@ virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr = old, =20 if (virDomainCapsCPUModelsAdd(cpuModels, old->models[i].name, -1, - old->models[i].usable) < 0) + old->models[i].usable, + old->models[i].blockers) < 0) goto error; } =20 @@ -210,7 +212,8 @@ virDomainCapsCPUModelsFilter(virDomainCapsCPUModelsPtr = old, int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, char **name, - virDomainCapsCPUUsable usable) + virDomainCapsCPUUsable usable, + char ***blockers) { if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, cpuModels->nmodels, 1) < 0) @@ -218,6 +221,10 @@ virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsP= tr cpuModels, =20 cpuModels->models[cpuModels->nmodels].usable =3D usable; VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].name, *name); + + if (blockers) + VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].blockers, *blo= ckers); + cpuModels->nmodels++; return 0; } @@ -227,20 +234,27 @@ int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, const char *name, ssize_t nameLen, - virDomainCapsCPUUsable usable) + virDomainCapsCPUUsable usable, + char **blockers) { - char *copy =3D NULL; + char *nameCopy =3D NULL; + char **blockersCopy =3D NULL; =20 - if (VIR_STRNDUP(copy, name, nameLen) < 0) + if (VIR_STRNDUP(nameCopy, name, nameLen) < 0) goto error; =20 - if (virDomainCapsCPUModelsAddSteal(cpuModels, ©, usable) < 0) + if (virStringListCopy(&blockersCopy, (const char **)blockers) < 0) + goto error; + + if (virDomainCapsCPUModelsAddSteal(cpuModels, &nameCopy, + usable, &blockersCopy) < 0) goto error; =20 return 0; =20 error: - VIR_FREE(copy); + VIR_FREE(nameCopy); + virStringListFree(blockersCopy); return -1; } =20 diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 82183c4524..8c71dec21e 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -116,6 +116,7 @@ typedef virDomainCapsCPUModel *virDomainCapsCPUModelPtr; struct _virDomainCapsCPUModel { char *name; virDomainCapsCPUUsable usable; + char **blockers; /* NULL-terminated list of usability blockers */ }; =20 typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels; @@ -171,11 +172,13 @@ virDomainCapsCPUModelsPtr virDomainCapsCPUModelsFilte= r(virDomainCapsCPUModelsPtr const char **blackl= ist); int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, char **name, - virDomainCapsCPUUsable usable); + virDomainCapsCPUUsable usable, + char ***blockers); int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, const char *name, ssize_t nameLen, - virDomainCapsCPUUsable usable); + virDomainCapsCPUUsable usable, + char **blockers); =20 # define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...) \ do { \ diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 085910dd4d..b20dd6ec32 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -795,7 +795,7 @@ virQEMUCapsParseX86Models(const char *output, } =20 if (virDomainCapsCPUModelsAdd(cpus, p, len, - VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0) + VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL= ) < 0) goto error; } while ((p =3D next)); =20 @@ -853,7 +853,7 @@ virQEMUCapsParsePPCModels(const char *output, continue; =20 if (virDomainCapsCPUModelsAdd(cpus, p, t - p - 1, - VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0) + VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL= ) < 0) goto error; } while ((p =3D next)); =20 @@ -2524,7 +2524,7 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, } =20 for (i =3D 0; i < count; i++) { - if (virDomainCapsCPUModelsAdd(cpus, name[i], -1, usable) < 0) + if (virDomainCapsCPUModelsAdd(cpus, name[i], -1, usable, NULL) < 0) return -1; } =20 @@ -3005,7 +3005,8 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemu= Caps, else if (cpus[i]->usable =3D=3D VIR_TRISTATE_BOOL_NO) usable =3D VIR_DOMCAPS_CPU_USABLE_NO; =20 - if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable)= < 0) + if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable, + NULL) < 0) goto cleanup; } =20 @@ -3768,7 +3769,7 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, goto cleanup; } =20 - if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable) < 0) + if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, NULL) < 0) goto cleanup; } =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 2719473244..7aeac4507f 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -88,11 +88,11 @@ fillAllCaps(virDomainCapsPtr domCaps) cpu->hostModel =3D virCPUDefCopy(&host); if (!(cpu->custom =3D virDomainCapsCPUModelsNew(3)) || virDomainCapsCPUModelsAdd(cpu->custom, "Model1", -1, - VIR_DOMCAPS_CPU_USABLE_UNKNOWN) < 0 || + VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL) < = 0 || virDomainCapsCPUModelsAdd(cpu->custom, "Model2", -1, - VIR_DOMCAPS_CPU_USABLE_NO) < 0 || + VIR_DOMCAPS_CPU_USABLE_NO, NULL) < 0 || virDomainCapsCPUModelsAdd(cpu->custom, "Model3", -1, - VIR_DOMCAPS_CPU_USABLE_YES) < 0) + VIR_DOMCAPS_CPU_USABLE_YES, NULL) < 0) return -1; =20 disk->supported =3D true; --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list