From nobody Mon Feb 9 18:19:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1638435279; cv=none; d=zohomail.com; s=zohoarc; b=R51P66UmmhKnE3MQd9BdVztoembx0tZT3PHedk/+9VTlupL4WVT2VVCm8GiAeEpyJYnTKmMowuAXIM2dP0G3GPNe2RsL78LV6mLP+e7nAC0HlRQOdoGh51k5MKBtEIvTl9tb6PyO6U2htL0D5zfvzy0Ugs7iqibupeB9iBXL4Tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638435279; 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=wtyfhjUMYIQORYIYyFNU+BWTYJ0xDEZp6RvR8hsy01w=; b=KrXRJMBKKSyXofszC1FU4EYbj3EZEsexeFT08VGslC/rUyeRSDrglLOqgXLChhuJf+vwc9sjlEfj7do1Puygiz7UtTBgpI42QZBPoNZ62ry2ER++mEwFUxPWyXxTqVn1meQsurl4e8+y5R+062qUBEBzDtIRLmGBXAKACV/95uU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1638435279441755.2113671481842; Thu, 2 Dec 2021 00:54:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-SSAyIBgcMo-CBtNZ1ZNkmg-1; Thu, 02 Dec 2021 03:54:36 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24EEB1023F4F; Thu, 2 Dec 2021 08:54:31 +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 E72A85FC22; Thu, 2 Dec 2021 08:54:30 +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 B23FA4BB7C; Thu, 2 Dec 2021 08:54:29 +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 1B28sR9e029533 for ; Thu, 2 Dec 2021 03:54:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 94503100AE22; Thu, 2 Dec 2021 08:54:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3CB9100EBAD; Thu, 2 Dec 2021 08:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638435278; 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=wtyfhjUMYIQORYIYyFNU+BWTYJ0xDEZp6RvR8hsy01w=; b=iSE1hjo3xYH7YN25ylvE7MRE5dd6hPF4HSG+z84RWNQZrdztHnjntwU8t+U3MJhupkBEsM Qu9/2chslnmBPhdFTcVApBsDrE2wygCg22HCS+PWmxXR7vCCRcmT88RFB4VGtxwkPxNGvq H21ZjqjXvP8EKPLg9pIkZQyQ9x/qEjw= X-MC-Unique: SSAyIBgcMo-CBtNZ1ZNkmg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 1/4] conf: Introduce TCG domain features Date: Thu, 2 Dec 2021 09:53:33 +0100 Message-Id: <2947ebaa561b595a05c0fb7e46a0a33525335465.1638434885.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.16 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: 1638435281408100001 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 | 58 ++++++++++++++++++- src/conf/domain_conf.h | 7 +++ src/qemu/qemu_validate.c | 1 + .../x86_64-default-cpu-tcg-features.xml | 56 ++++++++++++++++++ ...default-cpu-tcg-features.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 147 insertions(+), 3 deletions(-) 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..041dfc699d 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:`8.0.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 bdcc3dc2c1..7306fdc179 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, @@ -3713,6 +3714,7 @@ void virDomainDefFree(virDomainDef *def) g_free(def->description); g_free(def->title); g_free(def->hyperv_vendor_id); + g_free(def->tcg_features); =20 virBlkioDeviceArrayClear(def->blkio.devices, def->blkio.ndevices); @@ -17652,6 +17654,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) @@ -17860,6 +17886,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; } @@ -21664,8 +21695,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef = *src, break; =20 case VIR_DOMAIN_FEATURE_MSRS: - break; - + case VIR_DOMAIN_FEATURE_TCG: case VIR_DOMAIN_FEATURE_LAST: break; } @@ -27652,6 +27682,26 @@ 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; + + if (def->tcg_features->tb_cache > 0) { + virBufferAsprintf(&childBuf, + "%lld\n", + def->tcg_features->tb_cache); + } + + virXMLFormatElement(buf, "tcg", NULL, &childBuf); +} + + static int virDomainDefFormatFeatures(virBuffer *buf, virDomainDef *def) @@ -27972,6 +28022,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 c0c07ea6ba..b410922f68 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 1de6e05101..a7c89f27cf 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -294,6 +294,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, } break; =20 + case VIR_DOMAIN_FEATURE_TCG: 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..808e31752c --- /dev/null +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml @@ -0,0 +1,56 @@ + + guest + 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 + 4194304 + 4194304 + 4 + + hvm + + + + + + + 102400 + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + +