From nobody Tue Feb 10 16:18:58 2026 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 1547341060312817.2984452439581; Sat, 12 Jan 2019 16:57:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89C3D13BF6C; Sun, 13 Jan 2019 00:57:38 +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 543ED171C1; Sun, 13 Jan 2019 00:57:38 +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 0E11818E3019; Sun, 13 Jan 2019 00:57:38 +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 x0D0vYSp001988 for ; Sat, 12 Jan 2019 19:57:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id BFFC98176B; Sun, 13 Jan 2019 00:57:34 +0000 (UTC) Received: from cv1.lan (ovpn-126-68.rdu2.redhat.com [10.10.126.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AAFC81751; Sun, 13 Jan 2019 00:57:33 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Sat, 12 Jan 2019 18:50:25 -0600 Message-Id: <20190113005032.17880-27-cventeic@redhat.com> In-Reply-To: <20190113005032.17880-1-cventeic@redhat.com> References: <20190113005032.17880-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com, mprivozn@redhat.com, jdenemar@redhat.com, chris@venteicher.org Subject: [libvirt] [PATCH v6 26/33] qemu_capabilities: Introduce virCPUDef to CPUModelInfo function 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 13 Jan 2019 00:57:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Create public function to convert virCPUDef data structure into qemuMonitorCPUModelInfoPtr data structure. There was no existing code to reuse to create this function so this new virQEMUCapsCPUModelInfoFromCPUDef function was based on reversing the action of the existing virQEMUCapsCPUModelInfoToCPUDef function. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 53 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2bb56763b0..d0a2a42c97 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3664,6 +3664,58 @@ virQEMUCapsLoadCache(virArch hostArch, } =20 =20 +/** + * virQEMUCapsCPUModelInfoFromCPUDef: + * @cpuDef: input model + * + * virCPUDef model =3D> qemuMonitorCPUModelInfo name + * virCPUDef features =3D> qemuMonitorCPUModelInfo boolean properties + * + * property have true value if feature policy is undefined (-1), FORCE or = REQUIRE + * These semantics may need to be modified for other cases. + */ +qemuMonitorCPUModelInfoPtr +virQEMUCapsCPUModelInfoFromCPUDef(const virCPUDef *cpuDef) +{ + size_t i; + qemuMonitorCPUModelInfoPtr cpuModel =3D NULL; + qemuMonitorCPUModelInfoPtr ret =3D NULL; + + VIR_DEBUG("cpuDef =3D %p, cpuDef->model =3D %s", cpuDef, NULLSTR(cpuDe= f ? cpuDef->model : NULL)); + + if (!cpuDef || (VIR_ALLOC(cpuModel) < 0)) + goto cleanup; + + if (VIR_STRDUP(cpuModel->name, cpuDef->model) < 0 || + VIR_ALLOC_N(cpuModel->props, cpuDef->nfeatures) < 0) + goto cleanup; + + cpuModel->nprops =3D 0; + + for (i =3D 0; i < cpuDef->nfeatures; i++) { + qemuMonitorCPUPropertyPtr prop =3D &(cpuModel->props[cpuModel->npr= ops]); + virCPUFeatureDefPtr feature =3D &(cpuDef->features[i]); + + if (VIR_STRDUP(prop->name, feature->name) < 0) + goto cleanup; + + prop->type =3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN; + + prop->value.boolean =3D feature->policy =3D=3D -1 || /* policy und= efined */ + feature->policy =3D=3D VIR_CPU_FEATURE_FORCE= || + feature->policy =3D=3D VIR_CPU_FEATURE_REQUI= RE; + + cpuModel->nprops++; + } + + VIR_STEAL_PTR(ret, cpuModel); + + cleanup: + qemuMonitorCPUModelInfoFree(cpuModel); + return ret; +} + + /** * virQEMUCapsCPUModelInfoToCPUDef: * @model: input model diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 834844c1be..e05596ae06 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -583,6 +583,7 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuC= aps, void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); =20 +qemuMonitorCPUModelInfoPtr virQEMUCapsCPUModelInfoFromCPUDef(const virCPUD= ef *cpuDef); virCPUDefPtr virQEMUCapsCPUModelInfoToCPUDef(qemuMonitorCPUModelInfoPtr mo= del, bool migratable); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list