From nobody Sat Nov 23 15:01:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724676244458598.5534924436831; Mon, 26 Aug 2024 05:44:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 68905C7E; Mon, 26 Aug 2024 08:44:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 153BAD77; Mon, 26 Aug 2024 08:43:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 77B69D80; Thu, 22 Aug 2024 12:00:08 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id D533FD63 for ; Thu, 22 Aug 2024 12:00:07 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-4UtJqYohNAiXBE0o2Qo44A-1; Thu, 22 Aug 2024 12:00:05 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 690BD1954B01 for ; Thu, 22 Aug 2024 16:00:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.208.7]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D0F661955DD6; Thu, 22 Aug 2024 16:00:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724342406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CddD9t2tKooYQPvtlPFvwHBQy0NIt7KexNF8Kt4H/MM=; b=B0MUaN1jbFkbV0JnHlp6yTbyxLR4NUi57oMzCUomHEuCUd/8oJnYcua3IyaGKwmzD2BPLd a1vAtCq1CftNilg9hkVUSQc/dnWPpoB/2nl0LwCg19tiv+C36CeQdLLKsTqKjQUJY0UqER jZJFkzTysnnG0Yfsz4mGskcYJKLaSzs= X-MC-Unique: 4UtJqYohNAiXBE0o2Qo44A-1 From: Anthony Harivel To: devel@lists.libvirt.org Subject: [PATCH v2 1/1] qemu: Add support for RAPL MSRs feature Date: Thu, 22 Aug 2024 17:59:47 +0200 Message-ID: <20240822155955.875207-2-aharivel@redhat.com> In-Reply-To: <20240822155955.875207-1-aharivel@redhat.com> References: <20240822155955.875207-1-aharivel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-MailFrom: aharivel@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: AXCRMY2QKBX7RVLMJATU7QY5D2JXECGC X-Message-ID-Hash: AXCRMY2QKBX7RVLMJATU7QY5D2JXECGC X-Mailman-Approved-At: Mon, 26 Aug 2024 12:43:22 -0400 CC: pkrempa@redhat.com, Anthony Harivel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724676246117116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Add the support in libvirt to activate the RAPL feature in QEMU. This feature is activated with -accel kvm,rapl=3Dtrue,path=3D/path/sock.sock in QEMU. The feature is activated in libvirt with the following XML configuration: [...] [...] See: https://gitlab.com/qemu-project/qemu/-/commit/0418f90809aea5b375c859e7= 44c8e8610e9be446 Signed-off-by: Anthony Harivel --- docs/formatdomain.rst | 2 ++ src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/conf/schemas/domaincommon.rng | 10 ++++++++++ src/qemu/qemu_command.c | 11 +++++++++++ tests/qemuxmlconfdata/kvm-features-off.xml | 1 + .../kvm-features.x86_64-latest.args | 2 +- tests/qemuxmlconfdata/kvm-features.xml | 1 + 8 files changed, 46 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index e1e219bcb5c5..5c66e41e940f 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1996,6 +1996,7 @@ Hypervisors may allow certain CPU / machine features = to be toggled on/off. + @@ -2111,6 +2112,7 @@ are: poll-control Decrease IO completion latency by introducing a grace pe= riod of busy waiting on, off = :since:`6.10.0 (QEMU 4.2)` pv-ipi Paravirtualized send IPIs = on, off = :since:`7.10.0 (QEMU 3.1)` dirty-ring Enable dirty ring feature = on, off; size - must be power of 2, range [1024,65536]= :since:`8.0.0 (QEMU 6.1)` + rapl Enable rapl feature = on, off; socket - rapl helper socket = :since:`10.8.0 (QEMU 9.1)` =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D= =3D=3D=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 ``xen`` diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d950921667a2..32a3d09fe175 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -220,6 +220,7 @@ VIR_ENUM_IMPL(virDomainKVM, "poll-control", "pv-ipi", "dirty-ring", + "rapl", ); =20 VIR_ENUM_IMPL(virDomainXen, @@ -16693,6 +16694,11 @@ virDomainFeaturesKVMDefParse(virDomainDef *def, return -1; } } + + /* rapl feature should parse socket property */ + if (feature =3D=3D VIR_DOMAIN_KVM_RAPL && value =3D=3D VIR_TRISTAT= E_SWITCH_ON) { + kvm->rapl_helper_socket =3D virXMLPropString(feat, "socket"); + } } =20 def->features[VIR_DOMAIN_FEATURE_KVM] =3D VIR_TRISTATE_SWITCH_ON; @@ -21108,6 +21114,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef = *src, case VIR_DOMAIN_KVM_POLLCONTROL: case VIR_DOMAIN_KVM_PVIPI: case VIR_DOMAIN_KVM_DIRTY_RING: + case VIR_DOMAIN_KVM_RAPL: if (src->kvm_features->features[i] !=3D dst->kvm_features-= >features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of KVM feature '%1$s' differs:= source: '%2$s', destination: '%3$s'"), @@ -27840,6 +27847,17 @@ virDomainDefFormatFeatures(virBuffer *buf, } break; =20 + case VIR_DOMAIN_KVM_RAPL: + if (def->kvm_features->features[j] !=3D VIR_TRISTATE_S= WITCH_ABSENT) { + virBufferAsprintf(&childBuf, "<%s state=3D'%s'", + virDomainKVMTypeToString(j), + virTristateSwitchTypeToString(de= f->kvm_features->features[j])); + + virBufferEscapeString(&childBuf, " socket=3D'%s'",= def->kvm_features->rapl_helper_socket); + virBufferAddLit(&childBuf, "/>\n"); + } + break; + case VIR_DOMAIN_KVM_LAST: break; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index eae621f900b9..37295f1cfddb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2213,6 +2213,7 @@ typedef enum { VIR_DOMAIN_KVM_POLLCONTROL, VIR_DOMAIN_KVM_PVIPI, VIR_DOMAIN_KVM_DIRTY_RING, + VIR_DOMAIN_KVM_RAPL, =20 VIR_DOMAIN_KVM_LAST } virDomainKVM; @@ -2400,6 +2401,7 @@ struct _virDomainFeatureKVM { int features[VIR_DOMAIN_KVM_LAST]; =20 unsigned int dirty_ring_size; /* size of dirty ring for each vCPU, no = units */ + char *rapl_helper_socket; /* rapl helper socket */ }; =20 typedef struct _virDomainFeatureTCG virDomainFeatureTCG; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 05ba69792470..20d0ce556ecf 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -8016,6 +8016,16 @@ + + + + + + + + + + diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 28914c9c346a..b1b0bb9c63a6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6562,6 +6562,9 @@ qemuBuildCpuCommandLine(virCommand *cmd, case VIR_DOMAIN_KVM_DIRTY_RING: break; =20 + case VIR_DOMAIN_KVM_RAPL: + break; + case VIR_DOMAIN_KVM_LAST: break; } @@ -7176,6 +7179,14 @@ qemuBuildAccelCommandLine(virCommand *cmd, def->kvm_features->features[VIR_DOMAIN_KVM_DIRTY_RING] =3D=3D = VIR_TRISTATE_SWITCH_ON) { virBufferAsprintf(&buf, ",dirty-ring-size=3D%d", def->kvm_feat= ures->dirty_ring_size); } + if (def->features[VIR_DOMAIN_FEATURE_KVM] =3D=3D VIR_TRISTATE_SWIT= CH_ON && + def->kvm_features->features[VIR_DOMAIN_KVM_RAPL] =3D=3D VIR_TR= ISTATE_SWITCH_ON) { + virBufferAddLit(&buf, ",rapl=3Dtrue"); + + if (def->kvm_features->rapl_helper_socket !=3D NULL) { + virBufferAsprintf(&buf, ",rapl-helper-socket=3D%s", def->k= vm_features->rapl_helper_socket); + } + } break; =20 case VIR_DOMAIN_VIRT_HVF: diff --git a/tests/qemuxmlconfdata/kvm-features-off.xml b/tests/qemuxmlconf= data/kvm-features-off.xml index 3cd4ff18f283..3e8dbea4b177 100644 --- a/tests/qemuxmlconfdata/kvm-features-off.xml +++ b/tests/qemuxmlconfdata/kvm-features-off.xml @@ -16,6 +16,7 @@ + diff --git a/tests/qemuxmlconfdata/kvm-features.x86_64-latest.args b/tests/= qemuxmlconfdata/kvm-features.x86_64-latest.args index 955db67eb4b7..2dd613ab338d 100644 --- a/tests/qemuxmlconfdata/kvm-features.x86_64-latest.args +++ b/tests/qemuxmlconfdata/kvm-features.x86_64-latest.args @@ -11,7 +11,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -S \ -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ -machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Don \ --accel kvm,dirty-ring-size=3D4096 \ +-accel kvm,dirty-ring-size=3D4096,rapl=3Dtrue,rapl-helper-socket=3D/run/qe= mu-vmsr-helper.sock \ -cpu host,migratable=3Doff,kvm=3Doff,kvm-hint-dedicated=3Don,kvm-poll-cont= rol=3Don \ -m size=3D219136k \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ diff --git a/tests/qemuxmlconfdata/kvm-features.xml b/tests/qemuxmlconfdata= /kvm-features.xml index 78091064b109..ee601e06de75 100644 --- a/tests/qemuxmlconfdata/kvm-features.xml +++ b/tests/qemuxmlconfdata/kvm-features.xml @@ -16,6 +16,7 @@ + --=20 2.46.0