Skip to contentSkip to conversation

MAINTAINERS: enforce file entries are consistent from meson

PATCH In review Pierrick Bouvier 5 participants 16 messages Jun 15 – Jun 17 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover MAINTAINERS: enforce file entries are consistent from meson

Recently, Markus and Philippe made a great effort [1] to cleanup file entries in MAINTAINERS that do not match any real file.
Now it's clean, we can ensure it will stay consistent in the future, by checking those entries are consistent, directly at start of meson.build. Forcing this through the build system makes sure it can't be skipped, whether on local machine, or in CI. And since anyone needs to trigger it to add tests, doc or code, it will be detected as soon as possible.

[1] https://lore.kernel.org/qemu-devel/[email protected]/

In terms of performance, it takes 0.26s on a slow machine, where full configure takes 35s, thus a slow down < 1%: worth it for the consistency we get IMHO.

The first patch cleans up the latest inconsistent entry left, which we solve pragmatically. Commit mentions another alternative suggested.

The second patch is the check in itself. There was a conversation about comparing files vs list of files returned by git ls-files. I would prefer to stick comparing files instead of playing with regex, but I'm open to implement it another way if that's really important.

The usage is quite simple if you want to play with it manually:
./scripts/check-maintainers-file.py MAINTAINERS

Pierrick Bouvier (2):
MAINTAINERS: fix entry for 'Python scripts' meson.build: check MAINTAINERS file is consistent with source tree

 MAINTAINERS                       |  4 ++-
 meson.build                       |  5 +++
 scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100755 scripts/check-maintainers-file.py
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 MAINTAINERS: fix entry for 'Python scripts'

Existing entry tests/*.py does not match any file at the moment, the semantic is "any py file under tests".
Kernel MAINTAINERS file supports 'K: regexp' entries to match entries, but we don't support it, and I'm not sure it's the right solution here.

Instead of adding "yet another generic solution" to this problem, just add manual entries matching existing sublevels. The Python scripts section is the only one requiring this, and we can always reconsider the
K: approach later if another use case emerge.

---
 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
MAINTAINERS +3 -1
index 2b5b581e173..61af956ed82 100644
@@ -3472,7 +3472,9 @@ M: John Snow <[email protected]>
 M: Cleber Rosa <[email protected]>
 S: Odd Fixes
 F: scripts/*.py
-F: tests/*.py
+F: tests/*/*.py
+F: tests/*/*/*.py
+F: tests/*/*/*/*.py
 
 Benchmark util
 M: Vladimir Sementsov-Ogievskiy <[email protected]>
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/2] MAINTAINERS: fix entry for 'Python scripts'

Quoted 4 lines · Pierrick Bouvier

Existing entry tests/*.py does not match any file at the moment, the semantic is "any py file under tests".
Kernel MAINTAINERS file supports 'K: regexp' entries to match entries, but we don't support it, and I'm not sure it's the right solution here.

I think you mean N:. K: matches file contents. From the kernel's MAINTAINERS file:

N: Files and directories *Regex* patterns.
N: [^a-z]tegra all files whose path contains tegra
(not including files like integrator)
One pattern per line. Multiple N: lines acceptable. scripts/get_maintainer.pl has different behavior for files that match F: pattern and matches of N: patterns. By default, get_maintainer will not look at git log history when an F: pattern match occurs. When an N: match occurs, git log history is used to also notify the people that have git commit signatures.
K: *Content regex* (perl extended) pattern match in a patch or file.
For instance:
K: of_get_profile
matches patches or files that contain "of_get_profile"
K: \b(printk|pr_(info|err))\b
matches patches or files that contain one or more of the words printk, pr_info or pr_err
One regex pattern per line. Multiple K: lines acceptable.

Quoted 4 lines

Instead of adding "yet another generic solution" to this problem, just add manual entries matching existing sublevels. The Python scripts section is the only one requiring this, and we can always reconsider the
K: approach later if another use case emerge.

"Only one" is not correct, because ...

Quoted 11 lines
---
 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
MAINTAINERS +0 -0
index 2b5b581e173..61af956ed82 100644

MAINTAINERS M: John Snow <[email protected]> · line 3477

Quoted 7 lines
MAINTAINERS +3 -1
@@ -3472,7 +3472,9 @@ M: John Snow <[email protected]>
 M: Cleber Rosa <[email protected]>
 S: Odd Fixes
 F: scripts/*.py
-F: tests/*.py
+F: tests/*/*.py
+F: tests/*/*/*.py
+F: tests/*/*/*/*.py

... F: scripts/*.py matches only about a third of the .py under scripts.

I'm not demanding you port over N:, I'm just giving you information :)

The "one F: per directory level" solution is pleasantly stupid, but also somewhat brittle.

Quoted 3 lines
MAINTAINERS +0 -0
 Benchmark util
 M: Vladimir Sementsov-Ogievskiy <[email protected]>
#3 lore raw

Re: [PATCH 1/2] MAINTAINERS: fix entry for 'Python scripts'

Quoted 10 lines · Markus Armbruster
Quoted 4 lines · Pierrick Bouvier

Existing entry tests/*.py does not match any file at the moment, the semantic is "any py file under tests".
Kernel MAINTAINERS file supports 'K: regexp' entries to match entries, but we don't support it, and I'm not sure it's the right solution here.

I think you mean N:. K: matches file contents. From the kernel's MAINTAINERS file:

Oops, you're right indeed.
Sorry for being confused with N: and K:. Surprising given how those single letter names are obvious :).

Quoted 45 lines

N: Files and directories *Regex* patterns.
N: [^a-z]tegra all files whose path contains tegra
(not including files like integrator)
One pattern per line. Multiple N: lines acceptable. scripts/get_maintainer.pl has different behavior for files that match F: pattern and matches of N: patterns. By default, get_maintainer will not look at git log history when an F: pattern match occurs. When an N: match occurs, git log history is used to also notify the people that have git commit signatures.
K: *Content regex* (perl extended) pattern match in a patch or file.
For instance:
K: of_get_profile
matches patches or files that contain "of_get_profile"
K: \b(printk|pr_(info|err))\b
matches patches or files that contain one or more of the words printk, pr_info or pr_err
One regex pattern per line. Multiple K: lines acceptable.

Quoted 4 lines

Instead of adding "yet another generic solution" to this problem, just add manual entries matching existing sublevels. The Python scripts section is the only one requiring this, and we can always reconsider the
K: approach later if another use case emerge.

"Only one" is not correct, because ...

Quoted 11 lines
---
 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
MAINTAINERS +0 -0
index 2b5b581e173..61af956ed82 100644

MAINTAINERS M: John Snow <[email protected]> · line 3477

Quoted 7 lines
MAINTAINERS +3 -1
@@ -3472,7 +3472,9 @@ M: John Snow <[email protected]>
 M: Cleber Rosa <[email protected]>
 S: Odd Fixes
 F: scripts/*.py
-F: tests/*.py
+F: tests/*/*.py
+F: tests/*/*/*.py
+F: tests/*/*/*/*.py

... F: scripts/*.py matches only about a third of the .py under scripts.

Quoted 5 lines

I'm not demanding you port over N:, I'm just giving you information :)

The "one F: per directory level" solution is pleasantly stupid, but also somewhat brittle.

It is, but we need that in a single place, so I'm happy to have to have a stupid *and* simple/explicit solution. Complex+implicit, like in "I need to read the full QEMU doc to find what it does" is where things end up being really stupid IMHO.

Quoted 4 lines
Quoted 3 lines
MAINTAINERS +0 -0
 Benchmark util
 M: Vladimir Sementsov-Ogievskiy <[email protected]>
#4 lore raw

PATCH 2/2 meson.build: check MAINTAINERS file is consistent with source tree

In reply to Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

---
 meson.build                       |  5 +++
 scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100755 scripts/check-maintainers-file.py
meson.build +5 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',
 
 meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
 
+# check our MAINTAINERS file is consistent
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+
 ####################
 # Global variables #
 ####################
scripts/check-maintainers-file.py new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 47 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

---
 meson.build                       |  5 +++
 scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100755 scripts/check-maintainers-file.py
meson.build +5 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',
 
 meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
 
+# check our MAINTAINERS file is consistent
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+
 ####################
 # Global variables #
 ####################
scripts/check-maintainers-file.py new file +6 -0
new file mode 100755
index 00000000000..b001816a401
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Check incorrect file entries in MAINTAINERS
+#
+# Author: Pierrick Bouvier <[email protected]>
+#

scripts/check-maintainers-file.py line 16

Quoted 10 lines
scripts/check-maintainers-file.py new file +10 -0
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import glob
+import sys
+
+
+def check_one_entry(line) -> bool:
+    return True
+

This function is dead code, I'll remove it.

Quoted 37 lines
scripts/check-maintainers-file.py new file +37 -0
+
+def main() -> None:
+    parser = argparse.ArgumentParser(description="Check MAINTAINERS file")
+    parser.add_argument("maintainers", help="Path to MAINTAINERS file")
+    args = parser.parse_args()
+
+    found_file_entry = False
+    found_incorrect_entries = False
+    line_counter = 0
+
+    with open(args.maintainers) as file:
+        for entry in file:
+            line_counter += 1
+
+            if not entry.startswith("F:"):
+                continue
+            entry = entry[2:].strip()
+            found_file_entry = True
+
+            file_exists = len(glob.glob(entry, recursive=True)) > 0
+            if file_exists:
+                continue
+
+            found_incorrect_entries = True
+            print(
+                f"No matching files for {args.maintainers} +{line_counter}: {entry}",
+                file=sys.stderr,
+            )
+
+    if not found_file_entry:
+        raise Exception("no file entry found - is MAINTAINERS path correct?")
+    if found_incorrect_entries:
+        raise Exception(f"incorrect entries found in {args.maintainers}")
+
+
+if __name__ == "__main__":
+    main()
#6 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

In reply to Pierrick Bouvier
Quoted 6 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.

You mention adding/removing but this script only checks for removals, no additions; did I miss something?

Quoted 88 lines

For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

---
  meson.build                       |  5 +++
  scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
  2 files changed, 58 insertions(+)

create mode 100755 scripts/check-maintainers-file.py

meson.build +5 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',
 
  meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
 
+# check our MAINTAINERS file is consistent
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+
  ####################
  # Global variables #
  ####################
scripts/check-maintainers-file.py new file +53 -0
new file mode 100755
index 00000000000..b001816a401
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Check incorrect file entries in MAINTAINERS
+#
+# Author: Pierrick Bouvier <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import glob
+import sys
+
+
+def check_one_entry(line) -> bool:
+    return True
+
+
+def main() -> None:
+    parser = argparse.ArgumentParser(description="Check MAINTAINERS file")
+    parser.add_argument("maintainers", help="Path to MAINTAINERS file")
+    args = parser.parse_args()
+
+    found_file_entry = False
+    found_incorrect_entries = False
+    line_counter = 0
+
+    with open(args.maintainers) as file:
+        for entry in file:
+            line_counter += 1
+
+            if not entry.startswith("F:"):
+                continue
+            entry = entry[2:].strip()
+            found_file_entry = True
+
+            file_exists = len(glob.glob(entry, recursive=True)) > 0
+            if file_exists:
+                continue
+
+            found_incorrect_entries = True
+            print(
+                f"No matching files for {args.maintainers} +{line_counter}: {entry}",
+                file=sys.stderr,
+            )
+
+    if not found_file_entry:
+        raise Exception("no file entry found - is MAINTAINERS path correct?")
+    if found_incorrect_entries:
+        raise Exception(f"incorrect entries found in {args.maintainers}")
+
+
+if __name__ == "__main__":
+    main()
#7 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.

You mention adding/removing but this script only checks for removals, no additions; did I miss something?

The initial scope was only to check the MAINTAINERS file itself is correct. But while we're at it, we could extend the script to check that all files in the tree belong to at least one maintainer entry. This could have the benefit to force coverage for all new files. First we can try to see what is not covered at the moment.

What do you think Markus?

Quoted 93 lines
Quoted 92 lines

For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

---
  meson.build                       |  5 +++ scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++

  2 files changed, 58 insertions(+)

  create mode 100755 scripts/check-maintainers-file.py

meson.build +0 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',

    meson.add_postconf_script(find_program('scripts/symlink-install- tree.py'))
  +# check our MAINTAINERS file is consistent

meson.build +4 -0
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+

  ####################
  # Global variables #
  ####################

scripts/check- renamed from scripts/check-maintainers-file.py +0 -0

maintainers-file.py
new file mode 100755
index 00000000000..b001816a401

scripts/check-maintainers-file.py new file +19 -0
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Check incorrect file entries in MAINTAINERS
+#
+# Author: Pierrick Bouvier <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import glob
+import sys
+
+
+def check_one_entry(line) -> bool:
+    return True
+
+
+def main() -> None:
+    parser = argparse.ArgumentParser(description="Check MAINTAINERS

file")
+    parser.add_argument("maintainers", help="Path to MAINTAINERS file") +    args = parser.parse_args()

scripts/check-maintainers-file.py new file +27 -0
+
+    found_file_entry = False
+    found_incorrect_entries = False
+    line_counter = 0
+
+    with open(args.maintainers) as file:
+        for entry in file:
+            line_counter += 1
+
+            if not entry.startswith("F:"):
+                continue
+            entry = entry[2:].strip()
+            found_file_entry = True
+
+            file_exists = len(glob.glob(entry, recursive=True)) > 0
+            if file_exists:
+                continue
+
+            found_incorrect_entries = True
+            print(
+                f"No matching files for {args.maintainers}
+{line_counter}: {entry}",
+                file=sys.stderr,
+            )
+
+    if not found_file_entry:
+        raise Exception("no file entry found - is MAINTAINERS path

correct?")
+    if found_incorrect_entries:
+        raise Exception(f"incorrect entries found in {args.maintainers}")

scripts/check-maintainers-file.py new file +4 -0
+
+
+if __name__ == "__main__":
+    main()
#8 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 9 lines · Pierrick Bouvier
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.

Quoted 8 lines
Quoted 3 lines

You mention adding/removing but this script only checks for removals, no additions; did I miss something?

The initial scope was only to check the MAINTAINERS file itself is correct. But while we're at it, we could extend the script to check that all files in the tree belong to at least one maintainer entry. This could have the benefit to force coverage for all new files. First we can try to see what is not covered at the moment.

OK. So far removing "adding or" and check_one_entry():

Quoted 97 lines

What do you think Markus?

Quoted 93 lines
Quoted 92 lines

For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

---
   meson.build                       |  5 +++
   scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
   2 files changed, 58 insertions(+)

  create mode 100755 scripts/check-maintainers-file.py

meson.build +4 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',
     meson.add_postconf_script(find_program('scripts/symlink-install-
 tree.py'))
   +# check our MAINTAINERS file is consistent
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+
   ####################
   # Global variables #
   ####################
scripts/check- renamed from scripts/check-maintainers-file.py +0 -0

maintainers-file.py
new file mode 100755
index 00000000000..b001816a401

scripts/check-maintainers-file.py new file +19 -0
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Check incorrect file entries in MAINTAINERS
+#
+# Author: Pierrick Bouvier <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import glob
+import sys
+
+
+def check_one_entry(line) -> bool:
+    return True
+
+
+def main() -> None:
+    parser = argparse.ArgumentParser(description="Check MAINTAINERS

file")
+    parser.add_argument("maintainers", help="Path to MAINTAINERS file") +    args = parser.parse_args()

scripts/check-maintainers-file.py new file +27 -0
+
+    found_file_entry = False
+    found_incorrect_entries = False
+    line_counter = 0
+
+    with open(args.maintainers) as file:
+        for entry in file:
+            line_counter += 1
+
+            if not entry.startswith("F:"):
+                continue
+            entry = entry[2:].strip()
+            found_file_entry = True
+
+            file_exists = len(glob.glob(entry, recursive=True)) > 0
+            if file_exists:
+                continue
+
+            found_incorrect_entries = True
+            print(
+                f"No matching files for {args.maintainers}
+{line_counter}: {entry}",
+                file=sys.stderr,
+            )
+
+    if not found_file_entry:
+        raise Exception("no file entry found - is MAINTAINERS path

correct?")
+    if found_incorrect_entries:
+        raise Exception(f"incorrect entries found in {args.maintainers}")

scripts/check-maintainers-file.py new file +4 -0
+
+
+if __name__ == "__main__":
+    main()
#9 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

In reply to Pierrick Bouvier
Quoted 12 lines · Pierrick Bouvier
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.

You mention adding/removing but this script only checks for removals, no additions; did I miss something?

Quoted 7 lines

The initial scope was only to check the MAINTAINERS file itself is correct. But while we're at it, we could extend the script to check that all files in the tree belong to at least one maintainer entry. This could have the benefit to force coverage for all new files. First we can try to see what is not covered at the moment.

What do you think Markus?

I periodically post a report on MAINTAINERS coverage. The most recent one is for v10.2.0-rc4:

    Subject: Report on MAINTAINERS coverage
    To: [email protected]
    Date: Thu, 18 Dec 2025 13:45:24 +0100
    Message-ID: <[email protected]>
    https://lore.kernel.org/qemu-devel/[email protected]/

We had more than a thousand files not covered then. Getting to 100% coverage would take a big push, and require help from many people.

Even with imperfect coverage, we could still require coverage for all new files. I'm not sure this is practical without at least some targeted MAINTAINERS improvements. Test-drive with a month or three worth of existing commits to see how bad it would have been, to give us an idea on how bad it would be? Or just take the plunge, and revert if it turns out to be bad?

This series tries to solve a smaller problem. Even if we decide we want the bigger problem solved, getting the smaller problem solved sooner is probably better than getting it solved together with the bigger one later.

#10 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 22 lines · Markus Armbruster
Quoted 12 lines · Pierrick Bouvier
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.

You mention adding/removing but this script only checks for removals, no additions; did I miss something?

Quoted 7 lines

The initial scope was only to check the MAINTAINERS file itself is correct. But while we're at it, we could extend the script to check that all files in the tree belong to at least one maintainer entry. This could have the benefit to force coverage for all new files. First we can try to see what is not covered at the moment.

What do you think Markus?

Quoted 9 lines

I periodically post a report on MAINTAINERS coverage. The most recent one is for v10.2.0-rc4:

    Subject: Report on MAINTAINERS coverage
    To: [email protected]
    Date: Thu, 18 Dec 2025 13:45:24 +0100
    Message-ID: <[email protected]>
    https://lore.kernel.org/qemu-devel/[email protected]/

Thanks, I didn't know you were publishing those!

Quoted 10 lines

We had more than a thousand files not covered then. Getting to 100% coverage would take a big push, and require help from many people.

Even with imperfect coverage, we could still require coverage for all new files. I'm not sure this is practical without at least some targeted MAINTAINERS improvements. Test-drive with a month or three worth of existing commits to see how bad it would have been, to give us an idea on how bad it would be? Or just take the plunge, and revert if it turns out to be bad?

Quoted 5 lines

This series tries to solve a smaller problem. Even if we decide we want the bigger problem solved, getting the smaller problem solved sooner is probably better than getting it solved together with the bigger one later.

Right, definitely let's focus on what we have here already.

#11 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

In reply to Pierrick Bouvier
Quoted 11 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

Accuracy of the MAINTAINERS file is an upstream-only concern, but IIUC, this check is going to apply universally to every build of QEMU which is undesirable. It is irrelevant to end users and not appropriate to check in downsteam vendors forks.

In a "normal" modern project this kind of check would be done in a CI job on the merge request, since that's the only place it is relevant. In our case, the nearest fit is the checkpatch.pl file.

Quoted 86 lines
---
 meson.build                       |  5 +++
 scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100755 scripts/check-maintainers-file.py
meson.build +5 -0
index 19e123423b5..57e9c9de42b 100644
@@ -17,6 +17,11 @@ add_test_setup('thorough',
 
 meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
 
+# check our MAINTAINERS file is consistent
+check_maintainers = find_program('scripts/check-maintainers-file.py')
+maintainers_file = files('MAINTAINERS')
+run_command([check_maintainers, maintainers_file], check: true)
+
 ####################
 # Global variables #
 ####################
scripts/check-maintainers-file.py new file +53 -0
new file mode 100755
index 00000000000..b001816a401
@@ -0,0 +1,53 @@
+#! /usr/bin/env python3
+
+# Check incorrect file entries in MAINTAINERS
+#
+# Author: Pierrick Bouvier <[email protected]>
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import argparse
+import glob
+import sys
+
+
+def check_one_entry(line) -> bool:
+    return True
+
+
+def main() -> None:
+    parser = argparse.ArgumentParser(description="Check MAINTAINERS file")
+    parser.add_argument("maintainers", help="Path to MAINTAINERS file")
+    args = parser.parse_args()
+
+    found_file_entry = False
+    found_incorrect_entries = False
+    line_counter = 0
+
+    with open(args.maintainers) as file:
+        for entry in file:
+            line_counter += 1
+
+            if not entry.startswith("F:"):
+                continue
+            entry = entry[2:].strip()
+            found_file_entry = True
+
+            file_exists = len(glob.glob(entry, recursive=True)) > 0
+            if file_exists:
+                continue
+
+            found_incorrect_entries = True
+            print(
+                f"No matching files for {args.maintainers} +{line_counter}: {entry}",
+                file=sys.stderr,
+            )
+
+    if not found_file_entry:
+        raise Exception("no file entry found - is MAINTAINERS path correct?")
+    if found_incorrect_entries:
+        raise Exception(f"incorrect entries found in {args.maintainers}")
+
+
+if __name__ == "__main__":
+    main()
Signature · 1 line
2.43.0

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
#12 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 14 lines · Daniel P. Berrangé
Quoted 11 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

Quoted 8 lines

Accuracy of the MAINTAINERS file is an upstream-only concern, but IIUC, this check is going to apply universally to every build of QEMU which is undesirable. It is irrelevant to end users and not appropriate to check in downsteam vendors forks.

In a "normal" modern project this kind of check would be done in a CI job on the merge request, since that's the only place it is relevant. In our case, the nearest fit is the checkpatch.pl file.

You could put it in "make check", or (if you want to avoid the downstream-forks issue) in some sub-bit of "make check" that we don't check by default but do check in one of our CI jobs.

checkpatch isn't a great place for checks that you want to stay consistent on because so much of its output is "this is wrong/merely something to check, ignore".

-- PMM

#13 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 12 lines · Peter Maydell
Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

Accuracy of the MAINTAINERS file is an upstream-only concern, but IIUC, this check is going to apply universally to every build of QEMU which is undesirable. It is irrelevant to end users and not appropriate to check in downsteam vendors forks.

I accept the argument about downstream forks even though they are free to remove the check since they are... forks.
However, it's relevant to users I think. It's very easy to move a file, and forget to update associated MAINTAINERS entry, and the sooner we catch that, the better. Similar, when a new file is added and not covered by an entry in MAINTAINERS, it's very easy to miss that.

Quoted 3 lines
Quoted 3 lines

In a "normal" modern project this kind of check would be done in a CI job on the merge request, since that's the only place it is relevant. In our case, the nearest fit is the checkpatch.pl file.

It depends how fast you want to catch the problem.
Adding yet another round trip latency to a project that already has a multi day latency for upstream is not a good thing IMHO. Also, it brings yet another burden on top maintainers that will have to deal with this new failure, fix it themselves, or recreate their staging set for the next batch and wait for yet another day. More time spent, more noise, more iteration, just for a missing line update in MAINTAINERS file.

All that is nonexistent if no one can build it if it's incorrect. That's why we use -Werror by default for instance. And if someone sends a patch breaking this, you can be sure they didn't even try to build their own code/doc/test.

Does that open your view on this approach?

Quoted 5 lines

You could put it in "make check", or (if you want to avoid the downstream-forks issue) in some sub-bit of "make check" that we don't check by default but do check in one of our CI jobs.

If argument above is still rejected, we can just add a CI job (calling script directly). I'm not sure any kind of integration is needed. Also, not sure where to fit that in any existing test suite to be honest.

Quoted 4 lines

checkpatch isn't a great place for checks that you want to stay consistent on because so much of its output is "this is wrong/merely something to check, ignore".

I agree, checkpatch is not useful to enforce things. It would be different if it was strictly enforced in CI, but that's not the case, and won't be given the false positives it brings.

Quoted 1 line

-- PMM

Thanks for both of you for the feedback,
Pierrick

#14 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 29 lines · Pierrick Bouvier
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

Accuracy of the MAINTAINERS file is an upstream-only concern, but IIUC, this check is going to apply universally to every build of QEMU which is undesirable. It is irrelevant to end users and not appropriate to check in downsteam vendors forks.

I accept the argument about downstream forks even though they are free to remove the check since they are... forks.
However, it's relevant to users I think. It's very easy to move a file, and forget to update associated MAINTAINERS entry, and the sooner we catch that, the better. Similar, when a new file is added and not covered by an entry in MAINTAINERS, it's very easy to miss that.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

In a "normal" modern project this kind of check would be done in a CI job on the merge request, since that's the only place it is relevant. In our case, the nearest fit is the checkpatch.pl file.

It depends how fast you want to catch the problem.
Adding yet another round trip latency to a project that already has a multi day latency for upstream is not a good thing IMHO.

Yes, and ...

Quoted 5 lines

Also, it brings yet another burden on top maintainers that will have to deal with this new failure, fix it themselves, or recreate their staging set for the next batch and wait for yet another day. More time spent, more noise, more iteration, just for a missing line update in MAINTAINERS file.

... yes.

We might have conditioned ourselves to consider such loops normal. They're not.

Quoted 4 lines

All that is nonexistent if no one can build it if it's incorrect. That's why we use -Werror by default for instance. And if someone sends a patch breaking this, you can be sure they didn't even try to build their own code/doc/test.

I don't want make to fail during development just because I haven't updated MAINTAINERS, yet. It's a distraction that could snap me out of the flow. I'm developing with -Werror disabled for the same reason.

I do want make to fail before I send patches. I do another compile with -Werror enabled then, but that's just my personal workflow.

Solutions I like well enough:

* Make it a compile-time warning that obeys --enable-werror. Could well be more trouble than it's worth.

* Make it fail "make check".

Dislike:

* Make it a checkpatch.pl error. Stays out of my hair during development, but then I have to remember to actually run checkpatch.pl, or risk having CI bouncing things back to me, wasting everybody's time. Meh

* Make it fail CI in some other way. Worse, because now I have to remember running checkpatch.pl *and* that other way.

* Make it fail "make". Stay out of my hair!

Quoted 12 lines

Does that open your view on this approach?

Quoted 5 lines

You could put it in "make check", or (if you want to avoid the downstream-forks issue) in some sub-bit of "make check" that we don't check by default but do check in one of our CI jobs.

If argument above is still rejected, we can just add a CI job (calling script directly). I'm not sure any kind of integration is needed. Also, not sure where to fit that in any existing test suite to be honest.

Quoted 8 lines
Quoted 4 lines

checkpatch isn't a great place for checks that you want to stay consistent on because so much of its output is "this is wrong/merely something to check, ignore".

I agree, checkpatch is not useful to enforce things. It would be different if it was strictly enforced in CI, but that's not the case, and won't be given the false positives it brings.

CI should only reject things that are actually wrong, or at least undesirable.

checkpatch.pl warns when you add, move, or delete files without updating MAINTAINERS. It's only a warning, because MAINTAINERS may in fact not need an update. Not good enough for CI rejects.

The purpose of warnings is to help maintainers and developers find *potential* issues.

Quoted 5 lines
Quoted 2 lines

-- PMM

Thanks for both of you for the feedback,
Pierrick

#15 lore raw

Re: [PATCH 2/2] meson.build: check MAINTAINERS file is consistent with source tree

Quoted 47 lines · Markus Armbruster
Quoted 29 lines · Pierrick Bouvier
Quoted 12 lines · Peter Maydell
Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · Pierrick Bouvier

We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.

We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step.
For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries.

Accuracy of the MAINTAINERS file is an upstream-only concern, but IIUC, this check is going to apply universally to every build of QEMU which is undesirable. It is irrelevant to end users and not appropriate to check in downsteam vendors forks.

I accept the argument about downstream forks even though they are free to remove the check since they are... forks.
However, it's relevant to users I think. It's very easy to move a file, and forget to update associated MAINTAINERS entry, and the sooner we catch that, the better. Similar, when a new file is added and not covered by an entry in MAINTAINERS, it's very easy to miss that.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

In a "normal" modern project this kind of check would be done in a CI job on the merge request, since that's the only place it is relevant. In our case, the nearest fit is the checkpatch.pl file.

It depends how fast you want to catch the problem.
Adding yet another round trip latency to a project that already has a multi day latency for upstream is not a good thing IMHO.

Yes, and ...

Quoted 5 lines

Also, it brings yet another burden on top maintainers that will have to deal with this new failure, fix it themselves, or recreate their staging set for the next batch and wait for yet another day. More time spent, more noise, more iteration, just for a missing line update in MAINTAINERS file.

Quoted 5 lines

... yes.

We might have conditioned ourselves to consider such loops normal. They're not.

You're the first person I read here saying it's not normal, that's refreshing to see some lucidity instead of "It has always been like that/I have my own tempo, suck it up".

Quoted 12 lines
Quoted 4 lines

All that is nonexistent if no one can build it if it's incorrect. That's why we use -Werror by default for instance. And if someone sends a patch breaking this, you can be sure they didn't even try to build their own code/doc/test.

I don't want make to fail during development just because I haven't updated MAINTAINERS, yet. It's a distraction that could snap me out of the flow. I'm developing with -Werror disabled for the same reason.

I do want make to fail before I send patches. I do another compile with -Werror enabled then, but that's just my personal workflow.

Quoted 7 lines

Solutions I like well enough:

* Make it a compile-time warning that obeys --enable-werror. Could well be more trouble than it's worth.

* Make it fail "make check".

This assumes everyone always use make check.

Spoiler: a lot of people, including myself and experimented contributors, sometimes forget it. To be honest, I never run any test/check on my own machine, and just let GitHub do it for me, relentlessly and consistently.

If we take a step back and consider the recent series to fix MAINTAINERS. It was like 40 patches?

I don't know which period of time it covered since last time MAINTAINERS file has been consistent (if it has been one day). But let's say a year at least. So, it means that maybe 3 times in your personal life, when you'll move or remove a file, your flow will be interrupted, and you'll be given a chance to fix things directly instead of hours later. It's very different from -Werror that may hit you more frequently. I'm sure you get more door bells/phone calls interrupting you than this error :).

We can't do anything really consistent out of breaking the build, or break the CI. And break the CI adds latency by design.
Git pre-commit hooks are a good way to deal with that (with formatting also), but we can't enforce any of that unfortunately.

If we choose the CI way, truth is that top maintainers will pay for the cost. I'm not one of them, so can't speak for them, but I feel like solving a problem by narrowing the existing bottleneck is not a good idea.

Quoted 49 lines

Dislike:

* Make it a checkpatch.pl error. Stays out of my hair during development, but then I have to remember to actually run checkpatch.pl, or risk having CI bouncing things back to me, wasting everybody's time. Meh

* Make it fail CI in some other way. Worse, because now I have to remember running checkpatch.pl *and* that other way.

* Make it fail "make". Stay out of my hair!

Quoted 12 lines

Does that open your view on this approach?

Quoted 5 lines

You could put it in "make check", or (if you want to avoid the downstream-forks issue) in some sub-bit of "make check" that we don't check by default but do check in one of our CI jobs.

If argument above is still rejected, we can just add a CI job (calling script directly). I'm not sure any kind of integration is needed. Also, not sure where to fit that in any existing test suite to be honest.

Quoted 8 lines
Quoted 4 lines

checkpatch isn't a great place for checks that you want to stay consistent on because so much of its output is "this is wrong/merely something to check, ignore".

I agree, checkpatch is not useful to enforce things. It would be different if it was strictly enforced in CI, but that's not the case, and won't be given the false positives it brings.

CI should only reject things that are actually wrong, or at least undesirable.

checkpatch.pl warns when you add, move, or delete files without updating MAINTAINERS. It's only a warning, because MAINTAINERS may in fact not need an update. Not good enough for CI rejects.

The purpose of warnings is to help maintainers and developers find *potential* issues.

Quoted 5 lines
Quoted 2 lines

-- PMM

Thanks for both of you for the feedback,
Pierrick