diff --git a/defconfigs/bisection b/defconfigs/bisection new file mode 100644 index 000000000..1c3112a06 --- /dev/null +++ b/defconfigs/bisection @@ -0,0 +1,9 @@ +CONFIG_GUESTFS=y +CONFIG_LIBVIRT=y + +CONFIG_WORKFLOW_LINUX_CUSTOM=y +CONFIG_BOOTLINUX=y +CONFIG_BOOTLINUX_9P=y +CONFIG_BOOTLINUX_BISECT_ENABLE=y + +CONFIG_DEVCONFIG_ENABLE_SYSTEMD_JOURNAL_REMOTE=y diff --git a/playbooks/roles/bootlinux/defaults/main.yml b/playbooks/roles/bootlinux/defaults/main.yml index fd5674b5f..245ae43c5 100644 --- a/playbooks/roles/bootlinux/defaults/main.yml +++ b/playbooks/roles/bootlinux/defaults/main.yml @@ -52,3 +52,9 @@ kdevops_workflow_enable_cxl: False bootlinux_cxl_test: False bootlinux_tree_set_by_cli: False +bootlinux_bisect_enable: False +bootlinux_bisect_enable_cli: False +bootlinux_bisect_ref_good_cli: False +bootlinux_bisect_ref_bad_cli: False +bootlinux_bisect_script_boot: False +bootlinux_bisect_script_custom: False diff --git a/playbooks/roles/bootlinux/tasks/main.yml b/playbooks/roles/bootlinux/tasks/main.yml index 9ad675b3f..afa533c01 100644 --- a/playbooks/roles/bootlinux/tasks/main.yml +++ b/playbooks/roles/bootlinux/tasks/main.yml @@ -650,3 +650,48 @@ vars: running_kernel: "{{ uname_cmd.stdout_lines.0 }}" tags: [ 'linux', 'git', 'config', 'uname' ] + +- name: Copy git bisection script over + template: + src: "{{ bootlinux_bisect_script }}.j2" + dest: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}" + mode: 0644 + tags: [ 'bisect' ] + when: + - bootlinux_bisect_enable|bool + run_once: true + delegate_to: localhost + +- name: Set up bisection for git + command: "git bisect start {{ bootlinux_bisect_ref_bad }} {{ bootlinux_bisect_ref_good }}" + register: build + changed_when: "build.rc == 0" + args: + chdir: "{{ bootlinux_9p_host_path }}" + tags: [ 'bisect' ] + when: + - bootlinux_bisect_enable|bool + run_once: true + delegate_to: localhost + +- name: Ensure bisection script is executable + file: + path: "{{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}" + mode: '0755' + state: file + when: bootlinux_bisect_enable | bool + delegate_to: localhost + run_once: true + tags: [ 'bisect' ] + +- name: Run the the bisection script + command: "git bisect run {{ bootlinux_9p_host_path }}/{{ bootlinux_bisect_script }}" + register: build + changed_when: "build.rc == 0" + args: + chdir: "{{ bootlinux_9p_host_path }}" + tags: [ 'bisect' ] + when: + - bootlinux_bisect_enable|bool + run_once: true + delegate_to: localhost diff --git a/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2 b/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2 new file mode 100755 index 000000000..10dbacd30 --- /dev/null +++ b/playbooks/roles/bootlinux/templates/bisect-boot.sh.j2 @@ -0,0 +1,7 @@ +#!/bin/bash +# SPDX-License-Identifier: copyleft-next-0.3.1 +# +# If make linux-deploy fails for reasons unrelated to the bug we're tracking +# (e.g., a build error) we bail with exit code 125 to allow git to skip that +# commit. +make linux-deploy || exit 125 diff --git a/workflows/linux/Kconfig b/workflows/linux/Kconfig index 797469e60..b30187c80 100644 --- a/workflows/linux/Kconfig +++ b/workflows/linux/Kconfig @@ -10,6 +10,21 @@ config BOOTLINUX_TREE_REF_SET_BY_CLI output yaml default $(shell, scripts/check-cli-set-var.sh LINUX_TREE_REF) +config BOOTLINUX_BISECT_ENABLE_CLI + bool + output yaml + default $(shell, scripts/check-cli-set-var.sh LINUX_BISECT) + +config BOOTLINUX_BISECT_REF_GOOD_CLI + bool + output yaml + default $(shell, scripts/check-cli-set-var.sh GOOD) + +config BOOTLINUX_BISECT_REF_BAD_CLI + bool + output yaml + default $(shell, scripts/check-cli-set-var.sh BAD) + config BOOTLINUX_HAS_PURE_IOMAP_CONFIG bool @@ -173,7 +188,8 @@ config BOOTLINUX_TREE_CUSTOM_URL config BOOTLINUX_TREE_CUSTOM_REF string "Custom Linux kernel tag or branch to use" - default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI + default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI && !BOOTLINUX_TREE_REF_SET_BY_CLI + default $(shell, ./scripts/append-makefile-vars.sh $(LINUX_TREE_REF)) if BOOTLINUX_TREE_REF_SET_BY_CLI && !BOOTLINUX_BISECT_REF_GOOD_CLI default "master" if !BOOTLINUX_TREE_REF_SET_BY_CLI help The git ID or branch name to check out to compile linux. @@ -278,9 +294,71 @@ config BOOTLINUX_TREE_LOCALVERSION help The Linux local version to use (for uname). +config BOOTLINUX_BISECT_ENABLE + bool "Do you want to bisect a broken kernel?" + default y + depends on BOOTLINUX_9P + output yaml + help + Do you need to automate bisecting some broken kernel? + +if BOOTLINUX_BISECT_ENABLE + +choice + prompt "Bisection script to use" + default BOOTLINUX_BISECT_SCRIPT_BOOT + +config BOOTLINUX_BISECT_SCRIPT_BOOT + bool "Ensures we can at least boot" + help + This helps ensure we can at laest boot into the host. That's it. + +config BOOTLINUX_BISECT_SCRIPT_CUSTOM + bool "You will provide your own bisection script" + help + If you to test a new bisection script you can use this. + +endchoice + +config BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH + string "Custom path to git bisection script to use" + depends on BOOTLINUX_BISECT_SCRIPT_CUSTOM + default "" + output yaml + help + The custom path to the bisect script we will use. Instead of building + the kernel and booting it, 'make linux' will do the bisection + automatically for you based on the script. + +config BOOTLINUX_BISECT_SCRIPT + string + output yaml + default "bisect-boot.sh" if BOOTLINUX_BISECT_SCRIPT_BOOT + default BOOTLINUX_BISECT_SCRIPT_CUSTOM_PATH if BOOTLINUX_BISECT_SCRIPT_BOOT + + +config BOOTLINUX_BISECT_REF_GOOD + string "The last known good commit" + default BOOTLINUX_TREE_REF if !BOOTLINUX_BISECT_REF_GOOD_CLI + default $(shell, ./scripts/append-makefile-vars.sh $(GOOD)) if BOOTLINUX_BISECT_REF_GOOD_CLI + output yaml + help + The known kernel commit to be good. + +config BOOTLINUX_BISECT_REF_BAD + string "The known broken commit" + default BOOTLINUX_TREE_STABLE_REF if !BOOTLINUX_BISECT_REF_BAD_CLI + default $(shell, ./scripts/append-makefile-vars.sh $(BAD)) if BOOTLINUX_BISECT_REF_BAD_CLI + output yaml + help + The first broken tag. + +endif # BOOTLINUX_BISECT_ENABLE + config BOOTLINUX_SHALLOW_CLONE bool "Shallow git clone" default y + depends on !BOOTLINUX_BISECT_ENABLE help If enabled the git tree cloned with be cloned using a shallow tree with history truncated. You want to enable this if you really don't diff --git a/workflows/linux/Makefile b/workflows/linux/Makefile index ecce273a4..00ec13db7 100644 --- a/workflows/linux/Makefile +++ b/workflows/linux/Makefile @@ -104,6 +104,13 @@ linux-mount: --tags vars,9p_mount \ --extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS) +PHONY += linux-bisect +linux-bisect: + $(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \ + $(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \ + --tags vars,bisect \ + --extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS) + PHONY += linux-deploy linux-deploy: $(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \ @@ -176,6 +183,14 @@ linux-help-cxl: LINUX_HELP_EXTRA += linux-help-cxl endif +ifeq (y,$(CONFIG_BOOTLINUX_BISECTION)) +PHONY += linux-help-bisection +linux-help-bisection: + @echo "linux-bisection - Bisects the kernel automatically for you" + +LINUX_HELP_EXTRA += linux-help-bisection +endif + HELP_TARGETS+=linux-help-menu HELP_TARGETS+=$(LINUX_HELP_EXTRA) HELP_TARGETS+=linux-help-end