From nobody Mon Feb 9 06:02:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1636104949; cv=none; d=zohomail.com; s=zohoarc; b=GEWRdxAeR0HWM+5hofEm1kC2foKvdnpjDxWD26ZKGBQX9L0RHjJbdTUX3VwE+uVyTsgxkvVjGwdRgefNqPv+PQt+BG9qIxXhexVQHtbaclNAT9lgRtCrEcyKhW1Ze57azPslAPj7wH85iUu16nQGjm2xxBQ/kVQ1Pfc1U6gm+nk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636104949; 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=39ptgbDL+8Jcr+0eVO2nj4kd6g5SdGSN0AteBev9YQo=; b=BfAx409LGDKbG0+GDm38bZcjHjF+CG1XURCsqaaghw81QRE3ttvK8/iiBYxiF9rHU081dCYA8RiAtE3htsG7XdNVCSpqwibGxO1jKT80MkmF3HALopIcWEsnyWUTwyTrsf05/Il0q5U/I8cFwjU764C5iCYw2p82reRApNdRFCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636104949875324.5663567198393; Fri, 5 Nov 2021 02:35:49 -0700 (PDT) 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-331-fjilELnhM7WwpThTjA5k7A-1; Fri, 05 Nov 2021 05:35:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C5605B38D; Fri, 5 Nov 2021 09:35:32 +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 6FEB518A8F; Fri, 5 Nov 2021 09:35:32 +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 3E0564EA2A; Fri, 5 Nov 2021 09:35:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A59ZQLK026137 for ; Fri, 5 Nov 2021 05:35:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 799A2100239F; Fri, 5 Nov 2021 09:35:26 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 000481009AB7 for ; Fri, 5 Nov 2021 09:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636104948; 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=39ptgbDL+8Jcr+0eVO2nj4kd6g5SdGSN0AteBev9YQo=; b=aXGFZ+IImKEy6uyUtLbcXbY6vfA4hwQK9iee+OONnzQp1gim7mne3xJmkLqmV0V+GWkl9r 2zw542R1P3zKN1d+CmqJkW0kHbESQ6myPl+FARy5CgEJ2dgorI/uvaMy0p8vkZxQjtj2uu 9+1IaZJkGFztdGCzXVn/ZsiEXRkW3RE= X-MC-Unique: fjilELnhM7WwpThTjA5k7A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/4] conf: Introduce TCG domain features Date: Fri, 5 Nov 2021 10:35:19 +0100 Message-Id: <1fabe58c78b95cfb3178dfa3512a54115b75a59a.1636104680.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636104951580100001 Content-Type: text/plain; charset="utf-8" It may come handy to be able to tweak TCG options, in this specific case the size of translation block cache size (tb-size). Since we can expect more knobs to tweak let's put them under common element, like this: 128 Signed-off-by: Michal Privoznik Tested-by: Kashyap Chamarthy --- docs/formatdomain.rst | 11 +++ docs/schemas/domaincommon.rng | 15 +++- src/conf/domain_conf.c | 90 +++++++++++++++++++ src/conf/domain_conf.h | 7 ++ src/qemu/qemu_validate.c | 11 +++ .../x86_64-default-cpu-tcg-features.xml | 67 ++++++++++++++ ...default-cpu-tcg-features.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.= xml create mode 120000 tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-feature= s.x86_64-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index eb8c973cf1..1b7e92b3ba 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1864,6 +1864,9 @@ Hypervisors may allow certain CPU / machine features = to be toggled on/off. + + 128 + ... =20 @@ -2065,6 +2068,14 @@ are: ``fixed-na (fixed in hardware - no longer applicable)``. If t= he attribute is not defined, the hypervisor default will be used. :since:`= Since 6.3.0` (QEMU/KVM only) +``tcg`` + Various features to change the behavior of the TCG accelerator. + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + Feature Description Value = Since + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + tb-cache The size of translation block cache size an integer = :since:`7.10.0` + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 :anchor:`` =20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f01b7a6470..ce51e95895 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -6092,7 +6092,7 @@ @@ -6232,6 +6232,9 @@ + + + @@ -6520,6 +6523,16 @@ =20 + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index da0c64b460..496e43dc02 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -172,6 +172,7 @@ VIR_ENUM_IMPL(virDomainFeature, "cfpc", "sbbc", "ibs", + "tcg", ); =20 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, @@ -17679,6 +17680,30 @@ virDomainFeaturesCapabilitiesDefParse(virDomainDef= *def, } =20 =20 +static int +virDomainFeaturesTCGDefParse(virDomainDef *def, + xmlXPathContextPtr ctxt, + xmlNodePtr node) +{ + g_autofree virDomainFeatureTCG *tcg =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + + tcg =3D g_new0(virDomainFeatureTCG, 1); + ctxt->node =3D node; + + if (virDomainParseMemory("./tb-cache", "./tb-cache/@unit", + ctxt, &tcg->tb_cache, false, false) < 0) + return -1; + + if (tcg->tb_cache =3D=3D 0) + return 0; + + def->features[VIR_DOMAIN_FEATURE_TCG] =3D VIR_TRISTATE_SWITCH_ON; + def->tcg_features =3D g_steal_pointer(&tcg); + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17887,6 +17912,11 @@ virDomainFeaturesDefParse(virDomainDef *def, break; } =20 + case VIR_DOMAIN_FEATURE_TCG: + if (virDomainFeaturesTCGDefParse(def, ctxt, nodes[i]) < 0) + return -1; + break; + case VIR_DOMAIN_FEATURE_LAST: break; } @@ -21555,6 +21585,39 @@ virDomainRedirFilterDefCheckABIStability(virDomain= RedirFilterDef *src, } =20 =20 +static bool +virDomainFeatureTCGCheckABIStability(const virDomainDef *src, + const virDomainDef *dst) +{ + const int srcF =3D src->features[VIR_DOMAIN_FEATURE_TCG]; + const int dstF =3D dst->features[VIR_DOMAIN_FEATURE_TCG]; + + if (srcF !=3D dstF || + !!src->tcg_features !=3D !!dst->tcg_features) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("State of feature '%s' differs: " + "source: '%s', destination: '%s'"), + virDomainFeatureTypeToString(VIR_DOMAIN_FEATURE_TCG= ), + virTristateSwitchTypeToString(srcF), + virTristateSwitchTypeToString(dstF)); + return false; + } + + if (!src->tcg_features && !dst->tcg_features) + return true; + + if (src->tcg_features->tb_cache !=3D dst->tcg_features->tb_cache) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TCG tb-cache mismatch: source %llu, destination:= %llu"), + src->tcg_features->tb_cache, + dst->tcg_features->tb_cache); + return false; + } + + return true; +} + + static bool virDomainDefFeaturesCheckABIStability(virDomainDef *src, virDomainDef *dst) @@ -21705,6 +21768,11 @@ virDomainDefFeaturesCheckABIStability(virDomainDef= *src, case VIR_DOMAIN_FEATURE_MSRS: break; =20 + case VIR_DOMAIN_FEATURE_TCG: + if (!virDomainFeatureTCGCheckABIStability(src, dst)) + return false; + break; + case VIR_DOMAIN_FEATURE_LAST: break; } @@ -27691,6 +27759,24 @@ virDomainDefFormatBlkiotune(virBuffer *buf, } =20 =20 +static void +virDomainFeatureTCGFormat(virBuffer *buf, + const virDomainDef *def) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + if (!def->tcg_features || + def->features[VIR_DOMAIN_FEATURE_TCG] !=3D VIR_TRISTATE_SWITCH_ON) + return; + + virBufferAsprintf(&childBuf, + "%lld\n", + def->tcg_features->tb_cache); + + virXMLFormatElement(buf, "tcg", NULL, &childBuf); +} + + static int virDomainDefFormatFeatures(virBuffer *buf, virDomainDef *def) @@ -28011,6 +28097,10 @@ virDomainDefFormatFeatures(virBuffer *buf, virDomainIBSTypeToString(def->features[i])); break; =20 + case VIR_DOMAIN_FEATURE_TCG: + virDomainFeatureTCGFormat(&childBuf, def); + break; + case VIR_DOMAIN_FEATURE_LAST: break; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ab9a7d66f8..9c66e26ccf 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2054,6 +2054,7 @@ typedef enum { VIR_DOMAIN_FEATURE_CFPC, VIR_DOMAIN_FEATURE_SBBC, VIR_DOMAIN_FEATURE_IBS, + VIR_DOMAIN_FEATURE_TCG, =20 VIR_DOMAIN_FEATURE_LAST } virDomainFeature; @@ -2262,6 +2263,11 @@ typedef enum { =20 VIR_ENUM_DECL(virDomainIBS); =20 +typedef struct _virDomainFeatureTCG virDomainFeatureTCG; +struct _virDomainFeatureTCG { + unsigned long long tb_cache; /* Stored in KiB */ +}; + /* Operating system configuration data & machine / arch */ struct _virDomainOSEnv { char *name; @@ -2824,6 +2830,7 @@ struct _virDomainDef { unsigned long long hpt_maxpagesize; /* Stored in KiB */ char *hyperv_vendor_id; virTristateSwitch apic_eoi; + virDomainFeatureTCG *tcg_features; =20 bool tseg_specified; unsigned long long tseg_size; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 397eea5ede..bd33c9a800 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -294,6 +294,17 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, } break; =20 + case VIR_DOMAIN_FEATURE_TCG: + if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { + if (def->virtType !=3D VIR_DOMAIN_VIRT_QEMU) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TCG features are incompatible with d= omain type '%s'"), + virDomainVirtTypeToString(def->virtType= )); + return -1; + } + } + break; + case VIR_DOMAIN_FEATURE_SMM: case VIR_DOMAIN_FEATURE_KVM: case VIR_DOMAIN_FEATURE_XEN: diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml b/t= ests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml new file mode 100644 index 0000000000..e2058487b2 --- /dev/null +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml @@ -0,0 +1,67 @@ + + guest + 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 + 4194304 + 4194304 + 4 + + hvm + + + + + + + 102400 + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + +