1bcd562e2SSamuel Ortiz# Contributing to Cloud Hypervisor 2bcd562e2SSamuel Ortiz 3e78c0584SRob BradfordCloud Hypervisor is an open source project licensed under the [Apache v2 4e78c0584SRob BradfordLicense](https://opensource.org/licenses/Apache-2.0) and the [BSD 3 55e7a77e5SRob BradfordClause](https://opensource.org/licenses/BSD-3-Clause) license. Individual files 65e7a77e5SRob Bradfordcontain details of their licensing and changes to that file are under the same 75e7a77e5SRob Bradfordlicense unless the contribution changes the license of the file. When importing 87bf0cc1eSPhilipp Schustercode from a third party project (e.g. Firecracker or crosvm) please respect the 95e7a77e5SRob Bradfordlicense of those projects. 105e7a77e5SRob Bradford 115e7a77e5SRob BradfordNew code should be under the [Apache v2 125e7a77e5SRob BradfordLicense](https://opensource.org/licenses/Apache-2.0). 13bcd562e2SSamuel Ortiz 14bcd562e2SSamuel Ortiz## Coding Style 15bcd562e2SSamuel Ortiz 16*e3e83362SRuoqing HeWe follow the [Rust Style](https://github.com/rust-lang/rust/tree/HEAD/src/doc/style-guide/src) 17bcd562e2SSamuel Ortizconvention and enforce it through the Continuous Integration (CI) process calling into `rustfmt` 18bcd562e2SSamuel Ortizfor each submitted Pull Request (PR). 19bcd562e2SSamuel Ortiz 20041acf2aSRob Bradford## Basic Checks 21041acf2aSRob Bradford 22041acf2aSRob BradfordPlease consider creating the following hook as `.git/hooks/pre-commit` in order 23041acf2aSRob Bradfordto ensure basic correctness of your code. You can extend this further if you 24041acf2aSRob Bradfordhave specific features that you regularly develop against. 25041acf2aSRob Bradford 26041acf2aSRob Bradford```sh 27041acf2aSRob Bradford#!/bin/sh 28041acf2aSRob Bradford 29041acf2aSRob Bradfordcargo fmt -- --check || exit 1 30041acf2aSRob Bradfordcargo check --locked --all --all-targets --tests || exit 1 31041acf2aSRob Bradfordcargo clippy --locked --all --all-targets --tests -- -D warnings || exit 1 32041acf2aSRob Bradford``` 33041acf2aSRob Bradford 34041acf2aSRob BradfordYou will need to `chmod +x .git/hooks/pre-commit` to have it run on every 35041acf2aSRob Bradfordcommit you make. 36041acf2aSRob Bradford 37bcd562e2SSamuel Ortiz## Certificate of Origin 38bcd562e2SSamuel Ortiz 39*e3e83362SRuoqing HeIn order to get a clear contribution chain of trust we use the [signed-off-by language](https://web.archive.org/web/20230406041855/https://01.org/community/signed-process) 40bcd562e2SSamuel Ortizused by the Linux kernel project. 41bcd562e2SSamuel Ortiz 42bcd562e2SSamuel Ortiz## Patch format 43bcd562e2SSamuel Ortiz 44bcd562e2SSamuel OrtizBeside the signed-off-by footer, we expect each patch to comply with the following format: 45bcd562e2SSamuel Ortiz 46bcd562e2SSamuel Ortiz``` 47bcd562e2SSamuel Ortiz<component>: Change summary 48bcd562e2SSamuel Ortiz 49bcd562e2SSamuel OrtizMore detailed explanation of your changes: Why and how. 50bcd562e2SSamuel OrtizWrap it to 72 characters. 51bcd562e2SSamuel OrtizSee http://chris.beams.io/posts/git-commit/ 52bcd562e2SSamuel Ortizfor some more good pieces of advice. 53bcd562e2SSamuel Ortiz 54bcd562e2SSamuel OrtizSigned-off-by: <contributor@foo.com> 55bcd562e2SSamuel Ortiz``` 56bcd562e2SSamuel Ortiz 57bcd562e2SSamuel OrtizFor example: 58bcd562e2SSamuel Ortiz 59bcd562e2SSamuel Ortiz``` 60bcd562e2SSamuel Ortizvm-virtio: Reset underlying device on driver request 61bcd562e2SSamuel Ortiz 62bcd562e2SSamuel OrtizIf the driver triggers a reset by writing zero into the status register 63bcd562e2SSamuel Ortizthen reset the underlying device if supported. A device reset also 64bcd562e2SSamuel Ortizrequires resetting various aspects of the queue. 65bcd562e2SSamuel Ortiz 66bcd562e2SSamuel OrtizIn order to be able to do a subsequent reactivate it is required to 67bcd562e2SSamuel Ortizreclaim certain resources (interrupt and queue EventFDs.) If a device 68bcd562e2SSamuel Ortizreset is requested by the driver but the underlying device does not 69bcd562e2SSamuel Ortizsupport it then generate an error as the driver would not be able to 70bcd562e2SSamuel Ortizconfigure it anyway. 71bcd562e2SSamuel Ortiz 72bcd562e2SSamuel OrtizSigned-off-by: Rob Bradford <robert.bradford@intel.com> 73bcd562e2SSamuel Ortiz``` 74bcd562e2SSamuel Ortiz 75bcd562e2SSamuel Ortiz## Pull requests 76bcd562e2SSamuel Ortiz 77bcd562e2SSamuel OrtizCloud Hypervisor uses the “fork-and-pull” development model. Follow these steps if 78bcd562e2SSamuel Ortizyou want to merge your changes to `cloud-hypervisor`: 79bcd562e2SSamuel Ortiz 808ec89bc8SRob Bradford1. Fork the [cloud-hypervisor](https://github.com/cloud-hypervisor/cloud-hypervisor) project 81bcd562e2SSamuel Ortiz into your github organization. 82*e3e83362SRuoqing He1. Within your fork, create a branch for your contribution. 83*e3e83362SRuoqing He1. [Create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) 8476003110SRob Bradford against the main branch of the Cloud Hypervisor repository. 85*e3e83362SRuoqing He1. To update your pull request amend existing commits whenever applicable and 86bcd562e2SSamuel Ortiz then push the new changes to your pull request branch. 87*e3e83362SRuoqing He1. Once the pull request is approved it can be integrated. 88bcd562e2SSamuel Ortiz 89bcd562e2SSamuel Ortiz## Issue tracking 90bcd562e2SSamuel Ortiz 91bcd562e2SSamuel OrtizIf you have a problem, please let us know. We recommend using 928ec89bc8SRob Bradford[github issues](https://github.com/cloud-hypervisor/cloud-hypervisor/issues/new) for formally 93bcd562e2SSamuel Ortizreporting and documenting them. 94bcd562e2SSamuel Ortiz 95bcd562e2SSamuel OrtizTo quickly and informally bring something up to us, you can also reach out on [Slack](https://cloud-hypervisor.slack.com). 96bcd562e2SSamuel Ortiz 97bcd562e2SSamuel Ortiz## Closing issues 98bcd562e2SSamuel Ortiz 99bcd562e2SSamuel OrtizYou can either close issues manually by adding the fixing commit SHA1 to the issue 100bcd562e2SSamuel Ortizcomments or by adding the `Fixes` keyword to your commit message: 101bcd562e2SSamuel Ortiz 102bcd562e2SSamuel Ortiz``` 103bcd562e2SSamuel Ortizserial: Set terminal in raw mode 104bcd562e2SSamuel Ortiz 105bcd562e2SSamuel OrtizIn order to have proper output from the serial, we need to setup the 106bcd562e2SSamuel Ortizterminal in raw mode. When the VM is shutting down, it is also the 107bcd562e2SSamuel OrtizVMM responsibility to set the terminal back into canonical mode if we 108bcd562e2SSamuel Ortizdon't want to get any weird behavior from the shell. 109bcd562e2SSamuel Ortiz 110bcd562e2SSamuel OrtizFixes #88 111bcd562e2SSamuel Ortiz 112bcd562e2SSamuel OrtizSigned-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> 113bcd562e2SSamuel Ortiz``` 114bcd562e2SSamuel Ortiz 11542e9632cSJosh SorefThen, after the corresponding PR is merged, GitHub will automatically close that issue when parsing the 116bcd562e2SSamuel Ortiz[commit message](https://help.github.com/articles/closing-issues-via-commit-messages/). 117