From nobody Wed Nov 27 08:42:14 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=1724056785; cv=none; d=zohomail.com; s=zohoarc; b=LC2NCdQr0fCFV86oskzGiQFnEXrPLE/m+5NVYpSbabXb9JpKQhEj5oxdtlEtUgouH5nYchFim3mXghr1S3coYPV5MF8qY99mL0empiU/RAuSftkDUghkZapwJobR3arIxU8VUgHwDZtPokdlj4Jc4C2qM83Z+UXw/E85jb4Zmao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724056785; 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=bsU6qVhbZTsNGqmu7FshyAzyV5b/A2Lm26Dl16Nh5qo=; b=g3cjmeifZDZmhJux4H9WWNCFEiCsJd75WARJfM1W9vI41idAhqm8ytgX4+vZZWE15txujWHJUFh0oEEGeqeofzBSDildvamkckYPpSHXwsYaRZC+4ss1BgD5ZX7821PqXuLJFPJSiZYXm5YhWGxDzMVTE0HYXqp+MXhaBzrVTuM= 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 1724056785113679.7389593413801; Mon, 19 Aug 2024 01:39:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1341715CD; Mon, 19 Aug 2024 04:39:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2613D15E4; Mon, 19 Aug 2024 04:38:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 740001400; Sun, 18 Aug 2024 21:17:17 -0400 (EDT) Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) (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 BEF111300 for ; Sun, 18 Aug 2024 21:17:16 -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=1724030234; x=1724289434; bh=bsU6qVhbZTsNGqmu7FshyAzyV5b/A2Lm26Dl16Nh5qo=; 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=BUJFMy92Hv7KgqAq62deUIXEKu1hn/qA98CS7fNfJXnNIdknThwD8XTo+56b9xuau ldsnUhZlpt/LodvdHMmJqaKPPoYj9GubJ17ixeCSUmfdciu6LuwmjXt0KNilyU3N/h nCfcdpLFJ39Lr7Mz1J3cSdY0EffjkT1GpB8VxSUz2yi71/sCZHWca9JBZ8ZsQ/tons uGHWn+VaYIFsVi6YseFuo7VvqlS+CilVhKFjpSJzCpz6JYCYhSdVC8iqRbtIdvKeMK uKiCC28NIV+ApTFfU5b5y5D8ihHSSuZZLtHtjmDQ/MMZ1KRCj7ABmO/9L/vpsgV0FS QwHfOnxH+X+Ug== Date: Mon, 19 Aug 2024 01:17:11 +0000 To: "devel@lists.libvirt.org" From: =?utf-8?Q?Kamil_Szcz=C4=99k?= Subject: [PATCH v3 1/6] qemu: Improve PS/2 controller detection Message-ID: In-Reply-To: References: Feedback-ID: 37679334:user:proton X-Pm-Message-ID: dc3492ec41b1da307cd5e7f25dc624040268ce5c 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: MVUFYXKYOOMF45D4ZZZEC2QTS5GPX524 X-Message-ID-Hash: MVUFYXKYOOMF45D4ZZZEC2QTS5GPX524 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: 1724056785972116600 Content-Type: text/plain; charset="utf-8" Up until now, we've assumed that all x86 machines have a PS/2 controller built-in. This assumption was correct until QEMU v4.2 introduced a new x86-based machine type - microvm. Due to this assumption, a pair of unnecessary PS/2 inputs are implicitly added to all microvm domains. This patch fixes that by whitelisting machine types which are known to include the i8042 PS/2 controller. Signed-off-by: Kamil Szcz=C4=99k --- src/qemu/qemu_capabilities.c | 13 +++++++++++++ src/qemu/qemu_capabilities.h | 5 ++++- src/qemu/qemu_domain.c | 28 +++++++++++++++++++++++++--- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_validate.c | 4 ++-- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2f66a49711..dd833fb3ff 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6008,6 +6008,19 @@ virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps, STREQ(def->os.machine, "isapc"); } =20 +bool +virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps, + const virDomainDef *def) +{ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_I8042)) + return false; + + return qemuDomainIsI440FX(def) || + qemuDomainIsQ35(def) || + qemuDomainIsXenFV(def) || + STREQ(def->os.machine, "isapc"); +} + =20 /* * The preferred machine to use if none is listed explicitly diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index edeb870e01..659efd9182 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -535,7 +535,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_SMP_DIES, /* -smp dies=3D */ =20 /* 350 */ - QEMU_CAPS_DEVICE_I8042, /* PS/2 controller */ + QEMU_CAPS_DEVICE_I8042, /* PS/2 controller, use virQEMUCapsSupportsI80= 42() to query this capability */ QEMU_CAPS_OBJECT_RNG_BUILTIN, /* -object rng-builtin */ X_QEMU_CAPS_VIRTIO_NET_FAILOVER, /* virtio-net-*.failover */ QEMU_CAPS_DEVICE_TPM_SPAPR, /* -device tpm-spapr */ @@ -718,6 +718,9 @@ void virQEMUCapsInitProcessCapsInterlock(virQEMUCaps *q= emuCaps); bool virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps, const virDomainDef *def); =20 +bool virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps, + const virDomainDef *def); + const char *virQEMUCapsGetBinary(virQEMUCaps *qemuCaps); virArch virQEMUCapsGetArch(virQEMUCaps *qemuCaps); unsigned int virQEMUCapsGetVersion(virQEMUCaps *qemuCaps); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f87ba6ba51..2b4bb54efc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3925,9 +3925,10 @@ virXMLNamespace virQEMUDriverDomainXMLNamespace =3D { =20 =20 static int -qemuDomainDefAddImplicitInputDevice(virDomainDef *def) +qemuDomainDefAddImplicitInputDevice(virDomainDef *def, + virQEMUCaps *qemuCaps) { - if (ARCH_IS_X86(def->os.arch)) { + if (virQEMUCapsSupportsI8042(qemuCaps, def)) { if (virDomainDefMaybeAddInput(def, VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_BUS_PS2) < 0) @@ -4166,7 +4167,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, bool addITCOWatchdog =3D false; =20 /* add implicit input devices */ - if (qemuDomainDefAddImplicitInputDevice(def) < 0) + if (qemuDomainDefAddImplicitInputDevice(def, qemuCaps) < 0) return -1; =20 /* Add implicit PCI root controller if the machine has one */ @@ -9177,6 +9178,21 @@ qemuDomainMachineIsMipsMalta(const char *machine, return false; } =20 +static bool +qemuDomainMachineIsXenFV(const char *machine, + const virArch arch) +{ + if (!ARCH_IS_X86(arch)) + return false; + + if (STREQ(machine, "xenfv") || + STRPREFIX(machine, "xenfv-")) { + return true; + } + + return false; +} + =20 /* You should normally avoid this function and use * qemuDomainHasBuiltinIDE() instead. */ @@ -9263,6 +9279,12 @@ qemuDomainIsLoongArchVirt(const virDomainDef *def) return qemuDomainMachineIsLoongArchVirt(def->os.machine, def->os.arch); } =20 +bool +qemuDomainIsXenFV(const virDomainDef *def) +{ + return qemuDomainMachineIsXenFV(def->os.machine, def->os.arch); +} + =20 bool qemuDomainHasPCIRoot(const virDomainDef *def) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index af0bb04c45..1179b0d6dc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -838,6 +838,7 @@ bool qemuDomainIsLoongArchVirt(const virDomainDef *def); bool qemuDomainIsRISCVVirt(const virDomainDef *def); bool qemuDomainIsPSeries(const virDomainDef *def); bool qemuDomainIsMipsMalta(const virDomainDef *def); +bool qemuDomainIsXenFV(const virDomainDef *def); bool qemuDomainHasPCIRoot(const virDomainDef *def); bool qemuDomainHasPCIeRoot(const virDomainDef *def); bool qemuDomainHasBuiltinIDE(const virDomainDef *def); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index b885fe7c77..6f7aeababe 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4868,8 +4868,8 @@ qemuValidateDomainDeviceDefInput(const virDomainInput= Def *input, int cap; int ccwCap; =20 - if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_PS2 && !ARCH_IS_X86(def->os= .arch) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_I8042)) { + if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_PS2 && + !virQEMUCapsSupportsI8042(qemuCaps, def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("%1$s is not supported by this QEMU binary"), virDomainInputBusTypeToString(input->bus)); --=20 2.45.0