From nobody Wed Oct 22 12:27:07 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=1759930342; cv=none; d=zohomail.com; s=zohoarc; b=DtVrHuV5GDtRvFhEKTOQ6LBXelb5qmmOL2Mbf51A52hJuUmCfLSlZ1PqYqvSfCZKe0JCRpP5sHVn64IdZrKTSVMlbcoDr2F9tTuJKNDFG+V0cjEFubG+6SoPIODXLgKKOo/0aouPe3SyAzqR4QcWE0Ad8vyw7cJSzCNs8+vPmg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759930342; 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=6m/S0hwc6uN2zV+o9NbqbtjWvwatojFslPatCfSfNRI=; b=RaT2oLbQLkm3oHtJb6DJE6RQweBlegZQpkGvll9WQN2uARSlO4okEcFsRRXvpTPl2Xj0r2tWYeXCT0KHEng3lj3x+7mD94S2JTgGvhx4mDXPXYRHuB1iVmhAUz6FA5MEDE9vv7VXVp00L/de7fUW6bdWMsmsvbQcFiSmGYoaSJs= 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 1759930342052614.5842974988749; Wed, 8 Oct 2025 06:32:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7607A41B79; Wed, 8 Oct 2025 09:32:21 -0400 (EDT) Received: from [172.19.199.17] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1F223449CE; Wed, 8 Oct 2025 09:18:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id BF00B441BD; Wed, 8 Oct 2025 08:55:47 -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 6407E4426B for ; Wed, 8 Oct 2025 08:54:39 -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-103-8YZNQ6gYOl-tmoylgFc_Pg-1; Wed, 08 Oct 2025 08:54:37 -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 170BB1800447 for ; Wed, 8 Oct 2025 12:54:37 +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 6240219560B8 for ; Wed, 8 Oct 2025 12:54:36 +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=1759928079; 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=6m/S0hwc6uN2zV+o9NbqbtjWvwatojFslPatCfSfNRI=; b=S5ofpeduIAbqDbG8m01U+soPaBufCZ2d0CmSKfybA7DTeYoWIeqzRmHDOn2Rg2lHhMxFIJ bGyDCvy/1lwC/K6BaYJL+LabR8GoPADTlr0xAVdVmzDl0GUXAXwLulnXaFh3h52vhfPFYG r1hiSP2NOaiXyfKqfQugqbP6EkRwysE= X-MC-Unique: 8YZNQ6gYOl-tmoylgFc_Pg-1 X-Mimecast-MFC-AGG-ID: 8YZNQ6gYOl-tmoylgFc_Pg_1759928077 To: devel@lists.libvirt.org Subject: [PATCH v2 27/29] conf: Introduce hyperv host-model mode Date: Wed, 8 Oct 2025 14:53:59 +0200 Message-ID: <8bbbcbc96ae42b46ea3e9db943165bb8f36435f9.1759927755.git.mprivozn@redhat.com> 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: ZfP9qj27284nUzbhnsk84nTTFI5CEv81bK4WLlfoK94_1759928077 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EKTEWWRVYZQZ4FY5XFAGNPKWU46KZD7A X-Message-ID-Hash: EKTEWWRVYZQZ4FY5XFAGNPKWU46KZD7A 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: 1759930344768154100 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 fcf3ad8d29..13c624fe5b 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2189,6 +2189,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 8c42f95af4..4737594487 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, @@ -17035,7 +17036,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 5e37ef7b0d..a63d922853 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 b9230a35b4..ace74fee08 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 3962a7dba2..2b988157fa 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 7a31848d6f..609d0677df 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 + +
+ + + + +