[PATCH 03/13] qemu: give the component its own Kconfig
Daniel Gomez <[email protected]> Fri, 12 Jun 2026 14:36:41 +0200
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Daniel Gomez <[email protected]> Move the QEMU build knobs out of Kconfig.libvirt into a dedicated kconfigs/Kconfig.qemu, sourced from Kconfig.bringup outside the LIBVIRT guard so backends other than libvirt can build QEMU too. The symbols lose their QEMU_BUILD prefix now that they no longer share the libvirt namespace, so QEMU_BUILD becomes QEMU, QEMU_BUILD_GIT becomes QEMU_GIT and so on. The build inputs gain output yaml and a derived QEMU_TARGET, so the git tree, version, fetch path and target list reach the role through extra_vars.yaml like every other workflow. This retires the hand-rolled QEMU_BUILD_SETUP_ARGS push from the make fragment. QEMU_BIN_PATH is unified into Kconfig.qemu with output yaml and stays ungated, so the plain-libvirt case still resolves it from QEMU_BIN_PATH_LIBVIRT while every other backend uses the binary the role installs. Since it now reaches extra_vars.yaml on its own, the gen-nodes qemu_bin_path push is dropped to avoid a duplicate mapping key; gen_nodes and qsu both read the one QEMU_BIN_PATH. Dropping that push also orphans QEMU_INSTALL_DIR_LIBVIRT, which is removed along with its cxl-switch setting. The Makefile include guard, Kconfig.qsu reference and the cxl-switch defconfig follow the rename. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- MAINTAINERS | 1 + Makefile | 4 +- defconfigs/cxl-switch | 11 ++-- kconfigs/Kconfig.bringup | 1 + kconfigs/Kconfig.libvirt | 90 ---------------------------- kconfigs/Kconfig.qemu | 106 +++++++++++++++++++++++++++++++++ kconfigs/Kconfig.qsu | 16 +++-- playbooks/roles/qemu/defaults/main.yml | 10 ++-- scripts/gen-nodes.Makefile | 19 ------ scripts/qemu.Makefile | 28 ++------- 10 files changed, 131 insertions(+), 155 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1064f8ee..17c6c9ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -188,6 +188,7 @@ M: Daniel Gomez <[email protected]> L: [email protected] S: Maintained T: git https://github.com/linux-kdevops/kdevops.git +F: kconfigs/Kconfig.qemu F: playbooks/qemu.yml F: playbooks/roles/qemu/ F: scripts/qemu.Makefile diff --git a/Makefile b/Makefile index a6f4f8ca..0d6f7c4f 100644 --- a/Makefile +++ b/Makefile @@ -192,9 +192,9 @@ include scripts/install-rcloud-deps.Makefile include Makefile.btrfs_progs -ifeq (y,$(CONFIG_QEMU_BUILD)) +ifeq (y,$(CONFIG_QEMU)) include scripts/qemu.Makefile -endif # CONFIG_QEMU_BUILD +endif # CONFIG_QEMU ifeq (y,$(CONFIG_SETUP_POSTFIX_EMAIL_RELAY)) include Makefile.postfix diff --git a/defconfigs/cxl-switch b/defconfigs/cxl-switch index 6c7b0344..50d10343 100644 --- a/defconfigs/cxl-switch +++ b/defconfigs/cxl-switch @@ -1,13 +1,12 @@ CONFIG_VAGRANT=y CONFIG_LIBVIRT=y -CONFIG_QEMU_BUILD=y +CONFIG_QEMU=y CONFIG_QEMU_BIN_PATH_LIBVIRT="/usr/local/bin/qemu-system-x86_64" -CONFIG_QEMU_BUILD_JIC23=y +CONFIG_QEMU_JIC23=y CONFIG_QEMU_USE_DEVELOPMENT_VERSION=y -CONFIG_QEMU_BUILD_GIT="https://gitlab.com/jic23/qemu.git" -CONFIG_QEMU_BUILD_GIT_DATA_PATH="{{local_dev_path}}/qemu" -CONFIG_QEMU_BUILD_GIT_VERSION="cxl-2023-11-02" -CONFIG_QEMU_INSTALL_DIR_LIBVIRT="/usr/local/bin" +CONFIG_QEMU_GIT="https://gitlab.com/jic23/qemu.git" +CONFIG_QEMU_GIT_DATA_PATH="{{local_dev_path}}/qemu" +CONFIG_QEMU_GIT_VERSION="cxl-2023-11-02" CONFIG_QEMU_BIN_PATH="/usr/local/bin/qemu-system-x86_64" CONFIG_WORKFLOW_LINUX_CUSTOM=y CONFIG_BOOTLINUX=y diff --git a/kconfigs/Kconfig.bringup b/kconfigs/Kconfig.bringup index f1f1dfab..2f16bce6 100644 --- a/kconfigs/Kconfig.bringup +++ b/kconfigs/Kconfig.bringup @@ -125,6 +125,7 @@ source "kconfigs/Kconfig.nixos_flake" source "kconfigs/Kconfig.qsu" source "terraform/Kconfig" source "kconfigs/Kconfig.declared_hosts" +source "kconfigs/Kconfig.qemu" if LIBVIRT source "kconfigs/Kconfig.libvirt" endif diff --git a/kconfigs/Kconfig.libvirt b/kconfigs/Kconfig.libvirt index b9e886a0..13a14156 100644 --- a/kconfigs/Kconfig.libvirt +++ b/kconfigs/Kconfig.libvirt @@ -165,11 +165,6 @@ config LIBVIRT_STORAGE_POOL_PATH default LIBVIRT_STORAGE_POOL_PATH_AUTO if LIBVIRT && LIBVIRT_STORAGE_POOL_PATH_CUSTOM_CWD default LIBVIRT_STORAGE_POOL_PATH_CUSTOM if LIBVIRT && LIBVIRT_STORAGE_POOL_PATH_CUSTOM_MANUAL -config QEMU_BIN_PATH - string - default QEMU_BIN_PATH_LIBVIRT if LIBVIRT - default $(shell,./scripts/get_libvirt_qemu_bin_path.sh) if !QEMU_USE_DEVELOPMENT_VERSION - config LIBVIRT_URI string default "qemu:///system" if !LIBVIRT @@ -207,86 +202,6 @@ config USE_LIBVIRT_MIRROR default y if USE_LOCAL_LINUX_MIRROR default n if !USE_LOCAL_LINUX_MIRROR -config QEMU_BUILD - bool "Should we build QEMU for you?" - select NEEDS_LOCAL_DEVELOPMENT_PATH - help - You only want to enable this option if your distribution package - of QEMU does not have support for the features you need. For - example this may be useful if you are a QEMU developer or are - relying on technology is still under development or if you have - a custom QEMU git URL. - -if !QEMU_BUILD - -config QEMU_USE_DEVELOPMENT_VERSION - bool "Should we look for a development version of QEMU?" - help - You want to enable this option if for example the currently - available version of QEMU does not yet have support for the feature - you are going to be working on. - - Say yes here if you are compiling your own version of QEMU. - -endif # !QEMU_BUILD - -if QEMU_BUILD - -choice - prompt "QEMU git URL to use" - default QEMU_BUILD_JIC23 - -config QEMU_BUILD_UPSTREAM - bool "https://gitlab.com/qemu-project/qemu.git" - help - Select this option if you want to use the upstream QEMU git repo. - -config QEMU_BUILD_JIC23 - bool "https://gitlab.com/jic23/qemu.git" - help - Select this option if you want to use Cameron's QEMU git repo. - This has a few CXL bells and whistles which are not yet upstream. - -config QEMU_BUILD_MANUAL - bool "Custom QEMU git URL" - help - Select this option if you want to specify your own git URL. - -endchoice - -config QEMU_BUILD_GIT - string "Git tree for QEMU to clone on localhost" - default "/mirror/qemu.git" if USE_LOCAL_LINUX_MIRROR && QEMU_BUILD_UPSTREAM || QEMU_BUILD_MANUAL - default "/mirror/qemu-jic23.git" if USE_LOCAL_LINUX_MIRROR && QEMU_BUILD_JIC23 - default DEFAULT_QEMU_GITHUB_HTTPS_URL if !USE_LOCAL_LINUX_MIRROR && QEMU_BUILD_UPSTREAM || QEMU_BUILD_MANUAL - default DEFAULT_QEMU_JIC23_GITHUB_HTTPS_URL if !USE_LOCAL_LINUX_MIRROR && QEMU_BUILD_JIC23 - help - This is the git URL to use to clone and then build QEMU for you on - your localhost. - -config QEMU_BUILD_GIT_DATA_PATH - string "The destination directory where to clone the QEMU git tree" - default "{{local_dev_path}}/qemu" - help - This is the target location of where to clone the above git tree. - Note that {{local_dev_path}} corresponds to the location set by the - configuration option CONFIG_NEEDS_LOCAL_DEVELOPMENT_PATH. - -config QEMU_BUILD_GIT_VERSION - string "The version of QEMU to build" - default "cxl-2023-05-19" if QEMU_BUILD_JIC23 - default "v8.0.0-rc1" if QEMU_BUILD_UPSTREAM - help - This is the target build version of QEMU to build. Please use - at least v7.2.0 for CXL support. v8.0.0-rc1 has some build fixes - for newer compilers so it is the default now. - -config QEMU_USE_DEVELOPMENT_VERSION - bool - default y - -endif # QEMU_BUILD - config QEMU_BIN_PATH_LIBVIRT string "QEMU binary path to use" default "/usr/local/bin/qemu-system-x86_64" if QEMU_USE_DEVELOPMENT_VERSION && TARGET_ARCH_X86_64 @@ -296,11 +211,6 @@ config QEMU_BIN_PATH_LIBVIRT default "/usr/bin/qemu-system-aarch64" if !QEMU_USE_DEVELOPMENT_VERSION && TARGET_ARCH_ARM64 default "/usr/bin/qemu-system-ppc64le" if !QEMU_USE_DEVELOPMENT_VERSION && TARGET_ARCH_PPC64LE -config QEMU_INSTALL_DIR_LIBVIRT - string "Path to install QEMU" - default "/usr/local/bin" if QEMU_USE_DEVELOPMENT_VERSION - default "/usr/bin" if !QEMU_USE_DEVELOPMENT_VERSION - config QEMU_VIRSH_CAN_SUDO bool default $(shell, ./scripts/get_libvirsh_can_sudo.sh) diff --git a/kconfigs/Kconfig.qemu b/kconfigs/Kconfig.qemu new file mode 100644 index 00000000..49a1ae97 --- /dev/null +++ b/kconfigs/Kconfig.qemu @@ -0,0 +1,106 @@ +config QEMU + bool "Should we build QEMU for you?" + help + You only want to enable this option if your distribution package + of QEMU does not have support for the features you need. For + example this may be useful if you are a QEMU developer or are + relying on technology is still under development or if you have + a custom QEMU git URL. + +if !QEMU + +config QEMU_USE_DEVELOPMENT_VERSION + bool "Should we look for a development version of QEMU?" + help + You want to enable this option if for example the currently + available version of QEMU does not yet have support for the feature + you are going to be working on. + + Say yes here if you are compiling your own version of QEMU. + +endif # !QEMU + +if QEMU + +choice + prompt "QEMU git URL to use" + default QEMU_JIC23 + +config QEMU_UPSTREAM + bool "https://gitlab.com/qemu-project/qemu.git" + help + Select this option if you want to use the upstream QEMU git repo. + +config QEMU_JIC23 + bool "https://gitlab.com/jic23/qemu.git" + help + Select this option if you want to use Cameron's QEMU git repo. + This has a few CXL bells and whistles which are not yet upstream. + +config QEMU_MANUAL + bool "Custom QEMU git URL" + help + Select this option if you want to specify your own git URL. + +endchoice + +config QEMU_GIT + string "Git tree for QEMU to fetch on localhost" + output yaml + default "/mirror/qemu.git" if USE_LOCAL_LINUX_MIRROR && QEMU_UPSTREAM || QEMU_MANUAL + default "/mirror/qemu-jic23.git" if USE_LOCAL_LINUX_MIRROR && QEMU_JIC23 + default DEFAULT_QEMU_GITHUB_HTTPS_URL if !USE_LOCAL_LINUX_MIRROR && QEMU_UPSTREAM || QEMU_MANUAL + default DEFAULT_QEMU_JIC23_GITHUB_HTTPS_URL if !USE_LOCAL_LINUX_MIRROR && QEMU_JIC23 + help + This is the git URL to use to fetch and then build QEMU for you on + your localhost. + +config QEMU_GIT_DATA_PATH + string "The destination directory where to fetch the QEMU git tree" + output yaml + default "{{local_dev_path}}/qemu" + help + This is the target location of where to fetch the above git tree. + Note that {{local_dev_path}} corresponds to the location set by the + configuration option CONFIG_NEEDS_LOCAL_DEVELOPMENT_PATH. + +config QEMU_GIT_VERSION + string "The version of QEMU to build" + output yaml + default "cxl-2023-05-19" if QEMU_JIC23 + default "v8.0.0-rc1" if QEMU_UPSTREAM + help + This is the target build version of QEMU to build. Please use + at least v7.2.0 for CXL support. v8.0.0-rc1 has some build fixes + for newer compilers so it is the default now. + +config QEMU_USE_DEVELOPMENT_VERSION + bool + default y + +config QEMU_TARGET + string + output yaml + default "x86_64-softmmu" if TARGET_ARCH_X86_64 + default "aarch64-softmmu" if TARGET_ARCH_ARM64 + default "ppc64-softmmu" if TARGET_ARCH_PPC64LE + default "x86_64-softmmu" + help + QEMU --target-list value derived from the target architecture. + Consumed by the qemu role to configure the build. + +endif # QEMU + +config QEMU_BIN_PATH + string + output yaml + default QEMU_BIN_PATH_LIBVIRT if LIBVIRT + default "/usr/local/bin/qemu-system-aarch64" if TARGET_ARCH_ARM64 + default "/usr/local/bin/qemu-system-ppc64" if TARGET_ARCH_PPC64LE + default "/usr/local/bin/qemu-system-x86_64" + help + Absolute path to the QEMU system emulator binary. The libvirt + backend resolves this from QEMU_BIN_PATH_LIBVIRT. Every other + backend uses the binary installed by the qemu role under its + install prefix. This single source of truth feeds gen_nodes for + the libvirt domain emulator and qsu for the systemd unit ExecStart. diff --git a/kconfigs/Kconfig.qsu b/kconfigs/Kconfig.qsu index 4cbd4dbb..f4f5f99a 100644 --- a/kconfigs/Kconfig.qsu +++ b/kconfigs/Kconfig.qsu @@ -16,21 +16,19 @@ config QSU_VARS_DIR config QSU_QEMU_BINARY string "QEMU system emulator binary" output yaml - default QEMU_BUILD_BIN_PATH if QEMU_BUILD + default QEMU_BIN_PATH if QEMU default "/usr/bin/qemu-system-x86_64" help Absolute path to the QEMU system emulator binary for the guest architecture. The qsu templates invoke this as the ExecStart= binary path. - When QEMU_BUILD=y, this defaults to QEMU_BUILD_BIN_PATH so - the qsu service exec'd by systemd is the binary the - build_qemu role just installed under - KDEVOPS_CONTROLLER_DATA_PATH/qemu-destdir/bin/, with no - manual override needed in the defconfig. The Jinja2 - template resolves at Ansible-use time so changing the - controller data path or destdir path higher up propagates - here transitively. + When QEMU=y, this defaults to QEMU_BIN_PATH so the qsu + service exec'd by systemd is the binary the qemu role just + built and installed, with no manual override needed in the + defconfig. The Jinja2 template resolves at Ansible-use time + so changing the install prefix higher up propagates here + transitively. config QSU_CPU string "Guest CPU model" diff --git a/playbooks/roles/qemu/defaults/main.yml b/playbooks/roles/qemu/defaults/main.yml index 07fe4802..806d5375 100644 --- a/playbooks/roles/qemu/defaults/main.yml +++ b/playbooks/roles/qemu/defaults/main.yml @@ -3,9 +3,9 @@ # Forces to build and install even if the binary is already present qemu_force_install_if_present: false -qemu_bin_path: "/usr/local/bin/qemu-system-x86_64" -qemu_data: "{{ data_path }}/qemu" -qemu_git: "https://github.com/qemu/qemu.git" -qemu_version: "v7.2.0-rc4" +qemu_bin_path: "{{ qemu_bin_path | default('/usr/local/bin/qemu-system-x86_64') }}" +qemu_data: "{{ qemu_git_data_path | default(local_dev_path + '/qemu') }}" +qemu_git: "{{ qemu_git | default('https://github.com/qemu/qemu.git') }}" +qemu_version: "{{ qemu_git_version | default('v7.2.0-rc4') }}" qemu_build_dir: "{{ qemu_data }}/build" -qemu_target: "x86_64-softmmu" +qemu_target: "{{ qemu_target | default('x86_64-softmmu') }}" diff --git a/scripts/gen-nodes.Makefile b/scripts/gen-nodes.Makefile index 8ca11d60..8e2d0b32 100644 --- a/scripts/gen-nodes.Makefile +++ b/scripts/gen-nodes.Makefile @@ -7,25 +7,6 @@ GEN_NODES_EXTRA_ARGS += kdevops_nodes_template_full_path='$(TOPDIR_PATH)/$(KDEVO GEN_NODES_EXTRA_ARGS += libvirt_vcpus_count='$(subst ",,$(CONFIG_LIBVIRT_VCPUS_COUNT))' GEN_NODES_EXTRA_ARGS += libvirt_mem_mb='$(subst ",,$(CONFIG_LIBVIRT_MEM_MB))' -ifeq (y,$(CONFIG_QEMU_BUILD)) - - ifeq (y,$(CONFIG_TARGET_ARCH_X86_64)) - GEN_NODES_EXTRA_ARGS += qemu_bin_path='$(subst ",,$(CONFIG_QEMU_INSTALL_DIR_LIBVIRT))/qemu-system-x86_64' - endif - - ifeq (y,$(CONFIG_TARGET_ARCH_ARM64)) - GEN_NODES_EXTRA_ARGS += qemu_bin_path='$(subst ",,$(CONFIG_QEMU_INSTALL_DIR_LIBVIRT))/qemu-system-aarch64' - endif - - ifeq (y,$(CONFIG_TARGET_ARCH_PPC64LE)) - GEN_NODES_EXTRA_ARGS += qemu_bin_path='$(subst ",,$(CONFIG_QEMU_INSTALL_DIR_LIBVIRT))/qemu-system-ppc64' - endif - -else -GEN_NODES_EXTRA_ARGS += qemu_bin_path='$(subst ",,$(CONFIG_QEMU_BIN_PATH))' -endif - - GEN_NODES_EXTRA_ARGS += libvirt_uri='$(subst ",,$(CONFIG_LIBVIRT_URI))' GEN_NODES_EXTRA_ARGS += libvirt_system_uri='$(subst ",,$(CONFIG_LIBVIRT_SYSTEM_URI))' diff --git a/scripts/qemu.Makefile b/scripts/qemu.Makefile index 09442818..8d7c446e 100644 --- a/scripts/qemu.Makefile +++ b/scripts/qemu.Makefile @@ -1,24 +1,5 @@ # SPDX-License-Identifier: copyleft-next-0.3.1 -QEMU_BUILD_SETUP_ARGS := -QEMU_BUILD_SETUP_ARGS += qemu_build=True - -QEMU_GIT:=$(subst ",,$(CONFIG_QEMU_BUILD_GIT)) -QEMU_GIT_VERSION:=$(subst ",,$(CONFIG_QEMU_BUILD_GIT_VERSION)) -QEMU_DATA:=$(subst ",,$(CONFIG_QEMU_BUILD_GIT_DATA_PATH)) - -QEMU_BUILD_SETUP_ARGS += qemu_git=$(QEMU_GIT) -QEMU_BUILD_SETUP_ARGS += qemu_data=\"$(QEMU_DATA)\" -QEMU_BUILD_SETUP_ARGS += qemu_version='$(QEMU_GIT_VERSION)' - -ifeq (y,$(CONFIG_TARGET_ARCH_X86_64)) -QEMU_BUILD_SETUP_ARGS += qemu_target="x86_64-softmmu" -endif - -ifeq (y,$(CONFIG_TARGET_ARCH_PPC64LE)) -QEMU_BUILD_SETUP_ARGS += qemu_target="ppc64-softmmu" -endif - qemu: $(KDEVOPS_EXTRA_VARS) $(Q)ansible-playbook \ $(KDEVOPS_PLAYBOOKS_DIR)/qemu.yml \ @@ -46,13 +27,12 @@ PHONY += qemu-build qemu-help-menu: @echo "qemu options:" - @echo "qemu - Git clones qemu, builds and install it on localhost" - @echo "qemu-configure - Configure qemu build" - @echo "qemu-build - Build qemu" - @echo "qemu-install - Do the install of the qemu build on localhost" + @echo "qemu - Git fetches QEMU, builds and install it on localhost" + @echo "qemu-configure - Configure QEMU build" + @echo "qemu-build - Build QEMU" + @echo "qemu-install - Do the install of the QEMU build on localhost" @echo "" HELP_TARGETS += qemu-help-menu -ANSIBLE_EXTRA_ARGS += $(QEMU_BUILD_SETUP_ARGS) LOCALHOST_SETUP_WORK += qemu -- 2.54.0