xref: /qemu/docs/devel/submitting-a-patch.rst (revision 9f73de8df0335c9387f4ee39e207a65a1615676f)
1*9f73de8dSKashyap ChamarthySubmitting a Patch
2*9f73de8dSKashyap Chamarthy==================
3*9f73de8dSKashyap Chamarthy
4*9f73de8dSKashyap ChamarthyQEMU welcomes contributions of code (either fixing bugs or adding new
5*9f73de8dSKashyap Chamarthyfunctionality). However, we get a lot of patches, and so we have some
6*9f73de8dSKashyap Chamarthyguidelines about submitting patches. If you follow these, you'll help
7*9f73de8dSKashyap Chamarthymake our task of code review easier and your patch is likely to be
8*9f73de8dSKashyap Chamarthycommitted faster.
9*9f73de8dSKashyap Chamarthy
10*9f73de8dSKashyap ChamarthyThis page seems very long, so if you are only trying to post a quick
11*9f73de8dSKashyap Chamarthyone-shot fix, the bare minimum we ask is that:
12*9f73de8dSKashyap Chamarthy
13*9f73de8dSKashyap Chamarthy-  You **must** provide a Signed-off-by: line (this is a hard
14*9f73de8dSKashyap Chamarthy   requirement because it's how you say "I'm legally okay to contribute
15*9f73de8dSKashyap Chamarthy   this and happy for it to go into QEMU", modeled after the `Linux kernel
16*9f73de8dSKashyap Chamarthy   <http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n297>`__
17*9f73de8dSKashyap Chamarthy   policy.) ``git commit -s`` or ``git format-patch -s`` will add one.
18*9f73de8dSKashyap Chamarthy-  All contributions to QEMU must be **sent as patches** to the
19*9f73de8dSKashyap Chamarthy   qemu-devel `mailing list <MailingLists>`__. Patch contributions
20*9f73de8dSKashyap Chamarthy   should not be posted on the bug tracker, posted on forums, or
21*9f73de8dSKashyap Chamarthy   externally hosted and linked to. (We have other mailing lists too,
22*9f73de8dSKashyap Chamarthy   but all patches must go to qemu-devel, possibly with a Cc: to another
23*9f73de8dSKashyap Chamarthy   list.) ``git send-email`` works best for delivering the patch without
24*9f73de8dSKashyap Chamarthy   mangling it (`hints for setting it
25*9f73de8dSKashyap Chamarthy   up <http://lxr.free-electrons.com/source/Documentation/process/email-clients.rst>`__),
26*9f73de8dSKashyap Chamarthy   but attachments can be used as a last resort on a first-time
27*9f73de8dSKashyap Chamarthy   submission.
28*9f73de8dSKashyap Chamarthy-  You must read replies to your message, and be willing to act on them.
29*9f73de8dSKashyap Chamarthy   Note, however, that maintainers are often willing to manually fix up
30*9f73de8dSKashyap Chamarthy   first-time contributions, since there is a learning curve involved in
31*9f73de8dSKashyap Chamarthy   making an ideal patch submission.
32*9f73de8dSKashyap Chamarthy
33*9f73de8dSKashyap ChamarthyYou do not have to subscribe to post (list policy is to reply-to-all to
34*9f73de8dSKashyap Chamarthypreserve CCs and keep non-subscribers in the loop on the threads they
35*9f73de8dSKashyap Chamarthystart), although you may find it easier as a subscriber to pick up good
36*9f73de8dSKashyap Chamarthyideas from other posts. If you do subscribe, be prepared for a high
37*9f73de8dSKashyap Chamarthyvolume of email, often over one thousand messages in a week. The list is
38*9f73de8dSKashyap Chamarthymoderated; first-time posts from an email address (whether or not you
39*9f73de8dSKashyap Chamarthysubscribed) may be subject to some delay while waiting for a moderator
40*9f73de8dSKashyap Chamarthyto whitelist your address.
41*9f73de8dSKashyap Chamarthy
42*9f73de8dSKashyap ChamarthyThe larger your contribution is, or if you plan on becoming a long-term
43*9f73de8dSKashyap Chamarthycontributor, then the more important the rest of this page becomes.
44*9f73de8dSKashyap ChamarthyReading the table of contents below should already give you an idea of
45*9f73de8dSKashyap Chamarthythe basic requirements. Use the table of contents as a reference, and
46*9f73de8dSKashyap Chamarthyread the parts that you have doubts about.
47*9f73de8dSKashyap Chamarthy
48*9f73de8dSKashyap Chamarthy.. _writing_your_patches:
49*9f73de8dSKashyap Chamarthy
50*9f73de8dSKashyap ChamarthyWriting your Patches
51*9f73de8dSKashyap Chamarthy--------------------
52*9f73de8dSKashyap Chamarthy
53*9f73de8dSKashyap Chamarthy.. _use_the_qemu_coding_style:
54*9f73de8dSKashyap Chamarthy
55*9f73de8dSKashyap ChamarthyUse the QEMU coding style
56*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~
57*9f73de8dSKashyap Chamarthy
58*9f73de8dSKashyap ChamarthyYou can run run *scripts/checkpatch.pl <patchfile>* before submitting to
59*9f73de8dSKashyap Chamarthycheck that you are in compliance with our coding standards. Be aware
60*9f73de8dSKashyap Chamarthythat ``checkpatch.pl`` is not infallible, though, especially where C
61*9f73de8dSKashyap Chamarthypreprocessor macros are involved; use some common sense too. See also:
62*9f73de8dSKashyap Chamarthy
63*9f73de8dSKashyap Chamarthy- `QEMU Coding Style
64*9f73de8dSKashyap Chamarthy  <https://qemu-project.gitlab.io/qemu/devel/style.html>`__
65*9f73de8dSKashyap Chamarthy
66*9f73de8dSKashyap Chamarthy-  `Automate a checkpatch run on
67*9f73de8dSKashyap Chamarthy   commit <http://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html>`__
68*9f73de8dSKashyap Chamarthy
69*9f73de8dSKashyap Chamarthy.. _base_patches_against_current_git_master:
70*9f73de8dSKashyap Chamarthy
71*9f73de8dSKashyap ChamarthyBase patches against current git master
72*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73*9f73de8dSKashyap Chamarthy
74*9f73de8dSKashyap ChamarthyThere's no point submitting a patch which is based on a released version
75*9f73de8dSKashyap Chamarthyof QEMU because development will have moved on from then and it probably
76*9f73de8dSKashyap Chamarthywon't even apply to master. We only apply selected bugfixes to release
77*9f73de8dSKashyap Chamarthybranches and then only as backports once the code has gone into master.
78*9f73de8dSKashyap Chamarthy
79*9f73de8dSKashyap Chamarthy.. _split_up_long_patches:
80*9f73de8dSKashyap Chamarthy
81*9f73de8dSKashyap ChamarthySplit up long patches
82*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~
83*9f73de8dSKashyap Chamarthy
84*9f73de8dSKashyap ChamarthySplit up longer patches into a patch series of logical code changes.
85*9f73de8dSKashyap ChamarthyEach change should compile and execute successfully. For instance, don't
86*9f73de8dSKashyap Chamarthyadd a file to the makefile in patch one and then add the file itself in
87*9f73de8dSKashyap Chamarthypatch two. (This rule is here so that people can later use tools like
88*9f73de8dSKashyap Chamarthy`git bisect <http://git-scm.com/docs/git-bisect>`__ without hitting
89*9f73de8dSKashyap Chamarthypoints in the commit history where QEMU doesn't work for reasons
90*9f73de8dSKashyap Chamarthyunrelated to the bug they're chasing.) Put documentation first, not
91*9f73de8dSKashyap Chamarthylast, so that someone reading the series can do a clean-room evaluation
92*9f73de8dSKashyap Chamarthyof the documentation, then validate that the code matched the
93*9f73de8dSKashyap Chamarthydocumentation. A commit message that mentions "Also, ..." is often a
94*9f73de8dSKashyap Chamarthygood candidate for splitting into multiple patches. For more thoughts on
95*9f73de8dSKashyap Chamarthyproperly splitting patches and writing good commit messages, see `this
96*9f73de8dSKashyap Chamarthyadvice from
97*9f73de8dSKashyap ChamarthyOpenStack <https://wiki.openstack.org/wiki/GitCommitMessages>`__.
98*9f73de8dSKashyap Chamarthy
99*9f73de8dSKashyap Chamarthy.. _make_code_motion_patches_easy_to_review:
100*9f73de8dSKashyap Chamarthy
101*9f73de8dSKashyap ChamarthyMake code motion patches easy to review
102*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103*9f73de8dSKashyap Chamarthy
104*9f73de8dSKashyap ChamarthyIf a series requires large blocks of code motion, there are tricks for
105*9f73de8dSKashyap Chamarthymaking the refactoring easier to review. Split up the series so that
106*9f73de8dSKashyap Chamarthysemantic changes (or even function renames) are done in a separate patch
107*9f73de8dSKashyap Chamarthyfrom the raw code motion. Use a one-time setup of
108*9f73de8dSKashyap Chamarthy``git config diff.renames true; git config diff.algorithm patience``
109*9f73de8dSKashyap Chamarthy(Refer to `git-config <http://git-scm.com/docs/git-config>`__.)  The
110*9f73de8dSKashyap Chamarthy``diff.renames`` property ensures file rename patches will be given in a
111*9f73de8dSKashyap Chamarthymore compact representation that focuses only on the differences across
112*9f73de8dSKashyap Chamarthythe file rename, instead of showing the entire old file as a deletion
113*9f73de8dSKashyap Chamarthyand the new file as an insertion. Meanwhile, the 'diff.algorithm'
114*9f73de8dSKashyap Chamarthyproperty ensures that extracting a non-contiguous subset of one file
115*9f73de8dSKashyap Chamarthyinto a new file, but where all extracted parts occur in the same order
116*9f73de8dSKashyap Chamarthyboth before and after the patch, will reduce churn in trying to treat
117*9f73de8dSKashyap Chamarthyunrelated ``}`` lines in the original file as separating hunks of
118*9f73de8dSKashyap Chamarthychanges.
119*9f73de8dSKashyap Chamarthy
120*9f73de8dSKashyap ChamarthyIdeally, a code motion patch can be reviewed by doing::
121*9f73de8dSKashyap Chamarthy
122*9f73de8dSKashyap Chamarthy    git format-patch --stdout -1 > patch;
123*9f73de8dSKashyap Chamarthy    diff -u <(sed -n 's/^-//p' patch) <(sed -n 's/^\+//p' patch)
124*9f73de8dSKashyap Chamarthy
125*9f73de8dSKashyap Chamarthyto focus on the few changes that weren't wholesale code motion.
126*9f73de8dSKashyap Chamarthy
127*9f73de8dSKashyap Chamarthy.. _dont_include_irrelevant_changes:
128*9f73de8dSKashyap Chamarthy
129*9f73de8dSKashyap ChamarthyDon't include irrelevant changes
130*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131*9f73de8dSKashyap Chamarthy
132*9f73de8dSKashyap ChamarthyIn particular, don't include formatting, coding style or whitespace
133*9f73de8dSKashyap Chamarthychanges to bits of code that would otherwise not be touched by the
134*9f73de8dSKashyap Chamarthypatch. (It's OK to fix coding style issues in the immediate area (few
135*9f73de8dSKashyap Chamarthylines) of the lines you're changing.) If you think a section of code
136*9f73de8dSKashyap Chamarthyreally does need a reindent or other large-scale style fix, submit this
137*9f73de8dSKashyap Chamarthyas a separate patch which makes no semantic changes; don't put it in the
138*9f73de8dSKashyap Chamarthysame patch as your bug fix.
139*9f73de8dSKashyap Chamarthy
140*9f73de8dSKashyap ChamarthyFor smaller patches in less frequently changed areas of QEMU, consider
141*9f73de8dSKashyap Chamarthyusing the `trivial patches process
142*9f73de8dSKashyap Chamarthy<https://qemu-project.gitlab.io/qemu/devel/style.html>`__.
143*9f73de8dSKashyap Chamarthy
144*9f73de8dSKashyap Chamarthy.. _write_a_meaningful_commit_message:
145*9f73de8dSKashyap Chamarthy
146*9f73de8dSKashyap ChamarthyWrite a meaningful commit message
147*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148*9f73de8dSKashyap Chamarthy
149*9f73de8dSKashyap ChamarthyCommit messages should be meaningful and should stand on their own as a
150*9f73de8dSKashyap Chamarthyhistorical record of why the changes you applied were necessary or
151*9f73de8dSKashyap Chamarthyuseful.
152*9f73de8dSKashyap Chamarthy
153*9f73de8dSKashyap ChamarthyQEMU follows the usual standard for git commit messages: the first line
154*9f73de8dSKashyap Chamarthy(which becomes the email subject line) is "subsystem: single line
155*9f73de8dSKashyap Chamarthysummary of change". Whether the "single line summary of change" starts
156*9f73de8dSKashyap Chamarthywith a capital is a matter of taste, but we prefer that the summary does
157*9f73de8dSKashyap Chamarthynot end in ".". Look at ``git shortlog -30`` for an idea of sample
158*9f73de8dSKashyap Chamarthysubject lines. Then there is a blank line and a more detailed
159*9f73de8dSKashyap Chamarthydescription of the patch, another blank and your Signed-off-by: line.
160*9f73de8dSKashyap ChamarthyPlease do not use lines that are longer than 76 characters in your
161*9f73de8dSKashyap Chamarthycommit message (so that the text still shows up nicely with "git show"
162*9f73de8dSKashyap Chamarthyin a 80-columns terminal window).
163*9f73de8dSKashyap Chamarthy
164*9f73de8dSKashyap ChamarthyThe body of the commit message is a good place to document why your
165*9f73de8dSKashyap Chamarthychange is important. Don't include comments like "This is a suggestion
166*9f73de8dSKashyap Chamarthyfor fixing this bug" (they can go below the ``---`` line in the email so
167*9f73de8dSKashyap Chamarthythey don't go into the final commit message). Make sure the body of the
168*9f73de8dSKashyap Chamarthycommit message can be read in isolation even if the reader's mailer
169*9f73de8dSKashyap Chamarthydisplays the subject line some distance apart (that is, a body that
170*9f73de8dSKashyap Chamarthystarts with "... so that" as a continuation of the subject line is
171*9f73de8dSKashyap Chamarthyharder to follow).
172*9f73de8dSKashyap Chamarthy
173*9f73de8dSKashyap Chamarthy.. _submitting_your_patches:
174*9f73de8dSKashyap Chamarthy
175*9f73de8dSKashyap ChamarthySubmitting your Patches
176*9f73de8dSKashyap Chamarthy-----------------------
177*9f73de8dSKashyap Chamarthy
178*9f73de8dSKashyap Chamarthy.. _cc_the_relevant_maintainer:
179*9f73de8dSKashyap Chamarthy
180*9f73de8dSKashyap ChamarthyCC the relevant maintainer
181*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~
182*9f73de8dSKashyap Chamarthy
183*9f73de8dSKashyap ChamarthySend patches both to the mailing list and CC the maintainer(s) of the
184*9f73de8dSKashyap Chamarthyfiles you are modifying. look in the MAINTAINERS file to find out who
185*9f73de8dSKashyap Chamarthythat is. Also try using scripts/get_maintainer.pl from the repository
186*9f73de8dSKashyap Chamarthyfor learning the most common committers for the files you touched.
187*9f73de8dSKashyap Chamarthy
188*9f73de8dSKashyap ChamarthyExample::
189*9f73de8dSKashyap Chamarthy
190*9f73de8dSKashyap Chamarthy    ~/src/qemu/scripts/get_maintainer.pl -f hw/ide/core.c
191*9f73de8dSKashyap Chamarthy
192*9f73de8dSKashyap ChamarthyIn fact, you can automate this, via a one-time setup of ``git config
193*9f73de8dSKashyap Chamarthysendemail.cccmd 'scripts/get_maintainer.pl --nogit-fallback'`` (Refer to
194*9f73de8dSKashyap Chamarthy`git-config <http://git-scm.com/docs/git-config>`__.)
195*9f73de8dSKashyap Chamarthy
196*9f73de8dSKashyap Chamarthy.. _do_not_send_as_an_attachment:
197*9f73de8dSKashyap Chamarthy
198*9f73de8dSKashyap ChamarthyDo not send as an attachment
199*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200*9f73de8dSKashyap Chamarthy
201*9f73de8dSKashyap ChamarthySend patches inline so they are easy to reply to with review comments.
202*9f73de8dSKashyap ChamarthyDo not put patches in attachments.
203*9f73de8dSKashyap Chamarthy
204*9f73de8dSKashyap Chamarthy.. _use_git_format_patch:
205*9f73de8dSKashyap Chamarthy
206*9f73de8dSKashyap ChamarthyUse ``git format-patch``
207*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~
208*9f73de8dSKashyap Chamarthy
209*9f73de8dSKashyap ChamarthyUse the right diff format.
210*9f73de8dSKashyap Chamarthy`git format-patch <http://git-scm.com/docs/git-format-patch>`__ will
211*9f73de8dSKashyap Chamarthyproduce patch emails in the right format (check the documentation to
212*9f73de8dSKashyap Chamarthyfind out how to drive it). You can then edit the cover letter before
213*9f73de8dSKashyap Chamarthyusing ``git send-email`` to mail the files to the mailing list. (We
214*9f73de8dSKashyap Chamarthyrecommend `git send-email <http://git-scm.com/docs/git-send-email>`__
215*9f73de8dSKashyap Chamarthybecause mail clients often mangle patches by wrapping long lines or
216*9f73de8dSKashyap Chamarthymessing up whitespace. Some distributions do not include send-email in a
217*9f73de8dSKashyap Chamarthydefault install of git; you may need to download additional packages,
218*9f73de8dSKashyap Chamarthysuch as 'git-email' on Fedora-based systems.) Patch series need a cover
219*9f73de8dSKashyap Chamarthyletter, with shallow threading (all patches in the series are
220*9f73de8dSKashyap Chamarthyin-reply-to the cover letter, but not to each other); single unrelated
221*9f73de8dSKashyap Chamarthypatches do not need a cover letter (but if you do send a cover letter,
222*9f73de8dSKashyap Chamarthyuse --numbered so the cover and the patch have distinct subject lines).
223*9f73de8dSKashyap ChamarthyPatches are easier to find if they start a new top-level thread, rather
224*9f73de8dSKashyap Chamarthythan being buried in-reply-to another existing thread.
225*9f73de8dSKashyap Chamarthy
226*9f73de8dSKashyap Chamarthy.. _patch_emails_must_include_a_signed_off_by_line:
227*9f73de8dSKashyap Chamarthy
228*9f73de8dSKashyap ChamarthyPatch emails must include a ``Signed-off-by:`` line
229*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230*9f73de8dSKashyap Chamarthy
231*9f73de8dSKashyap ChamarthyFor more information see `1.12) Sign your work
232*9f73de8dSKashyap Chamarthy<http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1b33f0082ac22d71f66385a60d8157f#n296>`__.
233*9f73de8dSKashyap ChamarthyThis is vital or we will not be able to apply your patch! Please use
234*9f73de8dSKashyap Chamarthyyour real name to sign a patch (not an alias or acronym).
235*9f73de8dSKashyap Chamarthy
236*9f73de8dSKashyap ChamarthyIf you wrote the patch, make sure your "From:" and "Signed-off-by:"
237*9f73de8dSKashyap Chamarthylines use the same spelling. It's okay if you subscribe or contribute to
238*9f73de8dSKashyap Chamarthythe list via more than one address, but using multiple addresses in one
239*9f73de8dSKashyap Chamarthycommit just confuses things. If someone else wrote the patch, git will
240*9f73de8dSKashyap Chamarthyinclude a "From:" line in the body of the email (different from your
241*9f73de8dSKashyap Chamarthyenvelope From:) that will give credit to the correct author; but again,
242*9f73de8dSKashyap Chamarthythat author's Signed-off-by: line is mandatory, with the same spelling.
243*9f73de8dSKashyap Chamarthy
244*9f73de8dSKashyap Chamarthy.. _include_a_meaningful_cover_letter:
245*9f73de8dSKashyap Chamarthy
246*9f73de8dSKashyap ChamarthyInclude a meaningful cover letter
247*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248*9f73de8dSKashyap Chamarthy
249*9f73de8dSKashyap ChamarthyThis usually applies only to a series that includes multiple patches;
250*9f73de8dSKashyap Chamarthythe cover letter explains the overall goal of such a series.
251*9f73de8dSKashyap Chamarthy
252*9f73de8dSKashyap ChamarthyWhen reviewers don't know your goal at the start of their review, they
253*9f73de8dSKashyap Chamarthymay object to early changes that don't make sense until the end of the
254*9f73de8dSKashyap Chamarthyseries, because they do not have enough context yet at that point of
255*9f73de8dSKashyap Chamarthytheir review. A series where the goal is unclear also risks a higher
256*9f73de8dSKashyap Chamarthynumber of review-fix cycles because the reviewers haven't bought into
257*9f73de8dSKashyap Chamarthythe idea yet. If the cover letter can explain these points to the
258*9f73de8dSKashyap Chamarthyreviewer, the process will be smoother patches will get merged faster.
259*9f73de8dSKashyap ChamarthyMake sure your cover letter includes a diffstat of changes made over the
260*9f73de8dSKashyap Chamarthyentire series; potential reviewers know what files they are interested
261*9f73de8dSKashyap Chamarthyin, and they need an easy way determine if your series touches them.
262*9f73de8dSKashyap Chamarthy
263*9f73de8dSKashyap Chamarthy.. _use_the_rfc_tag_if_needed:
264*9f73de8dSKashyap Chamarthy
265*9f73de8dSKashyap ChamarthyUse the RFC tag if needed
266*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~
267*9f73de8dSKashyap Chamarthy
268*9f73de8dSKashyap ChamarthyFor example, "[PATCH RFC v2]". ``git format-patch --subject-prefix=RFC``
269*9f73de8dSKashyap Chamarthycan help.
270*9f73de8dSKashyap Chamarthy
271*9f73de8dSKashyap Chamarthy"RFC" means "Request For Comments" and is a statement that you don't
272*9f73de8dSKashyap Chamarthyintend for your patchset to be applied to master, but would like some
273*9f73de8dSKashyap Chamarthyreview on it anyway. Reasons for doing this include:
274*9f73de8dSKashyap Chamarthy
275*9f73de8dSKashyap Chamarthy-  the patch depends on some pending kernel changes which haven't yet
276*9f73de8dSKashyap Chamarthy   been accepted, so the QEMU patch series is blocked until that
277*9f73de8dSKashyap Chamarthy   dependency has been dealt with, but is worth reviewing anyway
278*9f73de8dSKashyap Chamarthy-  the patch set is not finished yet (perhaps it doesn't cover all use
279*9f73de8dSKashyap Chamarthy   cases or work with all targets) but you want early review of a major
280*9f73de8dSKashyap Chamarthy   API change or design structure before continuing
281*9f73de8dSKashyap Chamarthy
282*9f73de8dSKashyap ChamarthyIn general, since it's asking other people to do review work on a
283*9f73de8dSKashyap Chamarthypatchset that the submitter themselves is saying shouldn't be applied,
284*9f73de8dSKashyap Chamarthyit's best to:
285*9f73de8dSKashyap Chamarthy
286*9f73de8dSKashyap Chamarthy-  use it sparingly
287*9f73de8dSKashyap Chamarthy-  in the cover letter, be clear about why a patch is an RFC, what areas
288*9f73de8dSKashyap Chamarthy   of the patchset you're looking for review on, and why reviewers
289*9f73de8dSKashyap Chamarthy   should care
290*9f73de8dSKashyap Chamarthy
291*9f73de8dSKashyap Chamarthy.. _participating_in_code_review:
292*9f73de8dSKashyap Chamarthy
293*9f73de8dSKashyap ChamarthyParticipating in Code Review
294*9f73de8dSKashyap Chamarthy----------------------------
295*9f73de8dSKashyap Chamarthy
296*9f73de8dSKashyap ChamarthyAll patches submitted to the QEMU project go through a code review
297*9f73de8dSKashyap Chamarthyprocess before they are accepted. Some areas of code that are well
298*9f73de8dSKashyap Chamarthymaintained may review patches quickly, lesser-loved areas of code may
299*9f73de8dSKashyap Chamarthyhave a longer delay.
300*9f73de8dSKashyap Chamarthy
301*9f73de8dSKashyap Chamarthy.. _stay_around_to_fix_problems_raised_in_code_review:
302*9f73de8dSKashyap Chamarthy
303*9f73de8dSKashyap ChamarthyStay around to fix problems raised in code review
304*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305*9f73de8dSKashyap Chamarthy
306*9f73de8dSKashyap ChamarthyNot many patches get into QEMU straight away -- it is quite common that
307*9f73de8dSKashyap Chamarthydevelopers will identify bugs, or suggest a cleaner approach, or even
308*9f73de8dSKashyap Chamarthyjust point out code style issues or commit message typos. You'll need to
309*9f73de8dSKashyap Chamarthyrespond to these, and then send a second version of your patches with
310*9f73de8dSKashyap Chamarthythe issues fixed. This takes a little time and effort on your part, but
311*9f73de8dSKashyap Chamarthyif you don't do it then your changes will never get into QEMU. It's also
312*9f73de8dSKashyap Chamarthyjust polite -- it is quite disheartening for a developer to spend time
313*9f73de8dSKashyap Chamarthyreviewing your code and suggesting improvements, only to find that
314*9f73de8dSKashyap Chamarthyyou're not going to do anything further and it was all wasted effort.
315*9f73de8dSKashyap Chamarthy
316*9f73de8dSKashyap ChamarthyWhen replying to comments on your patches **reply to all and not just
317*9f73de8dSKashyap Chamarthythe sender** -- keeping discussion on the mailing list means everybody
318*9f73de8dSKashyap Chamarthycan follow it.
319*9f73de8dSKashyap Chamarthy
320*9f73de8dSKashyap Chamarthy.. _pay_attention_to_review_comments:
321*9f73de8dSKashyap Chamarthy
322*9f73de8dSKashyap ChamarthyPay attention to review comments
323*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324*9f73de8dSKashyap Chamarthy
325*9f73de8dSKashyap ChamarthySomeone took their time to review your work, and it pays to respect that
326*9f73de8dSKashyap Chamarthyeffort; repeatedly submitting a series without addressing all comments
327*9f73de8dSKashyap Chamarthyfrom the previous round tends to alienate reviewers and stall your
328*9f73de8dSKashyap Chamarthypatch. Reviewers aren't always perfect, so it is okay if you want to
329*9f73de8dSKashyap Chamarthyargue that your code was correct in the first place instead of blindly
330*9f73de8dSKashyap Chamarthydoing everything the reviewer asked. On the other hand, if someone
331*9f73de8dSKashyap Chamarthypointed out a potential issue during review, then even if your code
332*9f73de8dSKashyap Chamarthyturns out to be correct, it's probably a sign that you should improve
333*9f73de8dSKashyap Chamarthyyour commit message and/or comments in the code explaining why the code
334*9f73de8dSKashyap Chamarthyis correct.
335*9f73de8dSKashyap Chamarthy
336*9f73de8dSKashyap ChamarthyIf you fix issues that are raised during review **resend the entire
337*9f73de8dSKashyap Chamarthypatch series** not just the one patch that was changed. This allows
338*9f73de8dSKashyap Chamarthymaintainers to easily apply the fixed series without having to manually
339*9f73de8dSKashyap Chamarthyidentify which patches are relevant. Send the new version as a complete
340*9f73de8dSKashyap Chamarthyfresh email or series of emails -- don't try to make it a followup to
341*9f73de8dSKashyap Chamarthyversion 1. (This helps automatic patch email handling tools distinguish
342*9f73de8dSKashyap Chamarthybetween v1 and v2 emails.)
343*9f73de8dSKashyap Chamarthy
344*9f73de8dSKashyap Chamarthy.. _when_resending_patches_add_a_version_tag:
345*9f73de8dSKashyap Chamarthy
346*9f73de8dSKashyap ChamarthyWhen resending patches add a version tag
347*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348*9f73de8dSKashyap Chamarthy
349*9f73de8dSKashyap ChamarthyAll patches beyond the first version should include a version tag -- for
350*9f73de8dSKashyap Chamarthyexample, "[PATCH v2]". This means people can easily identify whether
351*9f73de8dSKashyap Chamarthythey're looking at the most recent version. (The first version of a
352*9f73de8dSKashyap Chamarthypatch need not say "v1", just [PATCH] is sufficient.) For patch series,
353*9f73de8dSKashyap Chamarthythe version applies to the whole series -- even if you only change one
354*9f73de8dSKashyap Chamarthypatch, you resend the entire series and mark it as "v2". Don't try to
355*9f73de8dSKashyap Chamarthytrack versions of different patches in the series separately.  `git
356*9f73de8dSKashyap Chamarthyformat-patch <http://git-scm.com/docs/git-format-patch>`__ and `git
357*9f73de8dSKashyap Chamarthysend-email <http://git-scm.com/docs/git-send-email>`__ both understand
358*9f73de8dSKashyap Chamarthythe ``-v2`` option to make this easier. Send each new revision as a new
359*9f73de8dSKashyap Chamarthytop-level thread, rather than burying it in-reply-to an earlier
360*9f73de8dSKashyap Chamarthyrevision, as many reviewers are not looking inside deep threads for new
361*9f73de8dSKashyap Chamarthypatches.
362*9f73de8dSKashyap Chamarthy
363*9f73de8dSKashyap Chamarthy.. _include_version_history_in_patchset_revisions:
364*9f73de8dSKashyap Chamarthy
365*9f73de8dSKashyap ChamarthyInclude version history in patchset revisions
366*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367*9f73de8dSKashyap Chamarthy
368*9f73de8dSKashyap ChamarthyFor later versions of patches, include a summary of changes from
369*9f73de8dSKashyap Chamarthyprevious versions, but not in the commit message itself. In an email
370*9f73de8dSKashyap Chamarthyformatted as a git patch, the commit message is the part above the "---"
371*9f73de8dSKashyap Chamarthyline, and this will go into the git changelog when the patch is
372*9f73de8dSKashyap Chamarthycommitted. This part should be a self-contained description of what this
373*9f73de8dSKashyap Chamarthyversion of the patch does, written to make sense to anybody who comes
374*9f73de8dSKashyap Chamarthyback to look at this commit in git in six months' time. The part below
375*9f73de8dSKashyap Chamarthythe "---" line and above the patch proper (git format-patch puts the
376*9f73de8dSKashyap Chamarthydiffstat here) is a good place to put remarks for people reading the
377*9f73de8dSKashyap Chamarthypatch email, and this is where the "changes since previous version"
378*9f73de8dSKashyap Chamarthysummary belongs. The
379*9f73de8dSKashyap Chamarthy`git-publish <https://github.com/stefanha/git-publish>`__ script can
380*9f73de8dSKashyap Chamarthyhelp with tracking a good summary across versions. Also, the
381*9f73de8dSKashyap Chamarthy`git-backport-diff <https://github.com/codyprime/git-scripts>`__ script
382*9f73de8dSKashyap Chamarthycan help focus reviewers on what changed between revisions.
383*9f73de8dSKashyap Chamarthy
384*9f73de8dSKashyap Chamarthy.. _tips_and_tricks:
385*9f73de8dSKashyap Chamarthy
386*9f73de8dSKashyap ChamarthyTips and Tricks
387*9f73de8dSKashyap Chamarthy---------------
388*9f73de8dSKashyap Chamarthy
389*9f73de8dSKashyap Chamarthy.. _proper_use_of_reviewed_by_tags_can_aid_review:
390*9f73de8dSKashyap Chamarthy
391*9f73de8dSKashyap ChamarthyProper use of Reviewed-by: tags can aid review
392*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393*9f73de8dSKashyap Chamarthy
394*9f73de8dSKashyap ChamarthyWhen reviewing a large series, a reviewer can reply to some of the
395*9f73de8dSKashyap Chamarthypatches with a Reviewed-by tag, stating that they are happy with that
396*9f73de8dSKashyap Chamarthypatch in isolation (sometimes conditional on minor cleanup, like fixing
397*9f73de8dSKashyap Chamarthywhitespace, that doesn't affect code content). You should then update
398*9f73de8dSKashyap Chamarthythose commit messages by hand to include the Reviewed-by tag, so that in
399*9f73de8dSKashyap Chamarthythe next revision, reviewers can spot which patches were already clean
400*9f73de8dSKashyap Chamarthyfrom the previous round. Conversely, if you significantly modify a patch
401*9f73de8dSKashyap Chamarthythat was previously reviewed, remove the reviewed-by tag out of the
402*9f73de8dSKashyap Chamarthycommit message, as well as listing the changes from the previous
403*9f73de8dSKashyap Chamarthyversion, to make it easier to focus a reviewer's attention to your
404*9f73de8dSKashyap Chamarthychanges.
405*9f73de8dSKashyap Chamarthy
406*9f73de8dSKashyap Chamarthy.. _if_your_patch_seems_to_have_been_ignored:
407*9f73de8dSKashyap Chamarthy
408*9f73de8dSKashyap ChamarthyIf your patch seems to have been ignored
409*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410*9f73de8dSKashyap Chamarthy
411*9f73de8dSKashyap ChamarthyIf your patchset has received no replies you should "ping" it after a
412*9f73de8dSKashyap Chamarthyweek or two, by sending an email as a reply-to-all to the patch mail,
413*9f73de8dSKashyap Chamarthyincluding the word "ping" and ideally also a link to the page for the
414*9f73de8dSKashyap Chamarthypatch on
415*9f73de8dSKashyap Chamarthy`patchwork <http://patchwork.ozlabs.org/project/qemu-devel/list/>`__ or
416*9f73de8dSKashyap ChamarthyGMANE. It's worth double-checking for reasons why your patch might have
417*9f73de8dSKashyap Chamarthybeen ignored (forgot to CC the maintainer? annoyed people by failing to
418*9f73de8dSKashyap Chamarthyrespond to review comments on an earlier version?), but often for
419*9f73de8dSKashyap Chamarthyless-maintained areas of QEMU patches do just slip through the cracks.
420*9f73de8dSKashyap ChamarthyIf your ping is also ignored, ping again after another week or so. As
421*9f73de8dSKashyap Chamarthythe submitter, you are the person with the most motivation to get your
422*9f73de8dSKashyap Chamarthypatch applied, so you have to be persistent.
423*9f73de8dSKashyap Chamarthy
424*9f73de8dSKashyap Chamarthy.. _is_my_patch_in:
425*9f73de8dSKashyap Chamarthy
426*9f73de8dSKashyap ChamarthyIs my patch in?
427*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~
428*9f73de8dSKashyap Chamarthy
429*9f73de8dSKashyap ChamarthyOnce your patch has had enough review on list, the maintainer for that
430*9f73de8dSKashyap Chamarthyarea of code will send notification to the list that they are including
431*9f73de8dSKashyap Chamarthyyour patch in a particular staging branch. Periodically, the maintainer
432*9f73de8dSKashyap Chamarthythen sends a `pull request
433*9f73de8dSKashyap Chamarthy<https://qemu-project.gitlab.io/qemu/devel/submitting-a-pull-request.html>`__
434*9f73de8dSKashyap Chamarthyfor aggregating topic branches into mainline qemu. Generally, you do not
435*9f73de8dSKashyap Chamarthyneed to send a pull request unless you have contributed enough patches
436*9f73de8dSKashyap Chamarthyto become a maintainer over a particular section of code. Maintainers
437*9f73de8dSKashyap Chamarthymay further modify your commit, by resolving simple merge conflicts or
438*9f73de8dSKashyap Chamarthyfixing minor typos pointed out during review, but will always add a
439*9f73de8dSKashyap ChamarthySigned-off-by line in addition to yours, indicating that it went through
440*9f73de8dSKashyap Chamarthytheir tree. Occasionally, the maintainer's pull request may hit more
441*9f73de8dSKashyap Chamarthydifficult merge conflicts, where you may be requested to help rebase and
442*9f73de8dSKashyap Chamarthyresolve the problems. It may take a couple of weeks between when your
443*9f73de8dSKashyap Chamarthypatch first had a positive review to when it finally lands in qemu.git;
444*9f73de8dSKashyap Chamarthyrelease cycle freezes may extend that time even longer.
445*9f73de8dSKashyap Chamarthy
446*9f73de8dSKashyap Chamarthy.. _return_the_favor:
447*9f73de8dSKashyap Chamarthy
448*9f73de8dSKashyap ChamarthyReturn the favor
449*9f73de8dSKashyap Chamarthy~~~~~~~~~~~~~~~~
450*9f73de8dSKashyap Chamarthy
451*9f73de8dSKashyap ChamarthyPeer review only works if everyone chips in a bit of review time. If
452*9f73de8dSKashyap Chamarthyeveryone submitted more patches than they reviewed, we would have a
453*9f73de8dSKashyap Chamarthypatch backlog. A good goal is to try to review at least as many patches
454*9f73de8dSKashyap Chamarthyfrom others as what you submit. Don't worry if you don't know the code
455*9f73de8dSKashyap Chamarthybase as well as a maintainer; it's perfectly fine to admit when your
456*9f73de8dSKashyap Chamarthyreview is weak because you are unfamiliar with the code.
457