From nobody Wed May 14 06:58:26 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 1526460006667169.16069484692605; Wed, 16 May 2018 01:40:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68BEBD8187; Wed, 16 May 2018 08:40:03 +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 2565998F7C; Wed, 16 May 2018 08:40:03 +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 6DC993FCFC; Wed, 16 May 2018 08:40:02 +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 w4G8dkW7018385 for ; Wed, 16 May 2018 04:39:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F7692166BAD; Wed, 16 May 2018 08:39:46 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E3472166BB1 for ; Wed, 16 May 2018 08:39:46 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id EB956102EF1; Wed, 16 May 2018 10:39:42 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 16 May 2018 10:39:39 +0200 Message-Id: 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 20/22] qemu_capabilities: Introduce virQEMUCapsGetCPUFeatures 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 16 May 2018 08:40:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function creates a lost of all (or migratable only) CPU features supported by QEMU. It works by looking at the CPU model info returned by query-cpu-model-expansion QMP command. Signed-off-by: Jiri Denemark Reviewed-by: Collin Walling Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 4 +++ 2 files changed, 56 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 77a4b4154e..e8c5940210 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2367,6 +2367,58 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, return ret; } =20 + +/** + * Get NULL terminated list of features supported by QEMU. + * + * Returns -1 on error, + * 0 on success (@features will be NULL if QEMU does not support = this), + * 1 when @features is filled in, but migratability info is not a= vailable. + */ +int +virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType, + bool migratable, + char ***features) +{ + virQEMUCapsHostCPUDataPtr data; + char **list; + size_t i; + size_t n; + int ret =3D -1; + + *features =3D NULL; + data =3D virQEMUCapsGetHostCPUData(qemuCaps, virtType); + + if (!data->info) + return 0; + + if (VIR_ALLOC_N(list, data->info->nprops + 1) < 0) + return -1; + + n =3D 0; + for (i =3D 0; i < data->info->nprops; i++) { + qemuMonitorCPUPropertyPtr prop =3D data->info->props + i; + + if (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_NO) + continue; + + if (VIR_STRDUP(list[n++], prop->name) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(*features, list); + if (migratable && !data->info->migratability) + ret =3D 1; + else + ret =3D 0; + + cleanup: + virStringListFree(list); + return ret; +} + + struct tpmTypeToCaps { int type; virQEMUCapsFlags caps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6f095bfbfe..eee989559e 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -529,6 +529,10 @@ typedef enum { virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps, virDomainVirtType type, virQEMUCapsHostCPUType cpuType); +int virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, + virDomainVirtType virtType, + bool migratable, + char ***features); =20 bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps, virCapsPtr caps, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list