Skip to content

Commit 031cdd3

Browse files
t-8chshuahkh
authored andcommitted
kunit: Enable PCI on UML without triggering WARN()
Various KUnit tests require PCI infrastructure to work. All normal platforms enable PCI by default, but UML does not. Enabling PCI from .kunitconfig files is problematic as it would not be portable. So in commit 6fc3a86 ("kunit: tool: Enable virtio/PCI by default on UML") PCI was enabled by way of CONFIG_UML_PCI_OVER_VIRTIO=y. However CONFIG_UML_PCI_OVER_VIRTIO requires additional configuration of CONFIG_UML_PCI_OVER_VIRTIO_DEVICE_ID or will otherwise trigger a WARN() in virtio_pcidev_init(). However there is no one correct value for UML_PCI_OVER_VIRTIO_DEVICE_ID which could be used by default. This warning is confusing when debugging test failures. On the other hand, the functionality of CONFIG_UML_PCI_OVER_VIRTIO is not used at all, given that it is completely non-functional as indicated by the WARN() in question. Instead it is only used as a way to enable CONFIG_UML_PCI which itself is not directly configurable. Instead of going through CONFIG_UML_PCI_OVER_VIRTIO, introduce a custom configuration option which enables CONFIG_UML_PCI without triggering warnings or building dead code. Link: https://lore.kernel.org/r/20250908-kunit-uml-pci-v2-1-d8eba5f73c9d@linutronix.de Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 93cf798 commit 031cdd3

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/kunit/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,11 @@ config KUNIT_DEFAULT_TIMEOUT
106106
If unsure, the default timeout of 300 seconds is suitable for most
107107
cases.
108108

109+
config KUNIT_UML_PCI
110+
bool "KUnit UML PCI Support"
111+
depends on UML
112+
select UML_PCI
113+
help
114+
Enables the PCI subsystem on UML for use by KUnit tests.
115+
109116
endif # KUNIT
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Config options which are added to UML builds by default
22

3-
# Enable virtio/pci, as a lot of tests require it.
4-
CONFIG_VIRTIO_UML=y
5-
CONFIG_UML_PCI_OVER_VIRTIO=y
3+
# Enable pci, as a lot of tests require it.
4+
CONFIG_KUNIT_UML_PCI=y
65

76
# Enable FORTIFY_SOURCE for wider checking.
87
CONFIG_FORTIFY_SOURCE=y

0 commit comments

Comments
 (0)