diff --git a/Makefile b/Makefile index dca30d252..ac631eb1f 100644 --- a/Makefile +++ b/Makefile @@ -165,6 +165,11 @@ demo-network: $(PTP_BIN) $(HOSTLOCAL_BIN) $(TC_REDIRECT_TAP_BIN) $(FCNET_CONFIG) .PHONY: firecracker firecracker: $(FIRECRACKER_BIN) $(JAILER_BIN) +.PHONY: install-firecracker +install-firecracker: firecracker + install -D -o root -g root -m755 -t $(INSTALLROOT)/bin $(FIRECRACKER_BIN) + install -D -o root -g root -m755 -t $(INSTALLROOT)/bin $(JAILER_BIN) + $(FIRECRACKER_DIR)/Cargo.toml: git submodule update --init --recursive $(FIRECRACKER_DIR) @@ -182,7 +187,7 @@ $(FIRECRACKER_BIN) $(JAILER_BIN): $(FIRECRACKER_DIR)/Cargo.toml tools/firecracke -e HOME=/tmp \ --workdir /src \ localhost/$(FIRECRACKER_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \ - cargo build --release --features vsock --target $(FIRECRACKER_TARGET) + cargo build --release --target $(FIRECRACKER_TARGET) .PHONY: firecracker-clean firecracker-clean: diff --git a/_submodules/firecracker b/_submodules/firecracker index 7267a7d73..1e1cb6f8f 160000 --- a/_submodules/firecracker +++ b/_submodules/firecracker @@ -1 +1 @@ -Subproject commit 7267a7d73875da3e30bf0901448c56182ba87c20 +Subproject commit 1e1cb6f8f8003e0bdce11d265f0feb23249a03f6 diff --git a/agent/main.go b/agent/main.go index 8307d4061..f2018bcf2 100644 --- a/agent/main.go +++ b/agent/main.go @@ -26,7 +26,6 @@ import ( taskAPI "github.com/containerd/containerd/runtime/v2/task" "github.com/containerd/containerd/sys/reaper" "github.com/containerd/ttrpc" - "github.com/mdlayher/vsock" "github.com/opencontainers/runc/libcontainer/system" "github.com/sirupsen/logrus" "golang.org/x/sync/errgroup" @@ -34,6 +33,7 @@ import ( "github.com/firecracker-microvm/firecracker-containerd/eventbridge" "github.com/firecracker-microvm/firecracker-containerd/internal/event" + "github.com/firecracker-microvm/firecracker-containerd/internal/vm" ) const ( @@ -93,8 +93,8 @@ func main() { // Run ttrpc over vsock - log.G(shimCtx).WithField("port", port).Info("listening to vsock") - listener, err := vsock.Listen(uint32(port)) + vsockLogger := log.G(shimCtx).WithField("port", port) + listener, err := vm.VSockListener(shimCtx, vsockLogger, uint32(port)) if err != nil { log.G(shimCtx).WithError(err).Fatalf("failed to listen to vsock on port %d", port) } diff --git a/docs/getting-started.md b/docs/getting-started.md index 406daff67..acb1dc77e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -50,27 +50,6 @@ You need to have the following things in order to use firecracker-containerd: ## Setup -### Build Firecracker with `vsock` support - -Clone the repository to your computer in a directory of your choice: - -```bash -git clone https://github.com/firecracker-microvm/firecracker.git -``` -Change into the new directory, and build with Cargo. Make sure to enable the -optional `vsock` feature using the `--features vsock` flag. - -> Note: Firecracker normally builds a statically-linked binary with musl libc. -> On Amazon Linux 2, you must specify `--target x86_64-unknown-linux-gnu` -> because musl libc is not available. Switching to this target changes the set -> of syscalls invoked by Firecracker. If you intend to jail Firecracker using -> seccomp, you must adjust your seccomp profile for these changes. - -```bash -git checkout v0.17.0 # latest released tag -cargo build --release --features vsock # --target x86_64-unknown-linux-gnu -``` - ### Download appropriate kernel You can use the following kernel: @@ -90,7 +69,7 @@ Clone this repository to your computer in a directory of your choice. We recommend choosing a directory outside of `$GOPATH` or `~/go`. ```bash -git clone https://github.com/firecracker-microvm/firecracker-containerd +git clone --recurse-submodules https://github.com/firecracker-microvm/firecracker-containerd make all ``` @@ -111,6 +90,21 @@ Once you have built the runtime, be sure to place the following binaries on your You can use the `make install` target to install the files to `/usr/local/bin`, or specify a different `INSTALLROOT` if you prefer another location. +### Build Firecracker + +From the repository cloned in the previous step, run +```bash +make firecracker +``` + +Once you have built firecracker, be sure to place the following binaries on your +`$PATH`: +* `_submodules/firecracker/target/x86_64-unknown-linux-musl/release/firecracker` +* `_submodules/firecracker/target/x86_64-unknown-linux-musl/release/jailer` + +You can use the `make install-firecracker` target to install the files to `/usr/local/bin`, +or specify a different `INSTALLROOT` if you prefer another location. + ### Build a root filesystem The firecracker-containerd repository includes an image builder component that diff --git a/docs/quickstart.md b/docs/quickstart.md index d183e5d29..914b01401 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -41,21 +41,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get \ git \ curl \ e2fsprogs \ - musl-tools \ util-linux -# Install Rust -curl https://sh.rustup.rs -sSf | sh -s -- --verbose -y --default-toolchain 1.32.0 -source $HOME/.cargo/env -rustup target add x86_64-unknown-linux-musl - -# Check out Firecracker and build it from the v0.17.0 tag -git clone https://github.com/firecracker-microvm/firecracker.git -cd firecracker -git checkout v0.17.0 -cargo build --release --features vsock --target x86_64-unknown-linux-musl -sudo cp target/x86_64-unknown-linux-musl/release/{firecracker,jailer} /usr/local/bin - cd ~ # Install Docker CE @@ -87,9 +74,8 @@ cd ~ git clone https://github.com/firecracker-microvm/firecracker-containerd.git cd firecracker-containerd sudo DEBIAN_FRONTEND=noninteractive apt-get install -y dmsetup -sg docker -c 'make all image' -sudo make install -sudo make demo-network +sg docker -c 'make all image firecracker' +sudo make install install-firecracker demo-network cd ~ @@ -142,9 +128,6 @@ sudo tee /etc/containerd/firecracker-runtime.json <