1cd6b1674SKashyap Chamarthy.. _submitting-a-patch: 2cd6b1674SKashyap Chamarthy 39f73de8dSKashyap ChamarthySubmitting a Patch 49f73de8dSKashyap Chamarthy================== 59f73de8dSKashyap Chamarthy 69f73de8dSKashyap ChamarthyQEMU welcomes contributions of code (either fixing bugs or adding new 79f73de8dSKashyap Chamarthyfunctionality). However, we get a lot of patches, and so we have some 89f73de8dSKashyap Chamarthyguidelines about submitting patches. If you follow these, you'll help 99f73de8dSKashyap Chamarthymake our task of code review easier and your patch is likely to be 109f73de8dSKashyap Chamarthycommitted faster. 119f73de8dSKashyap Chamarthy 129f73de8dSKashyap ChamarthyThis page seems very long, so if you are only trying to post a quick 139f73de8dSKashyap Chamarthyone-shot fix, the bare minimum we ask is that: 149f73de8dSKashyap Chamarthy 159f73de8dSKashyap Chamarthy- You **must** provide a Signed-off-by: line (this is a hard 169f73de8dSKashyap Chamarthy requirement because it's how you say "I'm legally okay to contribute 179f73de8dSKashyap Chamarthy this and happy for it to go into QEMU", modeled after the `Linux kernel 189f73de8dSKashyap Chamarthy <http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__ 199f73de8dSKashyap Chamarthy policy.) ``git commit -s`` or ``git format-patch -s`` will add one. 209f73de8dSKashyap Chamarthy- All contributions to QEMU must be **sent as patches** to the 2137da3bcfSBernhard Beschow qemu-devel `mailing list <https://wiki.qemu.org/Contribute/MailingLists>`__. 2237da3bcfSBernhard Beschow Patch contributions should not be posted on the bug tracker, posted on 2337da3bcfSBernhard Beschow forums, or externally hosted and linked to. (We have other mailing lists too, 249f73de8dSKashyap Chamarthy but all patches must go to qemu-devel, possibly with a Cc: to another 25cd6b1674SKashyap Chamarthy list.) ``git send-email`` (`step-by-step setup 26cd6b1674SKashyap Chamarthy guide <https://git-send-email.io/>`__ and `hints and 27cd6b1674SKashyap Chamarthy tips <https://elixir.bootlin.com/linux/latest/source/Documentation/process/email-clients.rst>`__) 28cd6b1674SKashyap Chamarthy works best for delivering the patch without mangling it, but 29cd6b1674SKashyap Chamarthy attachments can be used as a last resort on a first-time submission. 309f73de8dSKashyap Chamarthy- You must read replies to your message, and be willing to act on them. 319f73de8dSKashyap Chamarthy Note, however, that maintainers are often willing to manually fix up 329f73de8dSKashyap Chamarthy first-time contributions, since there is a learning curve involved in 339f73de8dSKashyap Chamarthy making an ideal patch submission. 349f73de8dSKashyap Chamarthy 359f73de8dSKashyap ChamarthyYou do not have to subscribe to post (list policy is to reply-to-all to 369f73de8dSKashyap Chamarthypreserve CCs and keep non-subscribers in the loop on the threads they 379f73de8dSKashyap Chamarthystart), although you may find it easier as a subscriber to pick up good 389f73de8dSKashyap Chamarthyideas from other posts. If you do subscribe, be prepared for a high 399f73de8dSKashyap Chamarthyvolume of email, often over one thousand messages in a week. The list is 409f73de8dSKashyap Chamarthymoderated; first-time posts from an email address (whether or not you 419f73de8dSKashyap Chamarthysubscribed) may be subject to some delay while waiting for a moderator 42*2d2e4843SThomas Huthto allow your address. 439f73de8dSKashyap Chamarthy 449f73de8dSKashyap ChamarthyThe larger your contribution is, or if you plan on becoming a long-term 459f73de8dSKashyap Chamarthycontributor, then the more important the rest of this page becomes. 469f73de8dSKashyap ChamarthyReading the table of contents below should already give you an idea of 479f73de8dSKashyap Chamarthythe basic requirements. Use the table of contents as a reference, and 489f73de8dSKashyap Chamarthyread the parts that you have doubts about. 499f73de8dSKashyap Chamarthy 50cd6b1674SKashyap Chamarthy.. contents:: Table of Contents 51cd6b1674SKashyap Chamarthy 529f73de8dSKashyap Chamarthy.. _writing_your_patches: 539f73de8dSKashyap Chamarthy 549f73de8dSKashyap ChamarthyWriting your Patches 559f73de8dSKashyap Chamarthy-------------------- 569f73de8dSKashyap Chamarthy 579f73de8dSKashyap Chamarthy.. _use_the_qemu_coding_style: 589f73de8dSKashyap Chamarthy 599f73de8dSKashyap ChamarthyUse the QEMU coding style 609f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~ 619f73de8dSKashyap Chamarthy 629f73de8dSKashyap ChamarthyYou can run run *scripts/checkpatch.pl <patchfile>* before submitting to 639f73de8dSKashyap Chamarthycheck that you are in compliance with our coding standards. Be aware 649f73de8dSKashyap Chamarthythat ``checkpatch.pl`` is not infallible, though, especially where C 659f73de8dSKashyap Chamarthypreprocessor macros are involved; use some common sense too. See also: 669f73de8dSKashyap Chamarthy 67cd6b1674SKashyap Chamarthy- :ref:`coding-style` 689f73de8dSKashyap Chamarthy- `Automate a checkpatch run on 69cd6b1674SKashyap Chamarthy commit <https://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html>`__ 709f73de8dSKashyap Chamarthy 719f73de8dSKashyap Chamarthy.. _base_patches_against_current_git_master: 729f73de8dSKashyap Chamarthy 739f73de8dSKashyap ChamarthyBase patches against current git master 749f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 759f73de8dSKashyap Chamarthy 769f73de8dSKashyap ChamarthyThere's no point submitting a patch which is based on a released version 779f73de8dSKashyap Chamarthyof QEMU because development will have moved on from then and it probably 789f73de8dSKashyap Chamarthywon't even apply to master. We only apply selected bugfixes to release 799f73de8dSKashyap Chamarthybranches and then only as backports once the code has gone into master. 809f73de8dSKashyap Chamarthy 81cd6b1674SKashyap ChamarthyIt is also okay to base patches on top of other on-going work that is 82cd6b1674SKashyap Chamarthynot yet part of the git master branch. To aid continuous integration 83cd6b1674SKashyap Chamarthytools, such as `patchew <http://patchew.org/QEMU/>`__, you should `add a 84cd6b1674SKashyap Chamarthytag <https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg01288.html>`__ 85cd6b1674SKashyap Chamarthyline ``Based-on: $MESSAGE_ID`` to your cover letter to make the series 86cd6b1674SKashyap Chamarthydependency obvious. 87cd6b1674SKashyap Chamarthy 889f73de8dSKashyap Chamarthy.. _split_up_long_patches: 899f73de8dSKashyap Chamarthy 909f73de8dSKashyap ChamarthySplit up long patches 919f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~ 929f73de8dSKashyap Chamarthy 939f73de8dSKashyap ChamarthySplit up longer patches into a patch series of logical code changes. 949f73de8dSKashyap ChamarthyEach change should compile and execute successfully. For instance, don't 959f73de8dSKashyap Chamarthyadd a file to the makefile in patch one and then add the file itself in 969f73de8dSKashyap Chamarthypatch two. (This rule is here so that people can later use tools like 979f73de8dSKashyap Chamarthy`git bisect <http://git-scm.com/docs/git-bisect>`__ without hitting 989f73de8dSKashyap Chamarthypoints in the commit history where QEMU doesn't work for reasons 999f73de8dSKashyap Chamarthyunrelated to the bug they're chasing.) Put documentation first, not 1009f73de8dSKashyap Chamarthylast, so that someone reading the series can do a clean-room evaluation 1019f73de8dSKashyap Chamarthyof the documentation, then validate that the code matched the 1029f73de8dSKashyap Chamarthydocumentation. A commit message that mentions "Also, ..." is often a 1039f73de8dSKashyap Chamarthygood candidate for splitting into multiple patches. For more thoughts on 1049f73de8dSKashyap Chamarthyproperly splitting patches and writing good commit messages, see `this 1059f73de8dSKashyap Chamarthyadvice from 1069f73de8dSKashyap ChamarthyOpenStack <https://wiki.openstack.org/wiki/GitCommitMessages>`__. 1079f73de8dSKashyap Chamarthy 1089f73de8dSKashyap Chamarthy.. _make_code_motion_patches_easy_to_review: 1099f73de8dSKashyap Chamarthy 1109f73de8dSKashyap ChamarthyMake code motion patches easy to review 1119f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1129f73de8dSKashyap Chamarthy 1139f73de8dSKashyap ChamarthyIf a series requires large blocks of code motion, there are tricks for 1149f73de8dSKashyap Chamarthymaking the refactoring easier to review. Split up the series so that 1159f73de8dSKashyap Chamarthysemantic changes (or even function renames) are done in a separate patch 116cd6b1674SKashyap Chamarthyfrom the raw code motion. Use a one-time setup of ``git config 117cd6b1674SKashyap Chamarthydiff.renames true;`` ``git config diff.algorithm patience`` (refer to 118cd6b1674SKashyap Chamarthy`git-config <http://git-scm.com/docs/git-config>`__). The 'diff.renames' 119cd6b1674SKashyap Chamarthyproperty ensures file rename patches will be given in a more compact 120cd6b1674SKashyap Chamarthyrepresentation that focuses only on the differences across the file 121cd6b1674SKashyap Chamarthyrename, instead of showing the entire old file as a deletion and the new 122cd6b1674SKashyap Chamarthyfile as an insertion. Meanwhile, the 'diff.algorithm' property ensures 123cd6b1674SKashyap Chamarthythat extracting a non-contiguous subset of one file into a new file, but 124cd6b1674SKashyap Chamarthywhere all extracted parts occur in the same order both before and after 125cd6b1674SKashyap Chamarthythe patch, will reduce churn in trying to treat unrelated ``}`` lines in 126cd6b1674SKashyap Chamarthythe original file as separating hunks of changes. 1279f73de8dSKashyap Chamarthy 1289f73de8dSKashyap ChamarthyIdeally, a code motion patch can be reviewed by doing:: 1299f73de8dSKashyap Chamarthy 1309f73de8dSKashyap Chamarthy git format-patch --stdout -1 > patch; 1319f73de8dSKashyap Chamarthy diff -u <(sed -n 's/^-//p' patch) <(sed -n 's/^\+//p' patch) 1329f73de8dSKashyap Chamarthy 1339f73de8dSKashyap Chamarthyto focus on the few changes that weren't wholesale code motion. 1349f73de8dSKashyap Chamarthy 1359f73de8dSKashyap Chamarthy.. _dont_include_irrelevant_changes: 1369f73de8dSKashyap Chamarthy 1379f73de8dSKashyap ChamarthyDon't include irrelevant changes 1389f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1399f73de8dSKashyap Chamarthy 1409f73de8dSKashyap ChamarthyIn particular, don't include formatting, coding style or whitespace 1419f73de8dSKashyap Chamarthychanges to bits of code that would otherwise not be touched by the 1429f73de8dSKashyap Chamarthypatch. (It's OK to fix coding style issues in the immediate area (few 1439f73de8dSKashyap Chamarthylines) of the lines you're changing.) If you think a section of code 1449f73de8dSKashyap Chamarthyreally does need a reindent or other large-scale style fix, submit this 1459f73de8dSKashyap Chamarthyas a separate patch which makes no semantic changes; don't put it in the 1469f73de8dSKashyap Chamarthysame patch as your bug fix. 1479f73de8dSKashyap Chamarthy 1489f73de8dSKashyap ChamarthyFor smaller patches in less frequently changed areas of QEMU, consider 149cd6b1674SKashyap Chamarthyusing the :ref:`trivial-patches` process. 1509f73de8dSKashyap Chamarthy 1519f73de8dSKashyap Chamarthy.. _write_a_meaningful_commit_message: 1529f73de8dSKashyap Chamarthy 1539f73de8dSKashyap ChamarthyWrite a meaningful commit message 1549f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1559f73de8dSKashyap Chamarthy 1569f73de8dSKashyap ChamarthyCommit messages should be meaningful and should stand on their own as a 1579f73de8dSKashyap Chamarthyhistorical record of why the changes you applied were necessary or 1589f73de8dSKashyap Chamarthyuseful. 1599f73de8dSKashyap Chamarthy 1609f73de8dSKashyap ChamarthyQEMU follows the usual standard for git commit messages: the first line 1619f73de8dSKashyap Chamarthy(which becomes the email subject line) is "subsystem: single line 1629f73de8dSKashyap Chamarthysummary of change". Whether the "single line summary of change" starts 1639f73de8dSKashyap Chamarthywith a capital is a matter of taste, but we prefer that the summary does 164cd6b1674SKashyap Chamarthynot end in a dot. Look at ``git shortlog -30`` for an idea of sample 1659f73de8dSKashyap Chamarthysubject lines. Then there is a blank line and a more detailed 1669f73de8dSKashyap Chamarthydescription of the patch, another blank and your Signed-off-by: line. 1679f73de8dSKashyap ChamarthyPlease do not use lines that are longer than 76 characters in your 1689f73de8dSKashyap Chamarthycommit message (so that the text still shows up nicely with "git show" 1699f73de8dSKashyap Chamarthyin a 80-columns terminal window). 1709f73de8dSKashyap Chamarthy 1719f73de8dSKashyap ChamarthyThe body of the commit message is a good place to document why your 1729f73de8dSKashyap Chamarthychange is important. Don't include comments like "This is a suggestion 1739f73de8dSKashyap Chamarthyfor fixing this bug" (they can go below the ``---`` line in the email so 1749f73de8dSKashyap Chamarthythey don't go into the final commit message). Make sure the body of the 1759f73de8dSKashyap Chamarthycommit message can be read in isolation even if the reader's mailer 1769f73de8dSKashyap Chamarthydisplays the subject line some distance apart (that is, a body that 1779f73de8dSKashyap Chamarthystarts with "... so that" as a continuation of the subject line is 1789f73de8dSKashyap Chamarthyharder to follow). 1799f73de8dSKashyap Chamarthy 180cd6b1674SKashyap ChamarthyIf your patch fixes a commit that is already in the repository, please 181cd6b1674SKashyap Chamarthyadd an additional line with "Fixes: <at-least-12-digits-of-SHA-commit-id> 182cd6b1674SKashyap Chamarthy("Fixed commit subject")" below the patch description / before your 183cd6b1674SKashyap Chamarthy"Signed-off-by:" line in the commit message. 184cd6b1674SKashyap Chamarthy 185cd6b1674SKashyap ChamarthyIf your patch fixes a bug in the gitlab bug tracker, please add a line 186cd6b1674SKashyap Chamarthywith "Resolves: <URL-of-the-bug>" to the commit message, too. Gitlab can 187cd6b1674SKashyap Chamarthyclose bugs automatically once commits with the "Resolved:" keyword get 188cd6b1674SKashyap Chamarthymerged into the master branch of the project. And if your patch addresses 189cd6b1674SKashyap Chamarthya bug in another public bug tracker, you can also use a line with 190cd6b1674SKashyap Chamarthy"Buglink: <URL-of-the-bug>" for reference here, too. 191cd6b1674SKashyap Chamarthy 192cd6b1674SKashyap ChamarthyExample:: 193cd6b1674SKashyap Chamarthy 194cd6b1674SKashyap Chamarthy Fixes: 14055ce53c2d ("s390x/tcg: avoid overflows in time2tod/tod2time") 195cd6b1674SKashyap Chamarthy Resolves: https://gitlab.com/qemu-project/qemu/-/issues/42 196cd6b1674SKashyap Chamarthy Buglink: https://bugs.launchpad.net/qemu/+bug/1804323`` 197cd6b1674SKashyap Chamarthy 19893e86b16SKashyap ChamarthySome other tags that are used in commit messages include "Message-Id:" 19993e86b16SKashyap Chamarthy"Tested-by:", "Acked-by:", "Reported-by:", "Suggested-by:". See ``git 20093e86b16SKashyap Chamarthylog`` for these keywords for example usage. 20193e86b16SKashyap Chamarthy 202cd6b1674SKashyap Chamarthy.. _test_your_patches: 203cd6b1674SKashyap Chamarthy 204cd6b1674SKashyap ChamarthyTest your patches 205cd6b1674SKashyap Chamarthy~~~~~~~~~~~~~~~~~ 206cd6b1674SKashyap Chamarthy 2077266ecceSAlex BennéeAlthough QEMU uses various :ref:`ci` services that attempt to test 2087266ecceSAlex Bennéepatches submitted to the list, it still saves everyone time if you 2097266ecceSAlex Bennéehave already tested that your patch compiles and works. Because QEMU 2107266ecceSAlex Bennéeis such a large project the default configuration won't create a 2117266ecceSAlex Bennéetesting pipeline on GitLab when a branch is pushed. See the :ref:`CI 2127266ecceSAlex Bennéevariable documentation<ci_var>` for details on how to control the 2137266ecceSAlex Bennéerunning of tests; but it is still wise to also check that your patches 2147266ecceSAlex Bennéework with a full build before submitting a series, especially if your 2157266ecceSAlex Bennéechanges might have an unintended effect on other areas of the code you 2167266ecceSAlex Bennéedon't normally experiment with. See :ref:`testing` for more details on 2177266ecceSAlex Bennéewhat tests are available. 2187266ecceSAlex Bennée 2197266ecceSAlex BennéeAlso, it is a wise idea to include a testsuite addition as part of 2207266ecceSAlex Bennéeyour patches - either to ensure that future changes won't regress your 2217266ecceSAlex Bennéenew feature, or to add a test which exposes the bug that the rest of 2227266ecceSAlex Bennéeyour series fixes. Keeping separate commits for the test and the fix 2237266ecceSAlex Bennéeallows reviewers to rebase the test to occur first to prove it catches 2247266ecceSAlex Bennéethe problem, then again to place it last in the series so that 2257266ecceSAlex Bennéebisection doesn't land on a known-broken state. 226cd6b1674SKashyap Chamarthy 2279f73de8dSKashyap Chamarthy.. _submitting_your_patches: 2289f73de8dSKashyap Chamarthy 2299f73de8dSKashyap ChamarthySubmitting your Patches 2309f73de8dSKashyap Chamarthy----------------------- 2319f73de8dSKashyap Chamarthy 232cd6b1674SKashyap Chamarthy.. _if_you_cannot_send_patch_emails: 233cd6b1674SKashyap Chamarthy 234cd6b1674SKashyap ChamarthyIf you cannot send patch emails 235cd6b1674SKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 236cd6b1674SKashyap Chamarthy 237cd6b1674SKashyap ChamarthyIn rare cases it may not be possible to send properly formatted patch 238cd6b1674SKashyap Chamarthyemails. You can use `sourcehut <https://sourcehut.org/>`__ to send your 239cd6b1674SKashyap Chamarthypatches to the QEMU mailing list by following these steps: 240cd6b1674SKashyap Chamarthy 241cd6b1674SKashyap Chamarthy#. Register or sign in to your account 242cd6b1674SKashyap Chamarthy#. Add your SSH public key in `meta \| 243cd6b1674SKashyap Chamarthy keys <https://meta.sr.ht/keys>`__. 244cd6b1674SKashyap Chamarthy#. Publish your git branch using **git push git@git.sr.ht:~USERNAME/qemu 245cd6b1674SKashyap Chamarthy HEAD** 246cd6b1674SKashyap Chamarthy#. Send your patches to the QEMU mailing list using the web-based 247cd6b1674SKashyap Chamarthy ``git-send-email`` UI at https://git.sr.ht/~USERNAME/qemu/send-email 248cd6b1674SKashyap Chamarthy 249cd6b1674SKashyap Chamarthy`This video 250cd6b1674SKashyap Chamarthy<https://spacepub.space/videos/watch/ad258d23-0ac6-488c-83fc-2bacf578de3a>`__ 251cd6b1674SKashyap Chamarthyshows the web-based ``git-send-email`` workflow. Documentation is 252cd6b1674SKashyap Chamarthyavailable `here 253cd6b1674SKashyap Chamarthy<https://man.sr.ht/git.sr.ht/#sending-patches-upstream>`__. 254cd6b1674SKashyap Chamarthy 2559f73de8dSKashyap Chamarthy.. _cc_the_relevant_maintainer: 2569f73de8dSKashyap Chamarthy 2579f73de8dSKashyap ChamarthyCC the relevant maintainer 2589f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599f73de8dSKashyap Chamarthy 2609f73de8dSKashyap ChamarthySend patches both to the mailing list and CC the maintainer(s) of the 2619f73de8dSKashyap Chamarthyfiles you are modifying. look in the MAINTAINERS file to find out who 2629f73de8dSKashyap Chamarthythat is. Also try using scripts/get_maintainer.pl from the repository 2639f73de8dSKashyap Chamarthyfor learning the most common committers for the files you touched. 2649f73de8dSKashyap Chamarthy 2659f73de8dSKashyap ChamarthyExample:: 2669f73de8dSKashyap Chamarthy 2679f73de8dSKashyap Chamarthy ~/src/qemu/scripts/get_maintainer.pl -f hw/ide/core.c 2689f73de8dSKashyap Chamarthy 2699f73de8dSKashyap ChamarthyIn fact, you can automate this, via a one-time setup of ``git config 2709f73de8dSKashyap Chamarthysendemail.cccmd 'scripts/get_maintainer.pl --nogit-fallback'`` (Refer to 2719f73de8dSKashyap Chamarthy`git-config <http://git-scm.com/docs/git-config>`__.) 2729f73de8dSKashyap Chamarthy 2739f73de8dSKashyap Chamarthy.. _do_not_send_as_an_attachment: 2749f73de8dSKashyap Chamarthy 2759f73de8dSKashyap ChamarthyDo not send as an attachment 2769f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2779f73de8dSKashyap Chamarthy 2789f73de8dSKashyap ChamarthySend patches inline so they are easy to reply to with review comments. 2799f73de8dSKashyap ChamarthyDo not put patches in attachments. 2809f73de8dSKashyap Chamarthy 2819f73de8dSKashyap Chamarthy.. _use_git_format_patch: 2829f73de8dSKashyap Chamarthy 2839f73de8dSKashyap ChamarthyUse ``git format-patch`` 2849f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~ 2859f73de8dSKashyap Chamarthy 2869f73de8dSKashyap ChamarthyUse the right diff format. 2879f73de8dSKashyap Chamarthy`git format-patch <http://git-scm.com/docs/git-format-patch>`__ will 2889f73de8dSKashyap Chamarthyproduce patch emails in the right format (check the documentation to 2899f73de8dSKashyap Chamarthyfind out how to drive it). You can then edit the cover letter before 2909f73de8dSKashyap Chamarthyusing ``git send-email`` to mail the files to the mailing list. (We 2919f73de8dSKashyap Chamarthyrecommend `git send-email <http://git-scm.com/docs/git-send-email>`__ 2929f73de8dSKashyap Chamarthybecause mail clients often mangle patches by wrapping long lines or 2939f73de8dSKashyap Chamarthymessing up whitespace. Some distributions do not include send-email in a 2949f73de8dSKashyap Chamarthydefault install of git; you may need to download additional packages, 2959f73de8dSKashyap Chamarthysuch as 'git-email' on Fedora-based systems.) Patch series need a cover 2969f73de8dSKashyap Chamarthyletter, with shallow threading (all patches in the series are 2979f73de8dSKashyap Chamarthyin-reply-to the cover letter, but not to each other); single unrelated 2989f73de8dSKashyap Chamarthypatches do not need a cover letter (but if you do send a cover letter, 299cd6b1674SKashyap Chamarthyuse ``--numbered`` so the cover and the patch have distinct subject lines). 3009f73de8dSKashyap ChamarthyPatches are easier to find if they start a new top-level thread, rather 3019f73de8dSKashyap Chamarthythan being buried in-reply-to another existing thread. 3029f73de8dSKashyap Chamarthy 303cd6b1674SKashyap Chamarthy.. _avoid_posting_large_binary_blob: 304cd6b1674SKashyap Chamarthy 305cd6b1674SKashyap ChamarthyAvoid posting large binary blob 306cd6b1674SKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 307cd6b1674SKashyap Chamarthy 308cd6b1674SKashyap ChamarthyIf you added binaries to the repository, consider producing the patch 309cd6b1674SKashyap Chamarthyemails using ``git format-patch --no-binary`` and include a link to a 310cd6b1674SKashyap Chamarthygit repository to fetch the original commit. 311cd6b1674SKashyap Chamarthy 3129f73de8dSKashyap Chamarthy.. _patch_emails_must_include_a_signed_off_by_line: 3139f73de8dSKashyap Chamarthy 3149f73de8dSKashyap ChamarthyPatch emails must include a ``Signed-off-by:`` line 3159f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169f73de8dSKashyap Chamarthy 317cd6b1674SKashyap ChamarthyFor more information see `SubmittingPatches 1.12 318cd6b1674SKashyap Chamarthy<http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__. 3199f73de8dSKashyap ChamarthyThis is vital or we will not be able to apply your patch! Please use 3209f73de8dSKashyap Chamarthyyour real name to sign a patch (not an alias or acronym). 3219f73de8dSKashyap Chamarthy 3229f73de8dSKashyap ChamarthyIf you wrote the patch, make sure your "From:" and "Signed-off-by:" 3239f73de8dSKashyap Chamarthylines use the same spelling. It's okay if you subscribe or contribute to 3249f73de8dSKashyap Chamarthythe list via more than one address, but using multiple addresses in one 3259f73de8dSKashyap Chamarthycommit just confuses things. If someone else wrote the patch, git will 3269f73de8dSKashyap Chamarthyinclude a "From:" line in the body of the email (different from your 3279f73de8dSKashyap Chamarthyenvelope From:) that will give credit to the correct author; but again, 3289f73de8dSKashyap Chamarthythat author's Signed-off-by: line is mandatory, with the same spelling. 3299f73de8dSKashyap Chamarthy 3309f73de8dSKashyap Chamarthy.. _include_a_meaningful_cover_letter: 3319f73de8dSKashyap Chamarthy 3329f73de8dSKashyap ChamarthyInclude a meaningful cover letter 3339f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349f73de8dSKashyap Chamarthy 335cd6b1674SKashyap ChamarthyThis is a requirement for any series with multiple patches (as it aids 336cd6b1674SKashyap Chamarthycontinuous integration), but optional for an isolated patch. The cover 337cd6b1674SKashyap Chamarthyletter explains the overall goal of such a series, and also provides a 338cd6b1674SKashyap Chamarthyconvenient 0/N email for others to reply to the series as a whole. A 339cd6b1674SKashyap Chamarthyone-time setup of ``git config format.coverletter auto`` (refer to 340cd6b1674SKashyap Chamarthy`git-config <http://git-scm.com/docs/git-config>`__) will generate the 341cd6b1674SKashyap Chamarthycover letter as needed. 3429f73de8dSKashyap Chamarthy 3439f73de8dSKashyap ChamarthyWhen reviewers don't know your goal at the start of their review, they 3449f73de8dSKashyap Chamarthymay object to early changes that don't make sense until the end of the 3459f73de8dSKashyap Chamarthyseries, because they do not have enough context yet at that point of 3469f73de8dSKashyap Chamarthytheir review. A series where the goal is unclear also risks a higher 3479f73de8dSKashyap Chamarthynumber of review-fix cycles because the reviewers haven't bought into 3489f73de8dSKashyap Chamarthythe idea yet. If the cover letter can explain these points to the 3499f73de8dSKashyap Chamarthyreviewer, the process will be smoother patches will get merged faster. 3509f73de8dSKashyap ChamarthyMake sure your cover letter includes a diffstat of changes made over the 3519f73de8dSKashyap Chamarthyentire series; potential reviewers know what files they are interested 3529f73de8dSKashyap Chamarthyin, and they need an easy way determine if your series touches them. 3539f73de8dSKashyap Chamarthy 3549f73de8dSKashyap Chamarthy.. _use_the_rfc_tag_if_needed: 3559f73de8dSKashyap Chamarthy 3569f73de8dSKashyap ChamarthyUse the RFC tag if needed 3579f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~ 3589f73de8dSKashyap Chamarthy 3599f73de8dSKashyap ChamarthyFor example, "[PATCH RFC v2]". ``git format-patch --subject-prefix=RFC`` 3609f73de8dSKashyap Chamarthycan help. 3619f73de8dSKashyap Chamarthy 3629f73de8dSKashyap Chamarthy"RFC" means "Request For Comments" and is a statement that you don't 3639f73de8dSKashyap Chamarthyintend for your patchset to be applied to master, but would like some 3649f73de8dSKashyap Chamarthyreview on it anyway. Reasons for doing this include: 3659f73de8dSKashyap Chamarthy 3669f73de8dSKashyap Chamarthy- the patch depends on some pending kernel changes which haven't yet 3679f73de8dSKashyap Chamarthy been accepted, so the QEMU patch series is blocked until that 3689f73de8dSKashyap Chamarthy dependency has been dealt with, but is worth reviewing anyway 3699f73de8dSKashyap Chamarthy- the patch set is not finished yet (perhaps it doesn't cover all use 3709f73de8dSKashyap Chamarthy cases or work with all targets) but you want early review of a major 3719f73de8dSKashyap Chamarthy API change or design structure before continuing 3729f73de8dSKashyap Chamarthy 3739f73de8dSKashyap ChamarthyIn general, since it's asking other people to do review work on a 3749f73de8dSKashyap Chamarthypatchset that the submitter themselves is saying shouldn't be applied, 3759f73de8dSKashyap Chamarthyit's best to: 3769f73de8dSKashyap Chamarthy 3779f73de8dSKashyap Chamarthy- use it sparingly 3789f73de8dSKashyap Chamarthy- in the cover letter, be clear about why a patch is an RFC, what areas 3799f73de8dSKashyap Chamarthy of the patchset you're looking for review on, and why reviewers 3809f73de8dSKashyap Chamarthy should care 3819f73de8dSKashyap Chamarthy 382cd6b1674SKashyap Chamarthy.. _consider_whether_your_patch_is_applicable_for_stable: 383cd6b1674SKashyap Chamarthy 384cd6b1674SKashyap ChamarthyConsider whether your patch is applicable for stable 385cd6b1674SKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 386cd6b1674SKashyap Chamarthy 387cd6b1674SKashyap ChamarthyIf your patch fixes a severe issue or a regression, it may be applicable 388cd6b1674SKashyap Chamarthyfor stable. In that case, consider adding ``Cc: qemu-stable@nongnu.org`` 389cd6b1674SKashyap Chamarthyto your patch to notify the stable maintainers. 390cd6b1674SKashyap Chamarthy 391cd6b1674SKashyap ChamarthyFor more details on how QEMU's stable process works, refer to the 392cd6b1674SKashyap Chamarthy:ref:`stable-process` page. 393cd6b1674SKashyap Chamarthy 3949f73de8dSKashyap Chamarthy.. _participating_in_code_review: 3959f73de8dSKashyap Chamarthy 3969f73de8dSKashyap ChamarthyParticipating in Code Review 3979f73de8dSKashyap Chamarthy---------------------------- 3989f73de8dSKashyap Chamarthy 3999f73de8dSKashyap ChamarthyAll patches submitted to the QEMU project go through a code review 4009f73de8dSKashyap Chamarthyprocess before they are accepted. Some areas of code that are well 4019f73de8dSKashyap Chamarthymaintained may review patches quickly, lesser-loved areas of code may 4029f73de8dSKashyap Chamarthyhave a longer delay. 4039f73de8dSKashyap Chamarthy 4049f73de8dSKashyap Chamarthy.. _stay_around_to_fix_problems_raised_in_code_review: 4059f73de8dSKashyap Chamarthy 4069f73de8dSKashyap ChamarthyStay around to fix problems raised in code review 4079f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4089f73de8dSKashyap Chamarthy 4099f73de8dSKashyap ChamarthyNot many patches get into QEMU straight away -- it is quite common that 4109f73de8dSKashyap Chamarthydevelopers will identify bugs, or suggest a cleaner approach, or even 4119f73de8dSKashyap Chamarthyjust point out code style issues or commit message typos. You'll need to 4129f73de8dSKashyap Chamarthyrespond to these, and then send a second version of your patches with 4139f73de8dSKashyap Chamarthythe issues fixed. This takes a little time and effort on your part, but 4149f73de8dSKashyap Chamarthyif you don't do it then your changes will never get into QEMU. It's also 4159f73de8dSKashyap Chamarthyjust polite -- it is quite disheartening for a developer to spend time 4169f73de8dSKashyap Chamarthyreviewing your code and suggesting improvements, only to find that 4179f73de8dSKashyap Chamarthyyou're not going to do anything further and it was all wasted effort. 4189f73de8dSKashyap Chamarthy 4199f73de8dSKashyap ChamarthyWhen replying to comments on your patches **reply to all and not just 4209f73de8dSKashyap Chamarthythe sender** -- keeping discussion on the mailing list means everybody 4219f73de8dSKashyap Chamarthycan follow it. 4229f73de8dSKashyap Chamarthy 4239f73de8dSKashyap Chamarthy.. _pay_attention_to_review_comments: 4249f73de8dSKashyap Chamarthy 4259f73de8dSKashyap ChamarthyPay attention to review comments 4269f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4279f73de8dSKashyap Chamarthy 4289f73de8dSKashyap ChamarthySomeone took their time to review your work, and it pays to respect that 4299f73de8dSKashyap Chamarthyeffort; repeatedly submitting a series without addressing all comments 4309f73de8dSKashyap Chamarthyfrom the previous round tends to alienate reviewers and stall your 4319f73de8dSKashyap Chamarthypatch. Reviewers aren't always perfect, so it is okay if you want to 4329f73de8dSKashyap Chamarthyargue that your code was correct in the first place instead of blindly 4339f73de8dSKashyap Chamarthydoing everything the reviewer asked. On the other hand, if someone 4349f73de8dSKashyap Chamarthypointed out a potential issue during review, then even if your code 4359f73de8dSKashyap Chamarthyturns out to be correct, it's probably a sign that you should improve 4369f73de8dSKashyap Chamarthyyour commit message and/or comments in the code explaining why the code 4379f73de8dSKashyap Chamarthyis correct. 4389f73de8dSKashyap Chamarthy 4399f73de8dSKashyap ChamarthyIf you fix issues that are raised during review **resend the entire 4409f73de8dSKashyap Chamarthypatch series** not just the one patch that was changed. This allows 4419f73de8dSKashyap Chamarthymaintainers to easily apply the fixed series without having to manually 4429f73de8dSKashyap Chamarthyidentify which patches are relevant. Send the new version as a complete 4439f73de8dSKashyap Chamarthyfresh email or series of emails -- don't try to make it a followup to 4449f73de8dSKashyap Chamarthyversion 1. (This helps automatic patch email handling tools distinguish 4459f73de8dSKashyap Chamarthybetween v1 and v2 emails.) 4469f73de8dSKashyap Chamarthy 4479f73de8dSKashyap Chamarthy.. _when_resending_patches_add_a_version_tag: 4489f73de8dSKashyap Chamarthy 4499f73de8dSKashyap ChamarthyWhen resending patches add a version tag 4509f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4519f73de8dSKashyap Chamarthy 4529f73de8dSKashyap ChamarthyAll patches beyond the first version should include a version tag -- for 4539f73de8dSKashyap Chamarthyexample, "[PATCH v2]". This means people can easily identify whether 4549f73de8dSKashyap Chamarthythey're looking at the most recent version. (The first version of a 4559f73de8dSKashyap Chamarthypatch need not say "v1", just [PATCH] is sufficient.) For patch series, 4569f73de8dSKashyap Chamarthythe version applies to the whole series -- even if you only change one 4579f73de8dSKashyap Chamarthypatch, you resend the entire series and mark it as "v2". Don't try to 4589f73de8dSKashyap Chamarthytrack versions of different patches in the series separately. `git 4599f73de8dSKashyap Chamarthyformat-patch <http://git-scm.com/docs/git-format-patch>`__ and `git 4609f73de8dSKashyap Chamarthysend-email <http://git-scm.com/docs/git-send-email>`__ both understand 4619f73de8dSKashyap Chamarthythe ``-v2`` option to make this easier. Send each new revision as a new 4629f73de8dSKashyap Chamarthytop-level thread, rather than burying it in-reply-to an earlier 4639f73de8dSKashyap Chamarthyrevision, as many reviewers are not looking inside deep threads for new 4649f73de8dSKashyap Chamarthypatches. 4659f73de8dSKashyap Chamarthy 4669f73de8dSKashyap Chamarthy.. _include_version_history_in_patchset_revisions: 4679f73de8dSKashyap Chamarthy 4689f73de8dSKashyap ChamarthyInclude version history in patchset revisions 4699f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4709f73de8dSKashyap Chamarthy 4719f73de8dSKashyap ChamarthyFor later versions of patches, include a summary of changes from 4729f73de8dSKashyap Chamarthyprevious versions, but not in the commit message itself. In an email 473cd6b1674SKashyap Chamarthyformatted as a git patch, the commit message is the part above the ``---`` 4749f73de8dSKashyap Chamarthyline, and this will go into the git changelog when the patch is 4759f73de8dSKashyap Chamarthycommitted. This part should be a self-contained description of what this 4769f73de8dSKashyap Chamarthyversion of the patch does, written to make sense to anybody who comes 4779f73de8dSKashyap Chamarthyback to look at this commit in git in six months' time. The part below 478cd6b1674SKashyap Chamarthythe ``---`` line and above the patch proper (git format-patch puts the 4799f73de8dSKashyap Chamarthydiffstat here) is a good place to put remarks for people reading the 4809f73de8dSKashyap Chamarthypatch email, and this is where the "changes since previous version" 481cd6b1674SKashyap Chamarthysummary belongs. The `git-publish 482cd6b1674SKashyap Chamarthy<https://github.com/stefanha/git-publish>`__ script can help with 483cd6b1674SKashyap Chamarthytracking a good summary across versions. Also, the `git-backport-diff 484cd6b1674SKashyap Chamarthy<https://github.com/codyprime/git-scripts>`__ script can help focus 485cd6b1674SKashyap Chamarthyreviewers on what changed between revisions. 4869f73de8dSKashyap Chamarthy 4879f73de8dSKashyap Chamarthy.. _tips_and_tricks: 4889f73de8dSKashyap Chamarthy 4899f73de8dSKashyap ChamarthyTips and Tricks 4909f73de8dSKashyap Chamarthy--------------- 4919f73de8dSKashyap Chamarthy 4929f73de8dSKashyap Chamarthy.. _proper_use_of_reviewed_by_tags_can_aid_review: 4939f73de8dSKashyap Chamarthy 4949f73de8dSKashyap ChamarthyProper use of Reviewed-by: tags can aid review 4959f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969f73de8dSKashyap Chamarthy 4979f73de8dSKashyap ChamarthyWhen reviewing a large series, a reviewer can reply to some of the 4989f73de8dSKashyap Chamarthypatches with a Reviewed-by tag, stating that they are happy with that 4999f73de8dSKashyap Chamarthypatch in isolation (sometimes conditional on minor cleanup, like fixing 5009f73de8dSKashyap Chamarthywhitespace, that doesn't affect code content). You should then update 5019f73de8dSKashyap Chamarthythose commit messages by hand to include the Reviewed-by tag, so that in 5029f73de8dSKashyap Chamarthythe next revision, reviewers can spot which patches were already clean 5039f73de8dSKashyap Chamarthyfrom the previous round. Conversely, if you significantly modify a patch 5049f73de8dSKashyap Chamarthythat was previously reviewed, remove the reviewed-by tag out of the 5059f73de8dSKashyap Chamarthycommit message, as well as listing the changes from the previous 5069f73de8dSKashyap Chamarthyversion, to make it easier to focus a reviewer's attention to your 5079f73de8dSKashyap Chamarthychanges. 5089f73de8dSKashyap Chamarthy 5099f73de8dSKashyap Chamarthy.. _if_your_patch_seems_to_have_been_ignored: 5109f73de8dSKashyap Chamarthy 5119f73de8dSKashyap ChamarthyIf your patch seems to have been ignored 5129f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5139f73de8dSKashyap Chamarthy 5149f73de8dSKashyap ChamarthyIf your patchset has received no replies you should "ping" it after a 5159f73de8dSKashyap Chamarthyweek or two, by sending an email as a reply-to-all to the patch mail, 5169f73de8dSKashyap Chamarthyincluding the word "ping" and ideally also a link to the page for the 517cd6b1674SKashyap Chamarthypatch on `patchew <https://patchew.org/QEMU/>`__ or 518cd6b1674SKashyap Chamarthy`lore.kernel.org <https://lore.kernel.org/qemu-devel/>`__. It's worth 519cd6b1674SKashyap Chamarthydouble-checking for reasons why your patch might have been ignored 520cd6b1674SKashyap Chamarthy(forgot to CC the maintainer? annoyed people by failing to respond to 521cd6b1674SKashyap Chamarthyreview comments on an earlier version?), but often for less-maintained 522cd6b1674SKashyap Chamarthyareas of QEMU patches do just slip through the cracks. If your ping is 523cd6b1674SKashyap Chamarthyalso ignored, ping again after another week or so. As the submitter, you 524cd6b1674SKashyap Chamarthyare the person with the most motivation to get your patch applied, so 525cd6b1674SKashyap Chamarthyyou have to be persistent. 5269f73de8dSKashyap Chamarthy 5279f73de8dSKashyap Chamarthy.. _is_my_patch_in: 5289f73de8dSKashyap Chamarthy 5299f73de8dSKashyap ChamarthyIs my patch in? 5309f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~ 5319f73de8dSKashyap Chamarthy 532cd6b1674SKashyap ChamarthyQEMU has some Continuous Integration machines that try to catch patch 533cd6b1674SKashyap Chamarthysubmission problems as soon as possible. `patchew 534cd6b1674SKashyap Chamarthy<http://patchew.org/QEMU/>`__ includes a web interface for tracking the 535cd6b1674SKashyap Chamarthystatus of various threads that have been posted to the list, and may 536cd6b1674SKashyap Chamarthysend you an automated mail if it detected a problem with your patch. 537cd6b1674SKashyap Chamarthy 5389f73de8dSKashyap ChamarthyOnce your patch has had enough review on list, the maintainer for that 5399f73de8dSKashyap Chamarthyarea of code will send notification to the list that they are including 5409f73de8dSKashyap Chamarthyyour patch in a particular staging branch. Periodically, the maintainer 541cd6b1674SKashyap Chamarthythen takes care of :ref:`submitting-a-pull-request` 542cd6b1674SKashyap Chamarthyfor aggregating topic branches into mainline QEMU. Generally, you do not 5439f73de8dSKashyap Chamarthyneed to send a pull request unless you have contributed enough patches 5449f73de8dSKashyap Chamarthyto become a maintainer over a particular section of code. Maintainers 5459f73de8dSKashyap Chamarthymay further modify your commit, by resolving simple merge conflicts or 5469f73de8dSKashyap Chamarthyfixing minor typos pointed out during review, but will always add a 5479f73de8dSKashyap ChamarthySigned-off-by line in addition to yours, indicating that it went through 5489f73de8dSKashyap Chamarthytheir tree. Occasionally, the maintainer's pull request may hit more 5499f73de8dSKashyap Chamarthydifficult merge conflicts, where you may be requested to help rebase and 5509f73de8dSKashyap Chamarthyresolve the problems. It may take a couple of weeks between when your 5519f73de8dSKashyap Chamarthypatch first had a positive review to when it finally lands in qemu.git; 5529f73de8dSKashyap Chamarthyrelease cycle freezes may extend that time even longer. 5539f73de8dSKashyap Chamarthy 5549f73de8dSKashyap Chamarthy.. _return_the_favor: 5559f73de8dSKashyap Chamarthy 5569f73de8dSKashyap ChamarthyReturn the favor 5579f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~ 5589f73de8dSKashyap Chamarthy 5599f73de8dSKashyap ChamarthyPeer review only works if everyone chips in a bit of review time. If 5609f73de8dSKashyap Chamarthyeveryone submitted more patches than they reviewed, we would have a 5619f73de8dSKashyap Chamarthypatch backlog. A good goal is to try to review at least as many patches 5629f73de8dSKashyap Chamarthyfrom others as what you submit. Don't worry if you don't know the code 5639f73de8dSKashyap Chamarthybase as well as a maintainer; it's perfectly fine to admit when your 5649f73de8dSKashyap Chamarthyreview is weak because you are unfamiliar with the code. 565