From nobody Sun Feb 8 10:44:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572960571; cv=none; d=zoho.com; s=zohoarc; b=QyLJfFwTyfKPn5U1lX969+wAyyg38TQy8ImyOF5OoYQj4HkvuMVtuBgRG20jmkUsCpQjFKGJAWa2mzagGdaXCV/gBF2RJDSPEn4flF1hZR3Js9BRIJIQ542J11t+FtFL/9wNEIVmvSYwv1EobzCysWG2EdHZCwq+Z/k1jI3XWhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572960571; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XAApQJCg0D891dXWxoQJw3U2SyZ4dxc84R8uzj+UeWg=; b=JL8Y8Z0hfpi6/hMOzP6dpeQ35Sy8t06wJpBfMvq2rKf/xCZjRvah76jga1OosKVwclo+7u8eRRf4VtKfd4wfzlXbuFgQCcSLGsxTL0/qW1C3pRcqED5alSolifMEpLLw/olhR6qFA7L/1Sc27NHFYz/8f8clr6l06xDP6rOJzx0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1572960571192544.8196075050165; Tue, 5 Nov 2019 05:29:31 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-tAKvi2zDNQOZGp1b8es2Hg-1; Tue, 05 Nov 2019 08:29:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31FA7100551A; Tue, 5 Nov 2019 13:29:20 +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 05ADD608B6; Tue, 5 Nov 2019 13:29:20 +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 AE7964EDAE; Tue, 5 Nov 2019 13:29:19 +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 xA5DS3Pw004127 for ; Tue, 5 Nov 2019 08:28:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 61A5E5C1B2; Tue, 5 Nov 2019 13:28:03 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 366B55C28C for ; Tue, 5 Nov 2019 13:27:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 90450105B2C; Tue, 5 Nov 2019 14:27:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572960570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XAApQJCg0D891dXWxoQJw3U2SyZ4dxc84R8uzj+UeWg=; b=FYNgsZITSSTipmXuXBcJzG4qjFi9+r4JrpwuhiZyU4xVX8jeHCd/iUxL1lRGg3VmeW32aq 5nCrCXQtxHi3Xx7muAapoK7r5869malFlqbRpZxCbEi0VO2FjyUM3lLX3CYb5K3QZXPO09 nq2GXUXUj3jdMStk5wvmVacaThpv/ec= From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Nov 2019 14:27:13 +0100 Message-Id: <28c16cf2c0ffb4c6e34604319e597b0c9d44cd8a.1572958254.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 15/52] qemu: Introduce virQEMUCapsCPUDefsToModels 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: tAKvi2zDNQOZGp1b8es2Hg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function translates qemuMonitorCPUDefsPtr (used by QEMU caps probing code) into virDomainCapsCPUModelsPtr used by domain capabilities. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - trivial rebase =20 Version 3: - g_autoptr, g_steal_pointer src/qemu/qemu_capabilities.c | 58 ++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2a93488520..1497c4f645 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1881,6 +1881,35 @@ virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, } =20 =20 +static virDomainCapsCPUModelsPtr +virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefsPtr defs, + const char **modelWhitelist, + const char **modelBlacklist) +{ + g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; + size_t i; + + if (!(cpuModels =3D virDomainCapsCPUModelsNew(defs->ncpus))) + return NULL; + + for (i =3D 0; i < defs->ncpus; i++) { + qemuMonitorCPUDefInfoPtr cpu =3D defs->cpus + i; + + if (modelWhitelist && !virStringListHasString(modelWhitelist, cpu-= >name)) + continue; + + if (modelBlacklist && virStringListHasString(modelBlacklist, cpu->= name)) + continue; + + if (virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable, + cpu->blockers) < 0) + return NULL; + } + + return g_steal_pointer(&cpuModels); +} + + virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type, @@ -2448,19 +2477,15 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, virDomainCapsCPUModelsPtr *cpuModels) { g_autoptr(qemuMonitorCPUDefs) defs =3D NULL; - virDomainCapsCPUModelsPtr models =3D NULL; size_t i; - int ret =3D -1; =20 *cpuModels =3D NULL; =20 if (qemuMonitorGetCPUDefinitions(mon, &defs) < 0) return -1; =20 - if (!defs) { - ret =3D 0; - goto cleanup; - } + if (!defs) + return 0; =20 /* QEMU 2.11 for Power renamed all CPU models to lower case, we need to * translate them back to libvirt's upper case model names. */ @@ -2469,7 +2494,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, char **name; =20 if (virCPUGetModels(arch, &libvirtModels) < 0) - goto cleanup; + return -1; =20 for (name =3D libvirtModels; name && *name; name++) { for (i =3D 0; i < defs->ncpus; i++) { @@ -2482,23 +2507,10 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, } } =20 - if (!(models =3D virDomainCapsCPUModelsNew(defs->ncpus))) - goto cleanup; - - for (i =3D 0; i < defs->ncpus; i++) { - if (virDomainCapsCPUModelsAddSteal(models, - &defs->cpus[i].name, - defs->cpus[i].usable, - &defs->cpus[i].blockers) < 0) - goto cleanup; - } - - *cpuModels =3D g_steal_pointer(&models); - ret =3D 0; + if (!(*cpuModels =3D virQEMUCapsCPUDefsToModels(defs, NULL, NULL))) + return -1; =20 - cleanup: - virObjectUnref(models); - return ret; + return 0; } =20 =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list