This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
forked from rust-vsock/tokio-vsock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
67 lines (53 loc) · 2.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright 2019 fsyncd, Berlin, Germany.
# Additional material, copyright of the containerd authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TOOLCHAIN := x86_64-unknown-linux-musl
VPATH = target/system target/$(TOOLCHAIN)/debug target/$(TOOLCHAIN)/release
SRCS := $(shell find . -type f -name '*.rs' | grep -v 'tests')
ID := $(shell date +%s)
.PHONY: all check clean tokio_vsock kmod vm
all: fmt clippy tokio_vsock test_server
check: tokio_vsock test
test:
cargo test --all
fmt:
cargo fmt --all -- --check
clippy:
cargo clippy --all-targets --all-features -- -D warnings
clean:
cargo clean
tokio_vsock: $(SRCS)
cargo build --lib
test_server: tokio_vsock test_server/src/main.rs
cargo build --manifest-path=test_server/Cargo.toml
# Setup required host kernel modules
kmod:
sudo /sbin/modprobe -r vmw_vsock_vmci_transport
sudo /sbin/modprobe -r vmw_vsock_virtio_transport_common
sudo /sbin/modprobe -r vsock
sudo /sbin/modprobe vhost_vsock
# Start a Virtio socket enabled vm
vm: initrd.cpio
sudo qemu-system-x86_64 -kernel test_fixture/bzImage -initrd target/$(TOOLCHAIN)/debug/initrd.cpio \
-enable-kvm -m 256 -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=3 -nographic -append "console=ttyS0"
# Create a simple operating system image for the vm
initrd.cpio: test_server
-rm -f target/$(TOOLCHAIN)/debug/initrd.cpio
mkdir -p /tmp/$(ID)
cp test_fixture/busybox.cpio /tmp/$(ID)/initrd.cpio
cp test_fixture/init /tmp/$(ID)/init
cp test_server/target/$(TOOLCHAIN)/debug/test_server /tmp/$(ID)/
(cd '/tmp/$(ID)' && find . | grep -v 'initrd.cpio' | cpio -H newc -o --append -F initrd.cpio)
mv /tmp/$(ID)/initrd.cpio target/$(TOOLCHAIN)/debug/
rm -Rf /tmp/$(ID)