Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 1 | .. _submitting-a-patch: |
| 2 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 3 | Submitting a Patch |
| 4 | ================== |
| 5 | |
Alex Bennée | 115847f | 2022-11-17 17:25:24 +0000 | [diff] [blame] | 6 | QEMU welcomes contributions to fix bugs, add functionality or improve |
| 7 | the documentation. However, we get a lot of patches, and so we have |
| 8 | some guidelines about submitting them. If you follow these, you'll |
| 9 | help make our task of contribution review easier and your change is |
| 10 | likely to be accepted and committed faster. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 11 | |
| 12 | This page seems very long, so if you are only trying to post a quick |
| 13 | one-shot fix, the bare minimum we ask is that: |
| 14 | |
Alex Bennée | ca127fe | 2022-11-17 17:25:25 +0000 | [diff] [blame] | 15 | .. list-table:: Minimal Checklist for Patches |
| 16 | :widths: 35 65 |
| 17 | :header-rows: 1 |
| 18 | |
| 19 | * - Check |
| 20 | - Reason |
| 21 | * - Patches contain Signed-off-by: Real Name <author@email> |
| 22 | - States you are legally able to contribute the code. See :ref:`patch_emails_must_include_a_signed_off_by_line` |
| 23 | * - Sent as patch emails to ``qemu-devel@nongnu.org`` |
| 24 | - The project uses an email list based workflow. See :ref:`submitting_your_patches` |
| 25 | * - Be prepared to respond to review comments |
| 26 | - Code that doesn't pass review will not get merged. See :ref:`participating_in_code_review` |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 27 | |
| 28 | You do not have to subscribe to post (list policy is to reply-to-all to |
| 29 | preserve CCs and keep non-subscribers in the loop on the threads they |
| 30 | start), although you may find it easier as a subscriber to pick up good |
| 31 | ideas from other posts. If you do subscribe, be prepared for a high |
| 32 | volume of email, often over one thousand messages in a week. The list is |
| 33 | moderated; first-time posts from an email address (whether or not you |
| 34 | subscribed) may be subject to some delay while waiting for a moderator |
Thomas Huth | 2d2e484 | 2022-07-11 11:53:00 +0200 | [diff] [blame] | 35 | to allow your address. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 36 | |
| 37 | The larger your contribution is, or if you plan on becoming a long-term |
| 38 | contributor, then the more important the rest of this page becomes. |
| 39 | Reading the table of contents below should already give you an idea of |
| 40 | the basic requirements. Use the table of contents as a reference, and |
| 41 | read the parts that you have doubts about. |
| 42 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 43 | .. contents:: Table of Contents |
| 44 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 45 | .. _writing_your_patches: |
| 46 | |
| 47 | Writing your Patches |
| 48 | -------------------- |
| 49 | |
| 50 | .. _use_the_qemu_coding_style: |
| 51 | |
| 52 | Use the QEMU coding style |
| 53 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 54 | |
| 55 | You can run run *scripts/checkpatch.pl <patchfile>* before submitting to |
| 56 | check that you are in compliance with our coding standards. Be aware |
| 57 | that ``checkpatch.pl`` is not infallible, though, especially where C |
| 58 | preprocessor macros are involved; use some common sense too. See also: |
| 59 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 60 | - :ref:`coding-style` |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 61 | - `Automate a checkpatch run on |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 62 | commit <https://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html>`__ |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 63 | |
| 64 | .. _base_patches_against_current_git_master: |
| 65 | |
| 66 | Base patches against current git master |
| 67 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 68 | |
| 69 | There's no point submitting a patch which is based on a released version |
| 70 | of QEMU because development will have moved on from then and it probably |
| 71 | won't even apply to master. We only apply selected bugfixes to release |
| 72 | branches and then only as backports once the code has gone into master. |
| 73 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 74 | It is also okay to base patches on top of other on-going work that is |
| 75 | not yet part of the git master branch. To aid continuous integration |
| 76 | tools, such as `patchew <http://patchew.org/QEMU/>`__, you should `add a |
| 77 | tag <https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg01288.html>`__ |
| 78 | line ``Based-on: $MESSAGE_ID`` to your cover letter to make the series |
| 79 | dependency obvious. |
| 80 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 81 | .. _split_up_long_patches: |
| 82 | |
| 83 | Split up long patches |
| 84 | ~~~~~~~~~~~~~~~~~~~~~ |
| 85 | |
| 86 | Split up longer patches into a patch series of logical code changes. |
| 87 | Each change should compile and execute successfully. For instance, don't |
| 88 | add a file to the makefile in patch one and then add the file itself in |
| 89 | patch two. (This rule is here so that people can later use tools like |
| 90 | `git bisect <http://git-scm.com/docs/git-bisect>`__ without hitting |
| 91 | points in the commit history where QEMU doesn't work for reasons |
| 92 | unrelated to the bug they're chasing.) Put documentation first, not |
| 93 | last, so that someone reading the series can do a clean-room evaluation |
| 94 | of the documentation, then validate that the code matched the |
| 95 | documentation. A commit message that mentions "Also, ..." is often a |
| 96 | good candidate for splitting into multiple patches. For more thoughts on |
| 97 | properly splitting patches and writing good commit messages, see `this |
| 98 | advice from |
| 99 | OpenStack <https://wiki.openstack.org/wiki/GitCommitMessages>`__. |
| 100 | |
| 101 | .. _make_code_motion_patches_easy_to_review: |
| 102 | |
| 103 | Make code motion patches easy to review |
| 104 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 105 | |
| 106 | If a series requires large blocks of code motion, there are tricks for |
| 107 | making the refactoring easier to review. Split up the series so that |
| 108 | semantic changes (or even function renames) are done in a separate patch |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 109 | from the raw code motion. Use a one-time setup of ``git config |
| 110 | diff.renames true;`` ``git config diff.algorithm patience`` (refer to |
| 111 | `git-config <http://git-scm.com/docs/git-config>`__). The 'diff.renames' |
| 112 | property ensures file rename patches will be given in a more compact |
| 113 | representation that focuses only on the differences across the file |
| 114 | rename, instead of showing the entire old file as a deletion and the new |
| 115 | file as an insertion. Meanwhile, the 'diff.algorithm' property ensures |
| 116 | that extracting a non-contiguous subset of one file into a new file, but |
| 117 | where all extracted parts occur in the same order both before and after |
| 118 | the patch, will reduce churn in trying to treat unrelated ``}`` lines in |
| 119 | the original file as separating hunks of changes. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 120 | |
| 121 | Ideally, a code motion patch can be reviewed by doing:: |
| 122 | |
| 123 | git format-patch --stdout -1 > patch; |
| 124 | diff -u <(sed -n 's/^-//p' patch) <(sed -n 's/^\+//p' patch) |
| 125 | |
| 126 | to focus on the few changes that weren't wholesale code motion. |
| 127 | |
| 128 | .. _dont_include_irrelevant_changes: |
| 129 | |
| 130 | Don't include irrelevant changes |
| 131 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 132 | |
| 133 | In particular, don't include formatting, coding style or whitespace |
| 134 | changes to bits of code that would otherwise not be touched by the |
| 135 | patch. (It's OK to fix coding style issues in the immediate area (few |
| 136 | lines) of the lines you're changing.) If you think a section of code |
| 137 | really does need a reindent or other large-scale style fix, submit this |
| 138 | as a separate patch which makes no semantic changes; don't put it in the |
| 139 | same patch as your bug fix. |
| 140 | |
| 141 | For smaller patches in less frequently changed areas of QEMU, consider |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 142 | using the :ref:`trivial-patches` process. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 143 | |
| 144 | .. _write_a_meaningful_commit_message: |
| 145 | |
| 146 | Write a meaningful commit message |
| 147 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 148 | |
| 149 | Commit messages should be meaningful and should stand on their own as a |
| 150 | historical record of why the changes you applied were necessary or |
| 151 | useful. |
| 152 | |
| 153 | QEMU follows the usual standard for git commit messages: the first line |
| 154 | (which becomes the email subject line) is "subsystem: single line |
| 155 | summary of change". Whether the "single line summary of change" starts |
| 156 | with a capital is a matter of taste, but we prefer that the summary does |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 157 | not end in a dot. Look at ``git shortlog -30`` for an idea of sample |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 158 | subject lines. Then there is a blank line and a more detailed |
| 159 | description of the patch, another blank and your Signed-off-by: line. |
| 160 | Please do not use lines that are longer than 76 characters in your |
| 161 | commit message (so that the text still shows up nicely with "git show" |
| 162 | in a 80-columns terminal window). |
| 163 | |
| 164 | The body of the commit message is a good place to document why your |
| 165 | change is important. Don't include comments like "This is a suggestion |
| 166 | for fixing this bug" (they can go below the ``---`` line in the email so |
| 167 | they don't go into the final commit message). Make sure the body of the |
| 168 | commit message can be read in isolation even if the reader's mailer |
| 169 | displays the subject line some distance apart (that is, a body that |
| 170 | starts with "... so that" as a continuation of the subject line is |
| 171 | harder to follow). |
| 172 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 173 | If your patch fixes a commit that is already in the repository, please |
| 174 | add an additional line with "Fixes: <at-least-12-digits-of-SHA-commit-id> |
| 175 | ("Fixed commit subject")" below the patch description / before your |
| 176 | "Signed-off-by:" line in the commit message. |
| 177 | |
| 178 | If your patch fixes a bug in the gitlab bug tracker, please add a line |
| 179 | with "Resolves: <URL-of-the-bug>" to the commit message, too. Gitlab can |
| 180 | close bugs automatically once commits with the "Resolved:" keyword get |
| 181 | merged into the master branch of the project. And if your patch addresses |
| 182 | a bug in another public bug tracker, you can also use a line with |
| 183 | "Buglink: <URL-of-the-bug>" for reference here, too. |
| 184 | |
| 185 | Example:: |
| 186 | |
| 187 | Fixes: 14055ce53c2d ("s390x/tcg: avoid overflows in time2tod/tod2time") |
| 188 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/42 |
| 189 | Buglink: https://bugs.launchpad.net/qemu/+bug/1804323`` |
| 190 | |
Kashyap Chamarthy | 93e86b1 | 2021-11-19 20:31:18 +0100 | [diff] [blame] | 191 | Some other tags that are used in commit messages include "Message-Id:" |
| 192 | "Tested-by:", "Acked-by:", "Reported-by:", "Suggested-by:". See ``git |
| 193 | log`` for these keywords for example usage. |
| 194 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 195 | .. _test_your_patches: |
| 196 | |
| 197 | Test your patches |
| 198 | ~~~~~~~~~~~~~~~~~ |
| 199 | |
Alex Bennée | 7266ecc | 2022-05-27 16:36:03 +0100 | [diff] [blame] | 200 | Although QEMU uses various :ref:`ci` services that attempt to test |
| 201 | patches submitted to the list, it still saves everyone time if you |
| 202 | have already tested that your patch compiles and works. Because QEMU |
| 203 | is such a large project the default configuration won't create a |
| 204 | testing pipeline on GitLab when a branch is pushed. See the :ref:`CI |
| 205 | variable documentation<ci_var>` for details on how to control the |
| 206 | running of tests; but it is still wise to also check that your patches |
| 207 | work with a full build before submitting a series, especially if your |
| 208 | changes might have an unintended effect on other areas of the code you |
| 209 | don't normally experiment with. See :ref:`testing` for more details on |
| 210 | what tests are available. |
| 211 | |
| 212 | Also, it is a wise idea to include a testsuite addition as part of |
| 213 | your patches - either to ensure that future changes won't regress your |
| 214 | new feature, or to add a test which exposes the bug that the rest of |
| 215 | your series fixes. Keeping separate commits for the test and the fix |
| 216 | allows reviewers to rebase the test to occur first to prove it catches |
| 217 | the problem, then again to place it last in the series so that |
| 218 | bisection doesn't land on a known-broken state. |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 219 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 220 | .. _submitting_your_patches: |
| 221 | |
| 222 | Submitting your Patches |
| 223 | ----------------------- |
| 224 | |
Alex Bennée | ca127fe | 2022-11-17 17:25:25 +0000 | [diff] [blame] | 225 | The QEMU project uses a public email based workflow for reviewing and |
| 226 | merging patches. As a result all contributions to QEMU must be **sent |
| 227 | as patches** to the qemu-devel `mailing list |
| 228 | <https://wiki.qemu.org/Contribute/MailingLists>`__. Patch |
| 229 | contributions should not be posted on the bug tracker, posted on |
| 230 | forums, or externally hosted and linked to. (We have other mailing |
| 231 | lists too, but all patches must go to qemu-devel, possibly with a Cc: |
| 232 | to another list.) ``git send-email`` (`step-by-step setup guide |
| 233 | <https://git-send-email.io/>`__ and `hints and tips |
| 234 | <https://elixir.bootlin.com/linux/latest/source/Documentation/process/email-clients.rst>`__) |
| 235 | works best for delivering the patch without mangling it, but |
| 236 | attachments can be used as a last resort on a first-time submission. |
| 237 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 238 | .. _if_you_cannot_send_patch_emails: |
| 239 | |
| 240 | If you cannot send patch emails |
| 241 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 242 | |
| 243 | In rare cases it may not be possible to send properly formatted patch |
| 244 | emails. You can use `sourcehut <https://sourcehut.org/>`__ to send your |
| 245 | patches to the QEMU mailing list by following these steps: |
| 246 | |
| 247 | #. Register or sign in to your account |
| 248 | #. Add your SSH public key in `meta \| |
| 249 | keys <https://meta.sr.ht/keys>`__. |
| 250 | #. Publish your git branch using **git push git@git.sr.ht:~USERNAME/qemu |
| 251 | HEAD** |
| 252 | #. Send your patches to the QEMU mailing list using the web-based |
| 253 | ``git-send-email`` UI at https://git.sr.ht/~USERNAME/qemu/send-email |
| 254 | |
| 255 | `This video |
| 256 | <https://spacepub.space/videos/watch/ad258d23-0ac6-488c-83fc-2bacf578de3a>`__ |
| 257 | shows the web-based ``git-send-email`` workflow. Documentation is |
| 258 | available `here |
| 259 | <https://man.sr.ht/git.sr.ht/#sending-patches-upstream>`__. |
| 260 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 261 | .. _cc_the_relevant_maintainer: |
| 262 | |
| 263 | CC the relevant maintainer |
| 264 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 265 | |
| 266 | Send patches both to the mailing list and CC the maintainer(s) of the |
| 267 | files you are modifying. look in the MAINTAINERS file to find out who |
| 268 | that is. Also try using scripts/get_maintainer.pl from the repository |
| 269 | for learning the most common committers for the files you touched. |
| 270 | |
| 271 | Example:: |
| 272 | |
| 273 | ~/src/qemu/scripts/get_maintainer.pl -f hw/ide/core.c |
| 274 | |
| 275 | In fact, you can automate this, via a one-time setup of ``git config |
| 276 | sendemail.cccmd 'scripts/get_maintainer.pl --nogit-fallback'`` (Refer to |
| 277 | `git-config <http://git-scm.com/docs/git-config>`__.) |
| 278 | |
| 279 | .. _do_not_send_as_an_attachment: |
| 280 | |
| 281 | Do not send as an attachment |
| 282 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 283 | |
| 284 | Send patches inline so they are easy to reply to with review comments. |
| 285 | Do not put patches in attachments. |
| 286 | |
| 287 | .. _use_git_format_patch: |
| 288 | |
| 289 | Use ``git format-patch`` |
| 290 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 291 | |
| 292 | Use the right diff format. |
| 293 | `git format-patch <http://git-scm.com/docs/git-format-patch>`__ will |
| 294 | produce patch emails in the right format (check the documentation to |
| 295 | find out how to drive it). You can then edit the cover letter before |
| 296 | using ``git send-email`` to mail the files to the mailing list. (We |
| 297 | recommend `git send-email <http://git-scm.com/docs/git-send-email>`__ |
| 298 | because mail clients often mangle patches by wrapping long lines or |
| 299 | messing up whitespace. Some distributions do not include send-email in a |
| 300 | default install of git; you may need to download additional packages, |
| 301 | such as 'git-email' on Fedora-based systems.) Patch series need a cover |
| 302 | letter, with shallow threading (all patches in the series are |
| 303 | in-reply-to the cover letter, but not to each other); single unrelated |
| 304 | patches do not need a cover letter (but if you do send a cover letter, |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 305 | use ``--numbered`` so the cover and the patch have distinct subject lines). |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 306 | Patches are easier to find if they start a new top-level thread, rather |
| 307 | than being buried in-reply-to another existing thread. |
| 308 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 309 | .. _avoid_posting_large_binary_blob: |
| 310 | |
| 311 | Avoid posting large binary blob |
| 312 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 313 | |
| 314 | If you added binaries to the repository, consider producing the patch |
| 315 | emails using ``git format-patch --no-binary`` and include a link to a |
| 316 | git repository to fetch the original commit. |
| 317 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 318 | .. _patch_emails_must_include_a_signed_off_by_line: |
| 319 | |
| 320 | Patch emails must include a ``Signed-off-by:`` line |
| 321 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 322 | |
Alex Bennée | ca127fe | 2022-11-17 17:25:25 +0000 | [diff] [blame] | 323 | Your patches **must** include a Signed-off-by: line. This is a hard |
| 324 | requirement because it's how you say "I'm legally okay to contribute |
| 325 | this and happy for it to go into QEMU". The process is modelled after |
| 326 | the `Linux kernel |
| 327 | <http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__ |
| 328 | policy. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 329 | |
| 330 | If you wrote the patch, make sure your "From:" and "Signed-off-by:" |
| 331 | lines use the same spelling. It's okay if you subscribe or contribute to |
| 332 | the list via more than one address, but using multiple addresses in one |
| 333 | commit just confuses things. If someone else wrote the patch, git will |
| 334 | include a "From:" line in the body of the email (different from your |
| 335 | envelope From:) that will give credit to the correct author; but again, |
| 336 | that author's Signed-off-by: line is mandatory, with the same spelling. |
| 337 | |
Alex Bennée | ca127fe | 2022-11-17 17:25:25 +0000 | [diff] [blame] | 338 | There are various tooling options for automatically adding these tags |
| 339 | include using ``git commit -s`` or ``git format-patch -s``. For more |
| 340 | information see `SubmittingPatches 1.12 |
| 341 | <http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__. |
| 342 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 343 | .. _include_a_meaningful_cover_letter: |
| 344 | |
| 345 | Include a meaningful cover letter |
| 346 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 347 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 348 | This is a requirement for any series with multiple patches (as it aids |
| 349 | continuous integration), but optional for an isolated patch. The cover |
| 350 | letter explains the overall goal of such a series, and also provides a |
| 351 | convenient 0/N email for others to reply to the series as a whole. A |
| 352 | one-time setup of ``git config format.coverletter auto`` (refer to |
| 353 | `git-config <http://git-scm.com/docs/git-config>`__) will generate the |
| 354 | cover letter as needed. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 355 | |
| 356 | When reviewers don't know your goal at the start of their review, they |
| 357 | may object to early changes that don't make sense until the end of the |
| 358 | series, because they do not have enough context yet at that point of |
| 359 | their review. A series where the goal is unclear also risks a higher |
| 360 | number of review-fix cycles because the reviewers haven't bought into |
| 361 | the idea yet. If the cover letter can explain these points to the |
| 362 | reviewer, the process will be smoother patches will get merged faster. |
| 363 | Make sure your cover letter includes a diffstat of changes made over the |
| 364 | entire series; potential reviewers know what files they are interested |
| 365 | in, and they need an easy way determine if your series touches them. |
| 366 | |
| 367 | .. _use_the_rfc_tag_if_needed: |
| 368 | |
| 369 | Use the RFC tag if needed |
| 370 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 371 | |
| 372 | For example, "[PATCH RFC v2]". ``git format-patch --subject-prefix=RFC`` |
| 373 | can help. |
| 374 | |
| 375 | "RFC" means "Request For Comments" and is a statement that you don't |
| 376 | intend for your patchset to be applied to master, but would like some |
| 377 | review on it anyway. Reasons for doing this include: |
| 378 | |
| 379 | - the patch depends on some pending kernel changes which haven't yet |
| 380 | been accepted, so the QEMU patch series is blocked until that |
| 381 | dependency has been dealt with, but is worth reviewing anyway |
| 382 | - the patch set is not finished yet (perhaps it doesn't cover all use |
| 383 | cases or work with all targets) but you want early review of a major |
| 384 | API change or design structure before continuing |
| 385 | |
| 386 | In general, since it's asking other people to do review work on a |
| 387 | patchset that the submitter themselves is saying shouldn't be applied, |
| 388 | it's best to: |
| 389 | |
| 390 | - use it sparingly |
| 391 | - in the cover letter, be clear about why a patch is an RFC, what areas |
| 392 | of the patchset you're looking for review on, and why reviewers |
| 393 | should care |
| 394 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 395 | .. _consider_whether_your_patch_is_applicable_for_stable: |
| 396 | |
| 397 | Consider whether your patch is applicable for stable |
| 398 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 399 | |
| 400 | If your patch fixes a severe issue or a regression, it may be applicable |
| 401 | for stable. In that case, consider adding ``Cc: qemu-stable@nongnu.org`` |
| 402 | to your patch to notify the stable maintainers. |
| 403 | |
| 404 | For more details on how QEMU's stable process works, refer to the |
| 405 | :ref:`stable-process` page. |
| 406 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 407 | .. _participating_in_code_review: |
| 408 | |
| 409 | Participating in Code Review |
| 410 | ---------------------------- |
| 411 | |
| 412 | All patches submitted to the QEMU project go through a code review |
Alex Bennée | ca127fe | 2022-11-17 17:25:25 +0000 | [diff] [blame] | 413 | process before they are accepted. This will often mean a series will |
| 414 | go through a number of iterations before being picked up by |
| 415 | :ref:`maintainers<maintainers>`. You therefore should be prepared to |
| 416 | read replies to your messages and be willing to act on them. |
| 417 | |
| 418 | Maintainers are often willing to manually fix up first-time |
| 419 | contributions, since there is a learning curve involved in making an |
| 420 | ideal patch submission. However for the best results you should |
| 421 | proactively respond to suggestions with changes or justifications for |
| 422 | your current approach. |
| 423 | |
| 424 | Some areas of code that are well maintained may review patches |
| 425 | quickly, lesser-loved areas of code may have a longer delay. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 426 | |
| 427 | .. _stay_around_to_fix_problems_raised_in_code_review: |
| 428 | |
| 429 | Stay around to fix problems raised in code review |
| 430 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 431 | |
| 432 | Not many patches get into QEMU straight away -- it is quite common that |
| 433 | developers will identify bugs, or suggest a cleaner approach, or even |
| 434 | just point out code style issues or commit message typos. You'll need to |
| 435 | respond to these, and then send a second version of your patches with |
| 436 | the issues fixed. This takes a little time and effort on your part, but |
Alex Bennée | 73ee4c5 | 2022-11-17 17:25:26 +0000 | [diff] [blame] | 437 | if you don't do it then your changes will never get into QEMU. |
| 438 | |
| 439 | Remember that a maintainer is under no obligation to take your |
| 440 | patches. If someone has spent the time reviewing your code and |
| 441 | suggesting improvements and you simply re-post without either |
| 442 | addressing the comment directly or providing additional justification |
| 443 | for the change then it becomes wasted effort. You cannot demand others |
| 444 | merge and then fix up your code after the fact. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 445 | |
| 446 | When replying to comments on your patches **reply to all and not just |
| 447 | the sender** -- keeping discussion on the mailing list means everybody |
Alex Bennée | 73ee4c5 | 2022-11-17 17:25:26 +0000 | [diff] [blame] | 448 | can follow it. Remember the spirit of the :ref:`code_of_conduct` and |
| 449 | keep discussions respectful and collaborative and avoid making |
| 450 | personal comments. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 451 | |
| 452 | .. _pay_attention_to_review_comments: |
| 453 | |
| 454 | Pay attention to review comments |
| 455 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 456 | |
| 457 | Someone took their time to review your work, and it pays to respect that |
| 458 | effort; repeatedly submitting a series without addressing all comments |
| 459 | from the previous round tends to alienate reviewers and stall your |
| 460 | patch. Reviewers aren't always perfect, so it is okay if you want to |
| 461 | argue that your code was correct in the first place instead of blindly |
| 462 | doing everything the reviewer asked. On the other hand, if someone |
| 463 | pointed out a potential issue during review, then even if your code |
| 464 | turns out to be correct, it's probably a sign that you should improve |
| 465 | your commit message and/or comments in the code explaining why the code |
| 466 | is correct. |
| 467 | |
| 468 | If you fix issues that are raised during review **resend the entire |
| 469 | patch series** not just the one patch that was changed. This allows |
| 470 | maintainers to easily apply the fixed series without having to manually |
| 471 | identify which patches are relevant. Send the new version as a complete |
| 472 | fresh email or series of emails -- don't try to make it a followup to |
| 473 | version 1. (This helps automatic patch email handling tools distinguish |
| 474 | between v1 and v2 emails.) |
| 475 | |
| 476 | .. _when_resending_patches_add_a_version_tag: |
| 477 | |
| 478 | When resending patches add a version tag |
| 479 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 480 | |
| 481 | All patches beyond the first version should include a version tag -- for |
| 482 | example, "[PATCH v2]". This means people can easily identify whether |
| 483 | they're looking at the most recent version. (The first version of a |
| 484 | patch need not say "v1", just [PATCH] is sufficient.) For patch series, |
| 485 | the version applies to the whole series -- even if you only change one |
| 486 | patch, you resend the entire series and mark it as "v2". Don't try to |
| 487 | track versions of different patches in the series separately. `git |
| 488 | format-patch <http://git-scm.com/docs/git-format-patch>`__ and `git |
| 489 | send-email <http://git-scm.com/docs/git-send-email>`__ both understand |
| 490 | the ``-v2`` option to make this easier. Send each new revision as a new |
| 491 | top-level thread, rather than burying it in-reply-to an earlier |
| 492 | revision, as many reviewers are not looking inside deep threads for new |
| 493 | patches. |
| 494 | |
| 495 | .. _include_version_history_in_patchset_revisions: |
| 496 | |
| 497 | Include version history in patchset revisions |
| 498 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 499 | |
| 500 | For later versions of patches, include a summary of changes from |
| 501 | previous versions, but not in the commit message itself. In an email |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 502 | formatted as a git patch, the commit message is the part above the ``---`` |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 503 | line, and this will go into the git changelog when the patch is |
| 504 | committed. This part should be a self-contained description of what this |
| 505 | version of the patch does, written to make sense to anybody who comes |
| 506 | back to look at this commit in git in six months' time. The part below |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 507 | the ``---`` line and above the patch proper (git format-patch puts the |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 508 | diffstat here) is a good place to put remarks for people reading the |
| 509 | patch email, and this is where the "changes since previous version" |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 510 | summary belongs. The `git-publish |
| 511 | <https://github.com/stefanha/git-publish>`__ script can help with |
| 512 | tracking a good summary across versions. Also, the `git-backport-diff |
| 513 | <https://github.com/codyprime/git-scripts>`__ script can help focus |
| 514 | reviewers on what changed between revisions. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 515 | |
| 516 | .. _tips_and_tricks: |
| 517 | |
| 518 | Tips and Tricks |
| 519 | --------------- |
| 520 | |
| 521 | .. _proper_use_of_reviewed_by_tags_can_aid_review: |
| 522 | |
| 523 | Proper use of Reviewed-by: tags can aid review |
| 524 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 525 | |
| 526 | When reviewing a large series, a reviewer can reply to some of the |
| 527 | patches with a Reviewed-by tag, stating that they are happy with that |
| 528 | patch in isolation (sometimes conditional on minor cleanup, like fixing |
| 529 | whitespace, that doesn't affect code content). You should then update |
| 530 | those commit messages by hand to include the Reviewed-by tag, so that in |
| 531 | the next revision, reviewers can spot which patches were already clean |
| 532 | from the previous round. Conversely, if you significantly modify a patch |
| 533 | that was previously reviewed, remove the reviewed-by tag out of the |
| 534 | commit message, as well as listing the changes from the previous |
| 535 | version, to make it easier to focus a reviewer's attention to your |
| 536 | changes. |
| 537 | |
| 538 | .. _if_your_patch_seems_to_have_been_ignored: |
| 539 | |
| 540 | If your patch seems to have been ignored |
| 541 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 542 | |
| 543 | If your patchset has received no replies you should "ping" it after a |
| 544 | week or two, by sending an email as a reply-to-all to the patch mail, |
| 545 | including the word "ping" and ideally also a link to the page for the |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 546 | patch on `patchew <https://patchew.org/QEMU/>`__ or |
| 547 | `lore.kernel.org <https://lore.kernel.org/qemu-devel/>`__. It's worth |
| 548 | double-checking for reasons why your patch might have been ignored |
| 549 | (forgot to CC the maintainer? annoyed people by failing to respond to |
| 550 | review comments on an earlier version?), but often for less-maintained |
| 551 | areas of QEMU patches do just slip through the cracks. If your ping is |
| 552 | also ignored, ping again after another week or so. As the submitter, you |
| 553 | are the person with the most motivation to get your patch applied, so |
| 554 | you have to be persistent. |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 555 | |
| 556 | .. _is_my_patch_in: |
| 557 | |
| 558 | Is my patch in? |
| 559 | ~~~~~~~~~~~~~~~ |
| 560 | |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 561 | QEMU has some Continuous Integration machines that try to catch patch |
| 562 | submission problems as soon as possible. `patchew |
| 563 | <http://patchew.org/QEMU/>`__ includes a web interface for tracking the |
| 564 | status of various threads that have been posted to the list, and may |
| 565 | send you an automated mail if it detected a problem with your patch. |
| 566 | |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 567 | Once your patch has had enough review on list, the maintainer for that |
| 568 | area of code will send notification to the list that they are including |
| 569 | your patch in a particular staging branch. Periodically, the maintainer |
Kashyap Chamarthy | cd6b167 | 2021-11-19 20:31:17 +0100 | [diff] [blame] | 570 | then takes care of :ref:`submitting-a-pull-request` |
| 571 | for aggregating topic branches into mainline QEMU. Generally, you do not |
Kashyap Chamarthy | 9f73de8d | 2021-11-10 15:49:02 +0100 | [diff] [blame] | 572 | need to send a pull request unless you have contributed enough patches |
| 573 | to become a maintainer over a particular section of code. Maintainers |
| 574 | may further modify your commit, by resolving simple merge conflicts or |
| 575 | fixing minor typos pointed out during review, but will always add a |
| 576 | Signed-off-by line in addition to yours, indicating that it went through |
| 577 | their tree. Occasionally, the maintainer's pull request may hit more |
| 578 | difficult merge conflicts, where you may be requested to help rebase and |
| 579 | resolve the problems. It may take a couple of weeks between when your |
| 580 | patch first had a positive review to when it finally lands in qemu.git; |
| 581 | release cycle freezes may extend that time even longer. |
| 582 | |
| 583 | .. _return_the_favor: |
| 584 | |
| 585 | Return the favor |
| 586 | ~~~~~~~~~~~~~~~~ |
| 587 | |
| 588 | Peer review only works if everyone chips in a bit of review time. If |
| 589 | everyone submitted more patches than they reviewed, we would have a |
| 590 | patch backlog. A good goal is to try to review at least as many patches |
| 591 | from others as what you submit. Don't worry if you don't know the code |
| 592 | base as well as a maintainer; it's perfectly fine to admit when your |
| 593 | review is weak because you are unfamiliar with the code. |