From nobody Wed Oct 22 12:28:45 2025 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1759930777; cv=none; d=zohomail.com; s=zohoarc; b=K6AqzDOuC1jYQja5UE6YTOGs2p6AOwcN99heqFLGQGV8EZ+ays3uEJRQgzxIsvHKZPyANbb+awrpw9CS51PNzX/wfmCiWGkALDO6vhanMYAFK8AhzazA4eCDtA6U1E3mTMp6xmwnxZsWm8aC0Zd3sN9lnePGLeLunaE6LuSYBHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759930777; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=6vzNuerX2anD6xqcT44CsU/3meedRjho1wjgrNUhBdM=; b=jmiefpCSbKEuogylmwCrzbjtXXLOWCB2zA/dFApIpPF5qgKzYkfK1FIEEepiSse9iBZ18akxvLEUn6KHiVvz5vSDfdkbbI2YHeCBrJ3MPIlc9JRZpnEZ0cO3Ypo/2VP4igzusPGY2TBYN0SjUxSsCYE04v416ikVRDiW9+g6v4k= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1759930777608993.3003825950155; Wed, 8 Oct 2025 06:39:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 001EC3F8ED; Wed, 8 Oct 2025 09:39:36 -0400 (EDT) Received: from [172.19.199.17] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 8F66544C09; Wed, 8 Oct 2025 09:18:50 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 540C14418C; Wed, 8 Oct 2025 08:55:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5ECDE44350 for ; Wed, 8 Oct 2025 08:54:40 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-xvvFZ4cpO2eEf_lJ2o2ugQ-1; Wed, 08 Oct 2025 08:54:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3518D180047F for ; Wed, 8 Oct 2025 12:54:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8013219560A2 for ; Wed, 8 Oct 2025 12:54:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759928080; h=from:from: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; bh=6vzNuerX2anD6xqcT44CsU/3meedRjho1wjgrNUhBdM=; b=T2gajU9nEI5vF8NgnQJx2Z/2gKBRsMurKSj1I0UMt6UVBiEzw0vqrNucbZHgHIjUjudPzu pk/sX1f6ESXq9UcBrT8ELtqqAIvy/Onm8cSZTAC421Vue6i6VBr20RgR8llZb6I4l0Bau/ NaXggiwuIc096G0mUQsGSx85WC29BBs= X-MC-Unique: xvvFZ4cpO2eEf_lJ2o2ugQ-1 X-Mimecast-MFC-AGG-ID: xvvFZ4cpO2eEf_lJ2o2ugQ_1759928078 To: devel@lists.libvirt.org Subject: [PATCH v2 28/29] qemu_process: Populate hyperv features for host-model Date: Wed, 8 Oct 2025 14:54:00 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: x9A-V1UOuX8FpGHfl_9WjzJ0kBCoxH_a0kxALhqFd60_1759928078 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FZPIMPFHKITEHVHRGGPZUR7FWOTK3QUY X-Message-ID-Hash: FZPIMPFHKITEHVHRGGPZUR7FWOTK3QUY X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1759930779765154101 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Pretty straightforward. The only "weird" thing here is that 'hv-time' enlightenment is exposed as a under element. Since it's required by 'hv-stimer' and 'hv-stimer-direct' it needs to be enabled too. Resolves: https://issues.redhat.com/browse/RHEL-114003 Signed-off-by: Michal Privoznik --- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_process.c | 72 +++++++++++++++++++ .../hyperv-host-model.x86_64-latest.args | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 609d0677df..fcf5fc1935 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6461,13 +6461,13 @@ qemuBuildCpuHypervCommandLine(virBuffer *buf, =20 switch ((virDomainHyperVMode) def->features[VIR_DOMAIN_FEATURE_HYPERV]= ) { case VIR_DOMAIN_HYPERV_MODE_CUSTOM: - case VIR_DOMAIN_HYPERV_MODE_HOST_MODEL: break; =20 case VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH: virBufferAddLit(buf, ",hv-passthrough=3Don"); break; =20 + case VIR_DOMAIN_HYPERV_MODE_HOST_MODEL: case VIR_DOMAIN_HYPERV_MODE_NONE: case VIR_DOMAIN_HYPERV_MODE_LAST: default: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d42e3f612b..9926998f85 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6835,6 +6835,75 @@ qemuProcessPrepareChardevSource(virDomainDef *def, } =20 =20 +static void +qemuProcessMaybeAddHypervTimer(virDomainDef *def) +{ + g_autofree virDomainTimerDef *timer =3D NULL; + + if (virDomainDefHasTimer(def, VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK)) + return; + + timer =3D g_new0(virDomainTimerDef, 1); + timer->name =3D VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK; + timer->present =3D VIR_TRISTATE_BOOL_YES; + + VIR_APPEND_ELEMENT(def->clock.timers, def->clock.ntimers, timer); +} + + +static int +qemuProcessEnableDomainFeatures(virDomainObj *vm) +{ + virDomainCapsFeatureHyperv *hv =3D NULL; + qemuDomainObjPrivate *priv =3D vm->privateData; + size_t i; + + if (vm->def->features[VIR_DOMAIN_FEATURE_HYPERV] !=3D VIR_DOMAIN_HYPER= V_MODE_HOST_MODEL) + return 0; + + hv =3D virQEMUCapsGetHypervCapabilities(priv->qemuCaps); + if (!hv || hv->supported !=3D VIR_TRISTATE_BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host-model hyperv mode unsupported, no hyperv ca= pabilities found")); + return -1; + } + + for (i =3D 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { + if (!VIR_DOMAIN_CAPS_ENUM_IS_SET(hv->features, i)) + continue; + + vm->def->hyperv.features[i] =3D VIR_TRISTATE_SWITCH_ON; + + if (i =3D=3D VIR_DOMAIN_HYPERV_SPINLOCKS) { + if (hv->spinlocks !=3D 0) { + vm->def->hyperv.spinlocks =3D hv->spinlocks; + } else { + vm->def->hyperv.features[i] =3D VIR_TRISTATE_SWITCH_ABSENT; + } + } else if (i =3D=3D VIR_DOMAIN_HYPERV_STIMER) { + vm->def->hyperv.stimer_direct =3D hv->stimer_direct; + /* Both hv-stimer and hv-stimer-direct require hv-time which is + * expose as a timer. Enable it. */ + qemuProcessMaybeAddHypervTimer(vm->def); + } else if (i =3D=3D VIR_DOMAIN_HYPERV_TLBFLUSH) { + vm->def->hyperv.tlbflush_direct =3D hv->tlbflush_direct; + vm->def->hyperv.tlbflush_extended =3D hv->tlbflush_extended; + } else if (i =3D=3D VIR_DOMAIN_HYPERV_VENDOR_ID) { + if (hv->vendor_id) { + vm->def->hyperv.vendor_id =3D g_strdup(hv->vendor_id); + } else { + vm->def->hyperv.features[i] =3D VIR_TRISTATE_SWITCH_ABSENT; + } + } + } + + vm->def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D VIR_DOMAIN_HYPERV_MOD= E_CUSTOM; + + return 0; +} + + + /** * qemuProcessPrepareDomain: * @driver: qemu driver @@ -6948,6 +7017,9 @@ qemuProcessPrepareDomain(virQEMUDriver *driver, VIR_DEBUG("Aligning guest memory"); if (qemuDomainAlignMemorySizes(vm->def) < 0) return -1; + + if (qemuProcessEnableDomainFeatures(vm) < 0) + return -1; } =20 for (i =3D 0; i < vm->def->nchannels; i++) { diff --git a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args b/t= ests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args index 2ed72fcd1b..58502ff51e 100644 --- a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args +++ b/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args @@ -12,7 +12,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -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 tcg \ --cpu qemu64 \ +-cpu 'qemu64,hv-time=3Don,hv-relaxed=3Don,hv-vapic=3Don,hv-spinlocks=3D0xf= ff,hv-vpindex=3Don,hv-runtime=3Don,hv-synic=3Don,hv-stimer=3Don,hv-stimer-d= irect=3Don,hv-reset=3Don,hv-vendor-id=3DLinux KVM Hv,hv-frequencies=3Don,hv= -reenlightenment=3Don,hv-tlbflush=3Don,hv-tlbflush-direct=3Don,hv-tlbflush-= ext=3Don,hv-ipi=3Don,hv-avic=3Don,hv-emsr-bitmap=3Don,hv-xmm-input=3Don' \ -m size=3D219136k \ -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ -overcommit mem-lock=3Doff \ --=20 2.49.1