-
Notifications
You must be signed in to change notification settings - Fork 29
arm64: Enable virtio-net and add network scripts #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
otischung
wants to merge
5
commits into
sysprog21:master
Choose a base branch
from
otischung:feat/arm64-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ebeb284
arm64: enable virtio-net and add network scripts
otischung 60835d6
Fix the URL in README.md
otischung 1e84059
Remove unneed kernel configurations
otischung 725a026
Rename "Stop" Emulator to "Exit" in README.md
otischung 82ff20a
Use '$' as shell prompt in README.md
otischung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -33,6 +33,8 @@ make check | |
|
||
## Usage | ||
|
||
### Start Emulator | ||
|
||
``` | ||
build/kvm-host -k bzImage [-i initrd] [-d disk-image] | ||
``` | ||
|
@@ -42,8 +44,63 @@ containing concatenated `bootsect.o + setup.o + misc.o + piggy.o`. `initrd` is t | |
initial RAM disk image, which is an optional argument. | ||
`disk-image` is the path to disk image which can be mounted as a block device via virtio. For the reference Linux guest, ext4 filesystem is used for disk image. | ||
|
||
### Exit Emulator | ||
|
||
To exit kvm-host, press "Ctrl-A", release both keys, and then press "x". | ||
|
||
### Enable Static Route to Test the Guest VirtIO-Net Interface | ||
|
||
1. Start the kvm-host emulator. Once initialized, the TUN/TAP interface (for example, `tap0`) is visible in the output of `ip a`. The following is sample output from the host: | ||
|
||
```shell | ||
❯ ip a | ||
1: lo: ... | ||
2: eth0: ... | ||
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 | ||
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff | ||
altname xxxxxxxxxxxxxxx | ||
inet 192.168.x.x/24 brd 192.168.x.255 scope global dynamic noprefixroute wlan0 | ||
valid_lft xxxxxxsec preferred_lft xxxxxxsec | ||
inet6 ... | ||
11: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 | ||
link/ether 5a:1d:bd:2d:7c:1f brd ff:ff:ff:ff:ff:ff | ||
``` | ||
|
||
2. Execute the shell script `./scripts/set-host-bridge.sh`, which configures a bridge by assigning the default route to 10.0.0.1, integrating the TUN/TAP interface into the bridge, and activating the network interfaces. The following is sample output of `ip a` from the host: | ||
|
||
```shell | ||
❯ ip a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. Use |
||
... | ||
11: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 | ||
link/ether 5a:1d:bd:2d:7c:1f brd ff:ff:ff:ff:ff:ff | ||
12: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 | ||
link/ether d6:92:97:85:e8:7c brd ff:ff:ff:ff:ff:ff | ||
inet 10.0.0.1/24 scope global br0 | ||
valid_lft forever preferred_lft forever | ||
``` | ||
|
||
3. Copy the commands from `scripts/set-guest-route.sh` into the guest environment and execute them. Below is a sample `ip a` output from the guest: | ||
|
||
```shell | ||
~ # ip a | ||
1: lo: <LOOPBACK> mtu 65536 qdisc noop qlen 1000 | ||
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | ||
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 | ||
link/ether c2:5a:92:87:97:42 brd ff:ff:ff:ff:ff:ff | ||
inet 10.0.0.2/24 scope global eth0 | ||
valid_lft forever preferred_lft forever | ||
inet6 fe80::c05a:92ff:fe87:9742/64 scope link | ||
valid_lft forever preferred_lft forever | ||
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000 | ||
link/sit 0.0.0.0 brd 0.0.0.0 | ||
``` | ||
|
||
4. Test guest network connectivity by pinging the configured default gateway. | ||
|
||
```bash | ||
ping 10.0.0.1 | ||
``` | ||
|
||
## License | ||
|
||
`kvm-host` is released under the BSD 2 clause license. Use of this source code is governed by | ||
|
@@ -52,7 +109,7 @@ a BSD-style license that can be found in the LICENSE file. | |
## References | ||
* [kvmtool](https://github.com/kvmtool/kvmtool) | ||
* [KVM (Kernel-based Virtual Machine) API](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt) | ||
* [The Linux/x86 Boot Protocol](https://www.kernel.org/doc/html/latest/x86/boot.html) | ||
* [The Linux/x86 Boot Protocol](https://www.kernel.org/doc/html/latest/arch/x86/boot.html) | ||
* [Using the KVM API](https://lwn.net/Articles/658511/) | ||
* [gokvm](https://github.com/bobuhiro11/gokvm) | ||
* [KVM Host in a few lines of code](https://zserge.com/posts/kvm/) | ||
|
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ip addr add 10.0.0.2/24 dev eth0 | ||
ip link set eth0 up | ||
ip route add default via 10.0.0.1 |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
sudo ip link delete br0 || true | ||
sudo brctl addbr br0 | ||
sudo ip addr add 10.0.0.1/24 dev br0 | ||
sudo ip route add default via 10.0.0.1 dev br0 | ||
sudo ip link set br0 up | ||
sudo ip link set tap0 master br0 | ||
sudo ip link set tap0 up |
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
$
for the command line prompt.