mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 01:33:06 +00:00
vmtest: move kconfig and flavor definitions to a new module
vmtest.config will contain configuration/settings for vmtest. Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
parent
94443457aa
commit
df1a17dc11
190
vmtest/config.py
Normal file
190
vmtest/config.py
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
|
||||||
|
from collections import OrderedDict
|
||||||
|
import inspect
|
||||||
|
from typing import NamedTuple
|
||||||
|
|
||||||
|
VMTEST_KERNEL_VERSION = 18
|
||||||
|
|
||||||
|
|
||||||
|
BASE_KCONFIG = """
|
||||||
|
CONFIG_EXPERT=y
|
||||||
|
CONFIG_MODULES=y
|
||||||
|
CONFIG_MODULE_UNLOAD=y
|
||||||
|
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
|
||||||
|
|
||||||
|
# We run the tests in KVM.
|
||||||
|
CONFIG_HYPERVISOR_GUEST=y
|
||||||
|
CONFIG_KVM_GUEST=y
|
||||||
|
CONFIG_PARAVIRT=y
|
||||||
|
CONFIG_PARAVIRT_SPINLOCKS=y
|
||||||
|
|
||||||
|
# Minimum requirements for vmtest.
|
||||||
|
CONFIG_9P_FS=y
|
||||||
|
CONFIG_DEVTMPFS=y
|
||||||
|
CONFIG_INET=y
|
||||||
|
CONFIG_NET=y
|
||||||
|
CONFIG_NETWORK_FILESYSTEMS=y
|
||||||
|
CONFIG_NET_9P=y
|
||||||
|
CONFIG_NET_9P_VIRTIO=y
|
||||||
|
CONFIG_OVERLAY_FS=y
|
||||||
|
CONFIG_PCI=y
|
||||||
|
CONFIG_PROC_FS=y
|
||||||
|
CONFIG_SERIAL_8250=y
|
||||||
|
CONFIG_SERIAL_8250_CONSOLE=y
|
||||||
|
CONFIG_SYSFS=y
|
||||||
|
CONFIG_TMPFS=y
|
||||||
|
CONFIG_TMPFS_XATTR=y
|
||||||
|
CONFIG_VIRTIO_CONSOLE=y
|
||||||
|
CONFIG_VIRTIO_PCI=y
|
||||||
|
CONFIG_HW_RANDOM=m
|
||||||
|
CONFIG_HW_RANDOM_VIRTIO=m
|
||||||
|
|
||||||
|
# Lots of stuff expect Unix sockets.
|
||||||
|
CONFIG_UNIX=y
|
||||||
|
|
||||||
|
# drgn needs debug info.
|
||||||
|
CONFIG_DEBUG_KERNEL=y
|
||||||
|
CONFIG_DEBUG_INFO=y
|
||||||
|
CONFIG_DEBUG_INFO_DWARF4=y
|
||||||
|
|
||||||
|
# For testing live kernel debugging with /proc/kcore.
|
||||||
|
CONFIG_PROC_KCORE=y
|
||||||
|
# drgn needs /proc/kallsyms in some cases. Some test cases also need it.
|
||||||
|
CONFIG_KALLSYMS=y
|
||||||
|
CONFIG_KALLSYMS_ALL=y
|
||||||
|
|
||||||
|
# For testing kernel core dumps with /proc/vmcore.
|
||||||
|
CONFIG_CRASH_DUMP=y
|
||||||
|
CONFIG_PROC_VMCORE=y
|
||||||
|
CONFIG_KEXEC=y
|
||||||
|
CONFIG_KEXEC_FILE=y
|
||||||
|
# Needed for CONFIG_KEXEC_FILE.
|
||||||
|
CONFIG_CRYPTO=y
|
||||||
|
CONFIG_CRYPTO_SHA256=y
|
||||||
|
|
||||||
|
# So that we can trigger a crash with /proc/sysrq-trigger.
|
||||||
|
CONFIG_MAGIC_SYSRQ=y
|
||||||
|
|
||||||
|
# For block tests.
|
||||||
|
CONFIG_BLK_DEV_LOOP=m
|
||||||
|
|
||||||
|
# For BPF tests.
|
||||||
|
CONFIG_BPF_SYSCALL=y
|
||||||
|
CONFIG_BPF_JIT=y
|
||||||
|
CONFIG_BPF_JIT_ALWAYS_ON=y
|
||||||
|
CONFIG_CGROUP_BPF=y
|
||||||
|
CONFIG_DEBUG_INFO_BTF=y
|
||||||
|
CONFIG_DEBUG_INFO_BTF_MODULES=y
|
||||||
|
|
||||||
|
# For cgroup tests.
|
||||||
|
CONFIG_CGROUPS=y
|
||||||
|
# To select CONFIG_SOCK_CGROUP_DATA. (CONFIG_CGROUP_BPF also selects
|
||||||
|
# CONFIG_SOCK_CGROUP_DATA, but that's only present since Linux kernel commit
|
||||||
|
# 3007098494be ("cgroup: add support for eBPF programs") (in v4.10)).
|
||||||
|
CONFIG_CGROUP_NET_CLASSID=y
|
||||||
|
|
||||||
|
# For kconfig tests.
|
||||||
|
CONFIG_IKCONFIG=m
|
||||||
|
CONFIG_IKCONFIG_PROC=y
|
||||||
|
|
||||||
|
# For filesystem tests.
|
||||||
|
CONFIG_BTRFS_FS=m
|
||||||
|
CONFIG_EXT4_FS=m
|
||||||
|
CONFIG_XFS_FS=m
|
||||||
|
|
||||||
|
# For net tests.
|
||||||
|
CONFIG_NAMESPACES=y
|
||||||
|
|
||||||
|
# For nodemask tests.
|
||||||
|
CONFIG_NUMA=y
|
||||||
|
|
||||||
|
# For slab allocator tests.
|
||||||
|
CONFIG_SLAB_FREELIST_HARDENED=y
|
||||||
|
|
||||||
|
# For Traffic Control tests.
|
||||||
|
CONFIG_NET_SCHED=y
|
||||||
|
CONFIG_NET_SCH_PRIO=m
|
||||||
|
CONFIG_NET_SCH_SFQ=m
|
||||||
|
CONFIG_NET_SCH_TBF=m
|
||||||
|
CONFIG_NET_SCH_INGRESS=m
|
||||||
|
CONFIG_NET_CLS_ACT=y
|
||||||
|
CONFIG_NETDEVICES=y
|
||||||
|
CONFIG_DUMMY=m
|
||||||
|
|
||||||
|
# To enable CONFIG_XARRAY_MULTI for xarray tests.
|
||||||
|
CONFIG_TRANSPARENT_HUGEPAGE=y
|
||||||
|
CONFIG_READ_ONLY_THP_FOR_FS=y
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class KernelFlavor(NamedTuple):
|
||||||
|
name: str
|
||||||
|
description: str
|
||||||
|
config: str
|
||||||
|
|
||||||
|
|
||||||
|
KERNEL_FLAVORS = OrderedDict(
|
||||||
|
(flavor.name, flavor)
|
||||||
|
for flavor in (
|
||||||
|
KernelFlavor(
|
||||||
|
name="default",
|
||||||
|
description="Default configuration",
|
||||||
|
config="""
|
||||||
|
CONFIG_SMP=y
|
||||||
|
CONFIG_SLUB=y
|
||||||
|
# For slab tests.
|
||||||
|
CONFIG_SLUB_DEBUG=y
|
||||||
|
""",
|
||||||
|
),
|
||||||
|
KernelFlavor(
|
||||||
|
name="alternative",
|
||||||
|
description="SLAB allocator",
|
||||||
|
config="""
|
||||||
|
CONFIG_SMP=y
|
||||||
|
CONFIG_SLAB=y
|
||||||
|
""",
|
||||||
|
),
|
||||||
|
KernelFlavor(
|
||||||
|
name="tiny",
|
||||||
|
description="!SMP, !PREEMPT, and SLOB allocator",
|
||||||
|
config="""
|
||||||
|
CONFIG_SMP=n
|
||||||
|
CONFIG_SLOB=y
|
||||||
|
# Linux kernel commit 149b6fa228ed ("mm, slob: rename CONFIG_SLOB to
|
||||||
|
# CONFIG_SLOB_DEPRECATED") (in v6.2) renamed the option for SLOB.
|
||||||
|
CONFIG_SLOB_DEPRECATED=y
|
||||||
|
# CONFIG_PREEMPT_DYNAMIC is not set
|
||||||
|
CONFIG_PREEMPT_NONE=y
|
||||||
|
# !PREEMPTION && !SMP will also select TINY_RCU.
|
||||||
|
""",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def kconfig_localversion(flavor: KernelFlavor) -> str:
|
||||||
|
localversion = f"-vmtest{VMTEST_KERNEL_VERSION}"
|
||||||
|
# The default flavor should be the "latest" version.
|
||||||
|
localversion += ".1" if flavor.name == "default" else ".0"
|
||||||
|
localversion += flavor.name
|
||||||
|
return localversion
|
||||||
|
|
||||||
|
|
||||||
|
def kconfig(flavor: KernelFlavor) -> str:
|
||||||
|
return f"""\
|
||||||
|
# Minimal Linux kernel configuration for booting into vmtest and running drgn
|
||||||
|
# tests ({flavor.name} flavor).
|
||||||
|
|
||||||
|
CONFIG_LOCALVERSION="{kconfig_localversion(flavor)}"
|
||||||
|
|
||||||
|
# base options
|
||||||
|
|
||||||
|
{inspect.cleandoc(BASE_KCONFIG)}
|
||||||
|
|
||||||
|
# {flavor.name} flavor options
|
||||||
|
|
||||||
|
{inspect.cleandoc(flavor.config)}
|
||||||
|
"""
|
179
vmtest/kbuild.py
179
vmtest/kbuild.py
@ -10,7 +10,7 @@ import shlex
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from typing import IO, Any, NamedTuple, Optional, Tuple, Union
|
from typing import IO, Any, Optional, Tuple, Union
|
||||||
|
|
||||||
from util import nproc
|
from util import nproc
|
||||||
from vmtest.asynciosubprocess import (
|
from vmtest.asynciosubprocess import (
|
||||||
@ -20,178 +20,14 @@ from vmtest.asynciosubprocess import (
|
|||||||
check_output_shell,
|
check_output_shell,
|
||||||
pipe_context,
|
pipe_context,
|
||||||
)
|
)
|
||||||
|
from vmtest.config import KERNEL_FLAVORS, KernelFlavor, kconfig
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class KernelFlavor(NamedTuple):
|
|
||||||
name: str
|
|
||||||
description: str
|
|
||||||
config: str
|
|
||||||
|
|
||||||
def localversion(self) -> str:
|
|
||||||
localversion = "-vmtest18"
|
|
||||||
# The default flavor should be the "latest" version.
|
|
||||||
localversion += ".1" if self.name == "default" else ".0"
|
|
||||||
localversion += self.name
|
|
||||||
return localversion
|
|
||||||
|
|
||||||
|
|
||||||
KERNEL_FLAVORS = [
|
|
||||||
KernelFlavor(
|
|
||||||
name="default",
|
|
||||||
description="Default configuration",
|
|
||||||
config="""
|
|
||||||
CONFIG_SMP=y
|
|
||||||
CONFIG_SLUB=y
|
|
||||||
# For slab tests.
|
|
||||||
CONFIG_SLUB_DEBUG=y
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
KernelFlavor(
|
|
||||||
name="alternative",
|
|
||||||
description="SLAB allocator",
|
|
||||||
config="""
|
|
||||||
CONFIG_SMP=y
|
|
||||||
CONFIG_SLAB=y
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
KernelFlavor(
|
|
||||||
name="tiny",
|
|
||||||
description="!SMP, !PREEMPT, and SLOB allocator",
|
|
||||||
config="""
|
|
||||||
CONFIG_SMP=n
|
|
||||||
CONFIG_SLOB=y
|
|
||||||
# Linux kernel commit 149b6fa228ed ("mm, slob: rename CONFIG_SLOB to
|
|
||||||
# CONFIG_SLOB_DEPRECATED") (in v6.2) renamed the option for SLOB.
|
|
||||||
CONFIG_SLOB_DEPRECATED=y
|
|
||||||
# CONFIG_PREEMPT_DYNAMIC is not set
|
|
||||||
CONFIG_PREEMPT_NONE=y
|
|
||||||
# !PREEMPTION && !SMP will also select TINY_RCU.
|
|
||||||
""",
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
_PACKAGE_FORMATS = ("tar.zst", "directory")
|
_PACKAGE_FORMATS = ("tar.zst", "directory")
|
||||||
|
|
||||||
|
|
||||||
def kconfig(flavor: KernelFlavor) -> str:
|
|
||||||
return rf"""# Minimal Linux kernel configuration for booting into vmtest and running drgn
|
|
||||||
# tests ({flavor.name} flavor).
|
|
||||||
|
|
||||||
CONFIG_LOCALVERSION="{flavor.localversion()}"
|
|
||||||
CONFIG_EXPERT=y
|
|
||||||
{flavor.config}
|
|
||||||
CONFIG_MODULES=y
|
|
||||||
CONFIG_MODULE_UNLOAD=y
|
|
||||||
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
|
|
||||||
|
|
||||||
# We run the tests in KVM.
|
|
||||||
CONFIG_HYPERVISOR_GUEST=y
|
|
||||||
CONFIG_KVM_GUEST=y
|
|
||||||
CONFIG_PARAVIRT=y
|
|
||||||
CONFIG_PARAVIRT_SPINLOCKS=y
|
|
||||||
|
|
||||||
# Minimum requirements for vmtest.
|
|
||||||
CONFIG_9P_FS=y
|
|
||||||
CONFIG_DEVTMPFS=y
|
|
||||||
CONFIG_INET=y
|
|
||||||
CONFIG_NET=y
|
|
||||||
CONFIG_NETWORK_FILESYSTEMS=y
|
|
||||||
CONFIG_NET_9P=y
|
|
||||||
CONFIG_NET_9P_VIRTIO=y
|
|
||||||
CONFIG_OVERLAY_FS=y
|
|
||||||
CONFIG_PCI=y
|
|
||||||
CONFIG_PROC_FS=y
|
|
||||||
CONFIG_SERIAL_8250=y
|
|
||||||
CONFIG_SERIAL_8250_CONSOLE=y
|
|
||||||
CONFIG_SYSFS=y
|
|
||||||
CONFIG_TMPFS=y
|
|
||||||
CONFIG_TMPFS_XATTR=y
|
|
||||||
CONFIG_VIRTIO_CONSOLE=y
|
|
||||||
CONFIG_VIRTIO_PCI=y
|
|
||||||
CONFIG_HW_RANDOM=m
|
|
||||||
CONFIG_HW_RANDOM_VIRTIO=m
|
|
||||||
|
|
||||||
# Lots of stuff expect Unix sockets.
|
|
||||||
CONFIG_UNIX=y
|
|
||||||
|
|
||||||
# drgn needs debug info.
|
|
||||||
CONFIG_DEBUG_KERNEL=y
|
|
||||||
CONFIG_DEBUG_INFO=y
|
|
||||||
CONFIG_DEBUG_INFO_DWARF4=y
|
|
||||||
|
|
||||||
# For testing live kernel debugging with /proc/kcore.
|
|
||||||
CONFIG_PROC_KCORE=y
|
|
||||||
# drgn needs /proc/kallsyms in some cases. Some test cases also need it.
|
|
||||||
CONFIG_KALLSYMS=y
|
|
||||||
CONFIG_KALLSYMS_ALL=y
|
|
||||||
|
|
||||||
# For testing kernel core dumps with /proc/vmcore.
|
|
||||||
CONFIG_CRASH_DUMP=y
|
|
||||||
CONFIG_PROC_VMCORE=y
|
|
||||||
CONFIG_KEXEC=y
|
|
||||||
CONFIG_KEXEC_FILE=y
|
|
||||||
# Needed for CONFIG_KEXEC_FILE.
|
|
||||||
CONFIG_CRYPTO=y
|
|
||||||
CONFIG_CRYPTO_SHA256=y
|
|
||||||
|
|
||||||
# So that we can trigger a crash with /proc/sysrq-trigger.
|
|
||||||
CONFIG_MAGIC_SYSRQ=y
|
|
||||||
|
|
||||||
# For block tests.
|
|
||||||
CONFIG_BLK_DEV_LOOP=m
|
|
||||||
|
|
||||||
# For BPF tests.
|
|
||||||
CONFIG_BPF_SYSCALL=y
|
|
||||||
CONFIG_BPF_JIT=y
|
|
||||||
CONFIG_BPF_JIT_ALWAYS_ON=y
|
|
||||||
CONFIG_CGROUP_BPF=y
|
|
||||||
CONFIG_DEBUG_INFO_BTF=y
|
|
||||||
CONFIG_DEBUG_INFO_BTF_MODULES=y
|
|
||||||
|
|
||||||
# For cgroup tests.
|
|
||||||
CONFIG_CGROUPS=y
|
|
||||||
# To select CONFIG_SOCK_CGROUP_DATA. (CONFIG_CGROUP_BPF also selects
|
|
||||||
# CONFIG_SOCK_CGROUP_DATA, but that's only present since Linux kernel commit
|
|
||||||
# 3007098494be ("cgroup: add support for eBPF programs") (in v4.10)).
|
|
||||||
CONFIG_CGROUP_NET_CLASSID=y
|
|
||||||
|
|
||||||
# For kconfig tests.
|
|
||||||
CONFIG_IKCONFIG=m
|
|
||||||
CONFIG_IKCONFIG_PROC=y
|
|
||||||
|
|
||||||
# For filesystem tests.
|
|
||||||
CONFIG_BTRFS_FS=m
|
|
||||||
CONFIG_EXT4_FS=m
|
|
||||||
CONFIG_XFS_FS=m
|
|
||||||
|
|
||||||
# For net tests.
|
|
||||||
CONFIG_NAMESPACES=y
|
|
||||||
|
|
||||||
# For nodemask tests.
|
|
||||||
CONFIG_NUMA=y
|
|
||||||
|
|
||||||
# For slab allocator tests.
|
|
||||||
CONFIG_SLAB_FREELIST_HARDENED=y
|
|
||||||
|
|
||||||
# For Traffic Control tests.
|
|
||||||
CONFIG_NET_SCHED=y
|
|
||||||
CONFIG_NET_SCH_PRIO=m
|
|
||||||
CONFIG_NET_SCH_SFQ=m
|
|
||||||
CONFIG_NET_SCH_TBF=m
|
|
||||||
CONFIG_NET_SCH_INGRESS=m
|
|
||||||
CONFIG_NET_CLS_ACT=y
|
|
||||||
CONFIG_NETDEVICES=y
|
|
||||||
CONFIG_DUMMY=m
|
|
||||||
|
|
||||||
# To enable CONFIG_XARRAY_MULTI for xarray tests.
|
|
||||||
CONFIG_TRANSPARENT_HUGEPAGE=y
|
|
||||||
CONFIG_READ_ONLY_THP_FOR_FS=y
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class KBuild:
|
class KBuild:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -595,12 +431,15 @@ async def main() -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-f",
|
"-f",
|
||||||
"--flavor",
|
"--flavor",
|
||||||
choices=[flavor.name for flavor in KERNEL_FLAVORS],
|
choices=KERNEL_FLAVORS,
|
||||||
help="kernel configuration flavor. "
|
help="kernel configuration flavor. "
|
||||||
+ ". ".join(
|
+ ". ".join(
|
||||||
[f"{flavor.name}: {flavor.description}" for flavor in KERNEL_FLAVORS]
|
[
|
||||||
|
f"{flavor.name}: {flavor.description}"
|
||||||
|
for flavor in KERNEL_FLAVORS.values()
|
||||||
|
]
|
||||||
),
|
),
|
||||||
default=KERNEL_FLAVORS[0].name,
|
default=next(iter(KERNEL_FLAVORS)),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--dump-kconfig",
|
"--dump-kconfig",
|
||||||
@ -609,7 +448,7 @@ async def main() -> None:
|
|||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
flavor = [flavor for flavor in KERNEL_FLAVORS if flavor.name == args.flavor][0]
|
flavor = KERNEL_FLAVORS[args.flavor]
|
||||||
|
|
||||||
if args.dump_kconfig:
|
if args.dump_kconfig:
|
||||||
sys.stdout.write(kconfig(flavor))
|
sys.stdout.write(kconfig(flavor))
|
||||||
|
@ -25,9 +25,10 @@ import uritemplate
|
|||||||
|
|
||||||
from util import KernelVersion
|
from util import KernelVersion
|
||||||
from vmtest.asynciosubprocess import check_call, check_output
|
from vmtest.asynciosubprocess import check_call, check_output
|
||||||
|
from vmtest.config import KERNEL_FLAVORS, KernelFlavor, kconfig_localversion
|
||||||
from vmtest.download import VMTEST_GITHUB_RELEASE, available_kernel_releases
|
from vmtest.download import VMTEST_GITHUB_RELEASE, available_kernel_releases
|
||||||
from vmtest.githubapi import AioGitHubApi
|
from vmtest.githubapi import AioGitHubApi
|
||||||
from vmtest.kbuild import KERNEL_FLAVORS, KBuild, KernelFlavor
|
from vmtest.kbuild import KBuild
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ def kernel_tag_to_release(tag: str, flavor: KernelFlavor) -> str:
|
|||||||
match.group(1),
|
match.group(1),
|
||||||
match.group(2) or ".0",
|
match.group(2) or ".0",
|
||||||
match.group(3) or "",
|
match.group(3) or "",
|
||||||
flavor.localversion(),
|
kconfig_localversion(flavor),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ async def main() -> None:
|
|||||||
for tag in latest_kernel_tags:
|
for tag in latest_kernel_tags:
|
||||||
flavors = [
|
flavors = [
|
||||||
flavor
|
flavor
|
||||||
for flavor in KERNEL_FLAVORS
|
for flavor in KERNEL_FLAVORS.values()
|
||||||
if kernel_tag_to_release(tag, flavor) not in kernel_releases
|
if kernel_tag_to_release(tag, flavor) not in kernel_releases
|
||||||
]
|
]
|
||||||
if flavors:
|
if flavors:
|
||||||
|
Loading…
Reference in New Issue
Block a user