generated from rust-vmm/crate-template
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README.md and add one for i2c
This updates the main README and adds a specific one for i2c crate. Signed-off-by: Viresh Kumar <[email protected]>
- Loading branch information
Showing
2 changed files
with
58 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,12 @@ | ||
# Crate Name | ||
# vhost-device | ||
|
||
## Design | ||
|
||
TODO: This section should have a high-level design of the crate. | ||
|
||
Some questions that might help in writing this section: | ||
- What is the purpose of this crate? | ||
- What are the main components of the crate? How do they interact which each | ||
other? | ||
This repository hosts various 'vhost-user' device backends in their own crates. | ||
See their individual README.md files for specific information about those | ||
crates. | ||
|
||
## Usage | ||
|
||
TODO: This section describes how the crate is used. | ||
|
||
Some questions that might help in writing this section: | ||
- What traits do users need to implement? | ||
- Does the crate have any default/optional features? What is each feature | ||
doing? | ||
- Is this crate used by other rust-vmm components? If yes, how? | ||
|
||
## Examples | ||
|
||
TODO: Usage examples. | ||
|
||
```rust | ||
use my_crate; | ||
|
||
... | ||
``` | ||
|
||
## License | ||
|
||
**!!!NOTICE**: The BSD-3-Clause license is not included in this template. | ||
The license needs to be manually added because the text of the license file | ||
also includes the copyright. The copyright can be different for different | ||
crates. If the crate contains code from CrosVM, the crate must add the | ||
CrosVM copyright which can be found | ||
[here](https://chromium.googlesource.com/chromiumos/platform/crosvm/+/master/LICENSE). | ||
For crates developed from scratch, the copyright is different and depends on | ||
the contributors. | ||
The individual creates are not interdependent and differ in their usage. Read | ||
the specific README.md files in device specific crates for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,64 @@ | ||
# Crate Name | ||
# vhost-device-i2c - I2C emulation backend daemon | ||
|
||
## Design | ||
## Description | ||
This program is a vhost-user backend that emulates a VirtIO I2C bus. | ||
This program takes the layout of the i2c bus and its devices on the host | ||
OS and then talks to them via the /dev/i2c-X interface when a request | ||
comes from the guest OS for an I2C or SMBUS device. | ||
|
||
TODO: This section should have a high-level design of the crate. | ||
This program is tested with QEMU's `-device vhost-user-i2c-pci` but should | ||
work with any virtual machine monitor (VMM) that supports vhost-user. See the | ||
Examples section below. | ||
|
||
Some questions that might help in writing this section: | ||
- What is the purpose of this crate? | ||
- What are the main components of the crate? How do they interact which each | ||
other? | ||
##Synopsis | ||
|
||
## Usage | ||
**vhost-device-i2c** [*OPTIONS*] | ||
|
||
TODO: This section describes how the crate is used. | ||
##Options | ||
|
||
Some questions that might help in writing this section: | ||
- What traits do users need to implement? | ||
- Does the crate have any default/optional features? What is each feature | ||
doing? | ||
- Is this crate used by other rust-vmm components? If yes, how? | ||
.. program:: vhost-device-i2c | ||
|
||
## Examples | ||
.. option:: -h, --help | ||
|
||
TODO: Usage examples. | ||
Print help. | ||
|
||
```rust | ||
use my_crate; | ||
.. option:: -s, --socket-path=PATH | ||
|
||
... | ||
``` | ||
Location of vhost-user Unix domain sockets, this path will be suffixed with | ||
0,1,2..socket_count-1. | ||
|
||
## License | ||
.. option:: -c, --socket-count=INT | ||
|
||
**!!!NOTICE**: The BSD-3-Clause license is not included in this template. | ||
The license needs to be manually added because the text of the license file | ||
also includes the copyright. The copyright can be different for different | ||
crates. If the crate contains code from CrosVM, the crate must add the | ||
CrosVM copyright which can be found | ||
[here](https://chromium.googlesource.com/chromiumos/platform/crosvm/+/master/LICENSE). | ||
For crates developed from scratch, the copyright is different and depends on | ||
the contributors. | ||
Number of guests (sockets) to attach to, default set to 1. | ||
|
||
.. option:: -l, --device-list=I2C-DEVICES | ||
|
||
I2c device list at the host OS in the format: | ||
<bus>:<client_addr>[:<client_addr>],[<bus>:<client_addr>[:<client_addr>]] | ||
|
||
Example: --device-list "2:32:21,3:10:23" | ||
|
||
Here, | ||
bus (decimal): adatper bus number. e.g. 2 for /dev/i2c-2, 3 for /dev/i2c-3. | ||
client_addr (decimal): address for client device, 32 == 0x20. | ||
|
||
##Examples | ||
|
||
The daemon should be started first: | ||
|
||
:: | ||
|
||
host# vhost-device-i2c --socket-path=vi2c.sock --socket-count=1 --device-list 0:32 | ||
|
||
The QEMU invocation needs to create a chardev socket the device can | ||
use to communicate as well as share the guests memory over a memfd. | ||
|
||
:: | ||
|
||
host# qemu-system \ | ||
-chardev socket,path=vi2c.sock,id=vi2c \ | ||
-device vhost-user-i2c-pci,chardev=vi2c,id=i2c \ | ||
-m 4096 \ | ||
-object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ | ||
-numa node,memdev=mem \ | ||
... |