From nobody Mon Feb 9 04:46:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573661162; cv=none; d=zoho.com; s=zohoarc; b=P+0V5ySzzrYDKkqadQ/DGao8xCWzJMi1TuCcYSPaBIvbuha8RCthIw/lwemftDuQ58IwH82y9SkeqFs/V4lSveyVWjFpo+15Y+5TBWKTWxHdDymkoqJb9s3oyG/OYmPWtB9jfASEqTE0uQN4faTr4LCCqiKI3byq71dfeGXULiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573661162; 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=Y/LgSpFsHpyuHgAb1T6qjKitRbLT4J/QmZsY0LJRzeQ=; b=mXbCYFnCKVSpOCjEsVIaRxFbuhA4dgFJHt11knPumVHJpH/ZTtbEvnN9Zc762XhnU8Y9eTPMvt8gXol5XuWsHr0w4dhrq/MaHT/bb9Emdslh+rZSUXZB/HLUfmoWkELUI5jt5kKDK/5pnfqxvXHi26/lYFiqIwdGHTzrEyZt8/0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1573661162120738.155348001021; Wed, 13 Nov 2019 08:06:02 -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-158-rnOn_3ICPEe7Z7c11fquMg-1; Wed, 13 Nov 2019 11:05:58 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E0EE107ACE4; Wed, 13 Nov 2019 16:05:50 +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 255DE106F957; Wed, 13 Nov 2019 16:05:50 +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 CEB1F4E56D; Wed, 13 Nov 2019 16:05:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADG5m5o019933 for ; Wed, 13 Nov 2019 11:05:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 84F164647A; Wed, 13 Nov 2019 16:05:48 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D9086365A for ; Wed, 13 Nov 2019 16:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573661161; 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=Y/LgSpFsHpyuHgAb1T6qjKitRbLT4J/QmZsY0LJRzeQ=; b=HjlixvBId0tF/0Z0S+dl/uwv/g1ASVSvf98t05Y4TlFNGFasmSd6t8kKGh5AQul5VvjWsY drsonqyOneTOd4u3WopEOEyVlSQeDn24xbCRdaaVdMaSnwY13IiDh0dYCuYujRgQ+57Cn8 MiSOXFbk0WVW2/9GBtxJzouifpE0cT4= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 17:05:25 +0100 Message-Id: <2e6590736d1c924f5cf10d7ac854e8cc944e2c2a.1573661034.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] domaincaps: Store domain capability features in an array 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.84 on 10.5.11.22 X-MC-Unique: rnOn_3ICPEe7Z7c11fquMg-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" Declare the capabilities as enum values and store them in an array. This makes adding new features more straightforward and simplifies the formatter which now doesn't require changing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_capabilities.c | 30 +++++++++++++++++++++++------- src/conf/domain_capabilities.h | 13 ++++++++++--- src/qemu/qemu_capabilities.c | 6 +++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 39acad00f1..1993a22cc5 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -33,6 +33,15 @@ VIR_ENUM_IMPL(virDomainCapsCPUUsable, "unknown", "yes", "no", ); + +VIR_ENUM_DECL(virDomainCapsFeature); +VIR_ENUM_IMPL(virDomainCapsFeature, + VIR_DOMAIN_CAPS_FEATURE_LAST, + "iothreads", + "vmcoreinfo", + "genid", +); + static virClassPtr virDomainCapsClass; static virClassPtr virDomainCapsCPUModelsClass; @@ -324,9 +333,10 @@ virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum) void virDomainCapsFeaturesInitUnsupported(virDomainCapsPtr caps) { - caps->iothreads =3D VIR_TRISTATE_BOOL_NO; - caps->vmcoreinfo =3D VIR_TRISTATE_BOOL_NO; - caps->genid =3D VIR_TRISTATE_BOOL_NO; + size_t i; + + for (i =3D 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) + caps->features[i] =3D VIR_TRISTATE_BOOL_NO; } @@ -619,11 +629,16 @@ virDomainCapsFormatFeatures(const virDomainCaps *caps, virBufferPtr buf) { g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; virDomainCapsFeatureGICFormat(&childBuf, &caps->gic); - qemuDomainCapsFeatureFormatSimple(&childBuf, "iothreads", caps->iothre= ads); - qemuDomainCapsFeatureFormatSimple(&childBuf, "vmcoreinfo", caps->vmcor= einfo); - qemuDomainCapsFeatureFormatSimple(&childBuf, "genid", caps->genid); + + for (i =3D 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) { + qemuDomainCapsFeatureFormatSimple(&childBuf, + virDomainCapsFeatureTypeToString= (i), + caps->features[i]); + } + virDomainCapsFeatureSEVFormat(&childBuf, caps->sev); virXMLFormatElement(buf, "features", NULL, &childBuf); @@ -649,7 +664,8 @@ virDomainCapsFormat(const virDomainCaps *caps) if (caps->maxvcpus) virBufferAsprintf(&buf, "\n", caps->maxvcpus); - qemuDomainCapsFeatureFormatSimple(&buf, "iothreads", caps->iothreads); + qemuDomainCapsFeatureFormatSimple(&buf, "iothreads", + caps->features[VIR_DOMAIN_CAPS_FEATU= RE_IOTHREADS]); virDomainCapsOSFormat(&buf, &caps->os); virDomainCapsCPUFormat(&buf, &caps->cpu); diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 9baaea8f60..83a9713a8b 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -156,6 +156,14 @@ struct _virSEVCapability { unsigned int reduced_phys_bits; }; +typedef enum { + VIR_DOMAIN_CAPS_FEATURE_IOTHREADS =3D 0, + VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO, + VIR_DOMAIN_CAPS_FEATURE_GENID, + + VIR_DOMAIN_CAPS_FEATURE_LAST +} virDomainCapsFeature; + struct _virDomainCaps { virObjectLockable parent; @@ -166,7 +174,6 @@ struct _virDomainCaps { /* Some machine specific info */ int maxvcpus; - virTristateBool iothreads; /* Whether I/O threads are supported or no= t. */ virDomainCapsOS os; virDomainCapsCPU cpu; @@ -178,10 +185,10 @@ struct _virDomainCaps { /* add new domain devices here */ virDomainCapsFeatureGIC gic; - virTristateBool vmcoreinfo; - virTristateBool genid; virSEVCapabilityPtr sev; /* add new domain features here */ + + virTristateBool features[VIR_DOMAIN_CAPS_FEATURE_LAST]; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainCaps, virObjectUnref); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 23a358bf91..a1fbf0da34 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5285,7 +5285,7 @@ static void virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps, virDomainCapsPtr domCaps) { - domCaps->iothreads =3D virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS] =3D virTristateBo= olFromBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)); } @@ -5584,10 +5584,10 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, domCaps->maxvcpus =3D MIN(domCaps->maxvcpus, hostmaxvcpus); } - domCaps->vmcoreinfo =3D virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO] =3D virTristateB= oolFromBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)); - domCaps->genid =3D virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_GENID] =3D virTristateBoolFr= omBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)); if (virQEMUCapsFillDomainOSCaps(os, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list