From nobody Wed Nov 27 08:35:16 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=pass; 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=none dis=none) header.from=szczek.dev ARC-Seal: i=1; a=rsa-sha256; t=1724056953; cv=none; d=zohomail.com; s=zohoarc; b=cjaAPl6rw4EtEi0insHf9ZapTQkKK8PEkYXtzHfrrdZhpZPuQM2TF36hAaaYqWuQ1BJvBds+HYxo+UxHXXZFZmbaBdpNSeclVHhqqyW+s6WjgxUEOaZn6uoU56Fi5bpGsU6cZj+SKcjAtdNwTHEtig8/l/fN12ETYZazibBs+9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724056953; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=60mBepQGVjqTSllaogArg7QICBWbrwOHwx63G7y3fjc=; b=JVS/buTydlzimpOfKj1sX4wslfIiaB4FjPZkdR3WGwekvIClOMkT6q3jKZ3HDy8f9lz4iEwXiNo6gE1RMGezczvj29p40LrSiVmVv4pgq4AbVbo4Ud5p9pRjT+d/DPQgzYUI28moYVtdvVnhTXMo/GeCSN5AXmVL6Kr6+o7ZlFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724056953033964.4873911117023; Mon, 19 Aug 2024 01:42:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D4D5615C2; Mon, 19 Aug 2024 04:42:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 143331592; Mon, 19 Aug 2024 04:38:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 67EB01400; Sun, 18 Aug 2024 21:19:25 -0400 (EDT) Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) (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 B44DA1300 for ; Sun, 18 Aug 2024 21:19:24 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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=szczek.dev; s=protonmail; t=1724030363; x=1724289563; bh=60mBepQGVjqTSllaogArg7QICBWbrwOHwx63G7y3fjc=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=v0ulseMPZTkJ6WcGOBSQJKVyGa3udk+lYiDhk1ChFAiazmWNGaXdg9ZrgEa9xm3fI Tf/fGAQYVEqOFQU8rHqEZ22lWyg8iS7Qfi0D5jQwsIlucypofczvWiGxZK2c7sxeWz CGErOEVIQxCKl3/TNJQ5DL83oyhZTbYkt0Yt0HKQCDN3lW4dN1Jyujp8PUUisfkZnS Z9GEmyppOVK/vJLuOHnm7dwm6xzpD1WoAQF8kdKD464QUW0VJxKHI3LqYzumNsMAg6 nS1535rW1wKuVBlD/tfXidnNmub6qYewrigJFmkKAXsG5UERSZTPAtAVO3nTsf2kkx gXSrzWWXUKPag== Date: Mon, 19 Aug 2024 01:19:21 +0000 To: "devel@lists.libvirt.org" From: =?utf-8?Q?Kamil_Szcz=C4=99k?= Subject: [PATCH v3 4/6] qemu: Introduce the 'ps2' feature Message-ID: <_4RZFGOAQAnvZunFdwun6l1uTtRfCTQdTvczKCpqNAVYVYvouKx07Y0lSnFMoa2W2qsipn9yuO42AL8slbNJO77TVdcDWeUdZONxDXyWOtQ=@szczek.dev> In-Reply-To: References: Feedback-ID: 37679334:user:proton X-Pm-Message-ID: 690e71b158b43438e4065b9972419916e1a9353b MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: kamil@szczek.dev 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: EI5MBYKUKPSQST6LMRUD3E7JVTW2RGTX X-Message-ID-Hash: EI5MBYKUKPSQST6LMRUD3E7JVTW2RGTX X-Mailman-Approved-At: Mon, 19 Aug 2024 08:38:18 -0400 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: pass (identity @szczek.dev) X-ZM-MESSAGEID: 1724056954597116600 Content-Type: text/plain; charset="utf-8" This introduces a new 'ps2' feature which, when disabled, results in no implicit PS/2 bus input devices being automatically added to the domain and addition of the 'i8042=3Doff' machine option to the QEMU command-line. A notable side effect of disabling the i8042 controller in QEMU is that the vmport device won't be created. For this reason we will not allow setting the vmport feature if the ps2 feature is explicitly disabled. Signed-off-by: Kamil Szcz=C4=99k --- docs/formatdomain.rst | 6 ++++++ src/conf/domain_conf.c | 6 +++++- src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 23 +++++++++++++++++++++++ src/conf/schemas/domaincommon.rng | 5 +++++ src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_domain.c | 3 ++- src/qemu/qemu_validate.c | 23 +++++++++++++++++++++++ 8 files changed, 70 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index e1e219bcb5..741405ec12 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2022,6 +2022,7 @@ Hypervisors may allow certain CPU / machine features = to be toggled on/off. + ... =20 @@ -2262,6 +2263,11 @@ are: exceptions when enabled (``on``). If the attribute is not defined, the hypervisor default will be used. :since:`Since 10.4.0` (QEMU/KVM and ARM virt guests only) +``ps2`` + Depending on the ``state`` attribute (values ``on``, ``off``) enable or + disable the emulation of a PS/2 controller used by ``ps2`` bus input de= vices. + If the attribute is not defined, the hypervisor default will be used. + :since:`Since 10.7.0` (QEMU only) =20 Time keeping ------------ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d950921667..a897b0b727 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -185,6 +185,7 @@ VIR_ENUM_IMPL(virDomainFeature, "tcg", "async-teardown", "ras", + "ps2", ); =20 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, @@ -17019,7 +17020,8 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_CCF_ASSIST: - case VIR_DOMAIN_FEATURE_RAS: { + case VIR_DOMAIN_FEATURE_RAS: + case VIR_DOMAIN_FEATURE_PS2: { virTristateSwitch state; =20 if (virXMLPropTristateSwitch(nodes[i], "state", @@ -20883,6 +20885,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef = *src, case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_CCF_ASSIST: case VIR_DOMAIN_FEATURE_RAS: + case VIR_DOMAIN_FEATURE_PS2: if (src->features[i] !=3D dst->features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of feature '%1$s' differs: source:= '%2$s', destination: '%3$s'"), @@ -27685,6 +27688,7 @@ virDomainDefFormatFeatures(virBuffer *buf, case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_CCF_ASSIST: case VIR_DOMAIN_FEATURE_RAS: + case VIR_DOMAIN_FEATURE_PS2: switch ((virTristateSwitch) def->features[i]) { case VIR_TRISTATE_SWITCH_LAST: case VIR_TRISTATE_SWITCH_ABSENT: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index eae621f900..f65cdd87b6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2181,6 +2181,7 @@ typedef enum { VIR_DOMAIN_FEATURE_TCG, VIR_DOMAIN_FEATURE_ASYNC_TEARDOWN, VIR_DOMAIN_FEATURE_RAS, + VIR_DOMAIN_FEATURE_PS2, =20 VIR_DOMAIN_FEATURE_LAST } virDomainFeature; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 39b8d67928..56f1092841 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2744,6 +2744,29 @@ virDomainInputDefValidate(const virDomainInputDef *i= nput, return -1; } =20 + switch ((virDomainInputBus) input->bus) { + case VIR_DOMAIN_INPUT_BUS_PS2: + if (def->features[VIR_DOMAIN_FEATURE_PS2] =3D=3D VIR_TRISTATE_SWIT= CH_OFF) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ps2 bus inputs require the ps2 feature not t= o be disabled")); + return -1; + } + break; + + case VIR_DOMAIN_INPUT_BUS_DEFAULT: + case VIR_DOMAIN_INPUT_BUS_USB: + case VIR_DOMAIN_INPUT_BUS_XEN: + case VIR_DOMAIN_INPUT_BUS_PARALLELS: + case VIR_DOMAIN_INPUT_BUS_VIRTIO: + case VIR_DOMAIN_INPUT_BUS_NONE: + break; + + case VIR_DOMAIN_INPUT_BUS_LAST: + default: + virReportEnumRangeError(virDomainInputBus, input->bus); + return -1; + } + return 0; } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 05ba697924..a71f1d97b9 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6917,6 +6917,11 @@ + + + + + diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 28914c9c34..bb6fee4bfd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6888,6 +6888,11 @@ qemuAppendDomainFeaturesMachineParam(virBuffer *buf, virBufferAsprintf(buf, ",ras=3D%s", str); } =20 + if (def->features[VIR_DOMAIN_FEATURE_PS2] !=3D VIR_TRISTATE_SWITCH_ABS= ENT) { + const char *str =3D virTristateSwitchTypeToString(def->features[VI= R_DOMAIN_FEATURE_PS2]); + virBufferAsprintf(buf, ",i8042=3D%s", str); + } + return 0; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2b4bb54efc..d1767c326d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3928,7 +3928,8 @@ static int qemuDomainDefAddImplicitInputDevice(virDomainDef *def, virQEMUCaps *qemuCaps) { - if (virQEMUCapsSupportsI8042(qemuCaps, def)) { + if (virQEMUCapsSupportsI8042(qemuCaps, def) && + def->features[VIR_DOMAIN_FEATURE_PS2] !=3D VIR_TRISTATE_SWITCH_OFF= ) { if (virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_BUS_PS2) < 0) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6f7aeababe..88774f5383 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -143,6 +143,13 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, _("vmport is not available with this QEMU b= inary")); return -1; } + + if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON && + def->features[VIR_DOMAIN_FEATURE_PS2] =3D=3D VIR_TRISTATE_= SWITCH_OFF) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("vmport feature requires the ps2 feature = not to be disabled")); + return -1; + } break; =20 case VIR_DOMAIN_FEATURE_VMCOREINFO: @@ -242,6 +249,22 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, } break; =20 + case VIR_DOMAIN_FEATURE_PS2: + if (def->features[i] !=3D VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsSupportsI8042(qemuCaps, def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ps2 feature is not available with this Q= EMU binary")); + return -1; + } + + if (def->features[i] !=3D VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsSupportsI8042Toggle(qemuCaps, def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ps2 feature state cannot be controlled w= ith this QEMU binary")); + return -1; + } + break; + case VIR_DOMAIN_FEATURE_SMM: case VIR_DOMAIN_FEATURE_KVM: case VIR_DOMAIN_FEATURE_XEN: --=20 2.45.0