From nobody Thu May 15 13:07:29 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 1507918942668584.7068823592859; Fri, 13 Oct 2017 11:22:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87F2C7EAA6; Fri, 13 Oct 2017 18:22:21 +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 6928018A70; Fri, 13 Oct 2017 18:22:21 +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 25E863FA5F; Fri, 13 Oct 2017 18:22:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9DIF1kK014044 for ; Fri, 13 Oct 2017 14:15:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5EE5460BE3; Fri, 13 Oct 2017 18:15:01 +0000 (UTC) Received: from mamuti.net (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E626B614EA for ; Fri, 13 Oct 2017 18:14:57 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 0D6991006CA; Fri, 13 Oct 2017 20:14:56 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87F2C7EAA6 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 13 Oct 2017 20:14:34 +0200 Message-Id: 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.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 02/22] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 13 Oct 2017 18:22:22 +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 --- Notes: Version 2: - no change 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 f9028157f1..7f4d019e9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -796,7 +796,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 @@ -854,7 +854,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 @@ -2526,7 +2526,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 @@ -3007,7 +3007,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 @@ -3770,7 +3771,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