From nobody Tue Oct 28 17:51:30 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=1759758517; cv=none; d=zohomail.com; s=zohoarc; b=bIzAGTvKKAdSBpcOAjmTZNDb5asjuDRmN56ETqfCieTJPY0kISYj1Es0femH/ds8F0Frkto2OYtWkIS5727q3YFrsMPKo5AypBklK5mvEyJr9Gd0Mg5vaJitcxc5CvUy9MXow6pqZ3Z577f5VUMKEJ1JDlXLunfBIlSiia6hazI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759758517; 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=99k7r9KTQDqDAXOuFyd5dlrMmHW/zEUKMSuU182XC+A=; b=kPxIR9ouWaibXxumDAjUojIo4+Cr0LebLvIBKNvaMWOl1dQDz5aESUycZMN9qQUPbbgu14OxKEQqYFaKUvOALq2387JMaJtjs+1Aqh9NS2QilGwkHtLt++UPDQXOxiT41DXWEK8NLoqCrLyaSL0pdJ0k22bbvI2QJtNOf5a8mmM= 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 1759758517283695.7137808454706; Mon, 6 Oct 2025 06:48:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5054A418D0; Mon, 6 Oct 2025 09:48:31 -0400 (EDT) Received: from [172.19.199.17] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 64E26442B2; Mon, 6 Oct 2025 09:25:38 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id F0BE241C8A; Mon, 6 Oct 2025 09:15:22 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 852CD41C80 for ; Mon, 6 Oct 2025 09:15:21 -0400 (EDT) Received: from mx-prod-mc-06.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-222-UUHPc1TLNgCoaYfvVnqPnA-1; Mon, 06 Oct 2025 09:15:18 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B32DC18002BC for ; Mon, 6 Oct 2025 13:15:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0949130002CC for ; Mon, 6 Oct 2025 13:15:16 +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=1759756521; 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=99k7r9KTQDqDAXOuFyd5dlrMmHW/zEUKMSuU182XC+A=; b=AuzNCLR9rp3O2Tz1bb5q4qGFiy2mSI97o/my1NMO8uovyd6kApaRckyu/cOzZgjUkXlV53 wUBWwLMOBQxtDvKU85QXwZLQdwsDfNx6U4Gyo2r0SsIPgpdZVnRHIBgnB9hLHC3FZPzwpy pcLj/2xbNxcNl64V3awbdnyDVhkdohM= X-MC-Unique: UUHPc1TLNgCoaYfvVnqPnA-1 X-Mimecast-MFC-AGG-ID: UUHPc1TLNgCoaYfvVnqPnA_1759756517 To: devel@lists.libvirt.org Subject: [PATCH 18/20] conf: Introduce hyperv host-model mode Date: Mon, 6 Oct 2025 15:14:49 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: H2G4Ex3XQVm4SJPz6KwSHL1fg72B7dbeneb-oFeMzQA_1759756517 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HAEHHHSHZFFYD5F5KO3MH2FNVKU5F2Y4 X-Message-ID-Hash: HAEHHHSHZFFYD5F5KO3MH2FNVKU5F2Y4 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: 1759758519590116601 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik So far we have two modes for hyperv features: 1) custom, where users have to enable features explicitly, and 2) passthrough, where hypervisor enables features automagically. Problem with 'custom' mode is that some features are not plain on/off switches but expect int/string value. Until very recently, these were not reported in domcaps. And even if they were it's a bit cumbersome. Problem with 'passthrough' mode is that users don't get to see the expanded list of enlightenments enabled. Therefore, mimic what we're already doing with CPUs: have 'host-model' which gets expanded at domain startup and is fixed throughout domain's run. Signed-off-by: Michal Privoznik --- docs/formatdomain.rst | 6 ++++ src/conf/domain_conf.c | 4 ++- src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 3 ++ src/libxl/libxl_conf.c | 1 + src/qemu/qemu_command.c | 1 + .../hyperv-host-model.x86_64-latest.args | 32 ++++++++++++++++++ .../hyperv-host-model.x86_64-latest.xml | 33 +++++++++++++++++++ tests/qemuxmlconfdata/hyperv-host-model.xml | 27 +++++++++++++++ tests/qemuxmlconftest.c | 1 + 10 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.a= rgs create mode 100644 tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.x= ml create mode 100644 tests/qemuxmlconfdata/hyperv-host-model.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 473233c5d1..269ad8794f 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2191,6 +2191,12 @@ are: virtual CPU may or may not contain features which may block migration even to an identical host. =20 + ``host-model`` + Similar to the ``passthrough`` mode, except libvirt detects which + enlightenments are supported by hypervisor and expands them on domain + startup into the live XML. In a sense, this is similar to ``host-mod= el`` + CPU mode (See `CPU model and topology`_). :since:`Since 11.9.0` + The ``mode`` attribute can be omitted and will default to ``custom``. =20 ``pvspinlock`` diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1df781545a..4ac921692a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -145,6 +145,7 @@ VIR_ENUM_IMPL(virDomainHyperVMode, "none", "custom", "passthrough", + "host-model", ); =20 VIR_ENUM_IMPL(virDomainBoot, @@ -17036,7 +17037,8 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def, =20 def->features[VIR_DOMAIN_FEATURE_HYPERV] =3D mode; =20 - if (mode =3D=3D VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH) + if (mode =3D=3D VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH || + mode =3D=3D VIR_DOMAIN_HYPERV_MODE_HOST_MODEL) return 0; =20 node =3D xmlFirstElementChild(node); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d156f11de3..39733da0f8 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -164,6 +164,7 @@ typedef enum { VIR_DOMAIN_HYPERV_MODE_NONE =3D 0, VIR_DOMAIN_HYPERV_MODE_CUSTOM, VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH, + VIR_DOMAIN_HYPERV_MODE_HOST_MODEL, =20 VIR_DOMAIN_HYPERV_MODE_LAST } virDomainHyperVMode; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 0fe9e711eb..746cbefee0 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -8030,6 +8030,9 @@ passthrough + + host-model + diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 83ca803a93..f8493fd641 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -599,6 +599,7 @@ libxlMakeDomBuildInfo(virDomainDef *def, case VIR_DOMAIN_HYPERV_MODE_PASSTHROUGH: libxl_bitmap_set_any(&b_info->u.hvm.viridian_enable); break; + 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_command.c b/src/qemu/qemu_command.c index 7bb56e0b13..37427f51bc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6461,6 +6461,7 @@ 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: diff --git a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args b/t= ests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args new file mode 100644 index 0000000000..2ed72fcd1b --- /dev/null +++ b/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.args @@ -0,0 +1,32 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-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 tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml b/te= sts/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml new file mode 100644 index 0000000000..453a43b3c9 --- /dev/null +++ b/tests/qemuxmlconfdata/hyperv-host-model.x86_64-latest.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +