Skip to content

Commit ba84893

Browse files
committed
Upgrade to Firecracker v0.18.0.
This consists of: * Upgrading to the new Go SDK version. * Using the new vsock interface with unix-domain socket backend on the host. Signed-off-by: Erik Sipsma <[email protected]>
1 parent 5a77bc8 commit ba84893

15 files changed

+296
-252
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ demo-network: $(PTP_BIN) $(HOSTLOCAL_BIN) $(TC_REDIRECT_TAP_BIN) $(FCNET_CONFIG)
165165
.PHONY: firecracker
166166
firecracker: $(FIRECRACKER_BIN) $(JAILER_BIN)
167167

168+
.PHONY: install-firecracker
169+
install-firecracker: firecracker
170+
install -D -o root -g root -m755 -t $(INSTALLROOT)/bin $(FIRECRACKER_BIN)
171+
install -D -o root -g root -m755 -t $(INSTALLROOT)/bin $(JAILER_BIN)
172+
168173
$(FIRECRACKER_DIR)/Cargo.toml:
169174
git submodule update --init --recursive $(FIRECRACKER_DIR)
170175

@@ -182,7 +187,7 @@ $(FIRECRACKER_BIN) $(JAILER_BIN): $(FIRECRACKER_DIR)/Cargo.toml tools/firecracke
182187
-e HOME=/tmp \
183188
--workdir /src \
184189
localhost/$(FIRECRACKER_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \
185-
cargo build --release --features vsock --target $(FIRECRACKER_TARGET)
190+
cargo build --release --target $(FIRECRACKER_TARGET)
186191

187192
.PHONY: firecracker-clean
188193
firecracker-clean:

_submodules/firecracker

Submodule firecracker updated 130 files

agent/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ import (
2626
taskAPI "github.com/containerd/containerd/runtime/v2/task"
2727
"github.com/containerd/containerd/sys/reaper"
2828
"github.com/containerd/ttrpc"
29-
"github.com/mdlayher/vsock"
3029
"github.com/opencontainers/runc/libcontainer/system"
3130
"github.com/sirupsen/logrus"
3231
"golang.org/x/sync/errgroup"
3332
"golang.org/x/sys/unix"
3433

3534
"github.com/firecracker-microvm/firecracker-containerd/eventbridge"
3635
"github.com/firecracker-microvm/firecracker-containerd/internal/event"
36+
"github.com/firecracker-microvm/firecracker-containerd/internal/vm"
3737
)
3838

3939
const (
@@ -93,8 +93,8 @@ func main() {
9393

9494
// Run ttrpc over vsock
9595

96-
log.G(shimCtx).WithField("port", port).Info("listening to vsock")
97-
listener, err := vsock.Listen(uint32(port))
96+
vsockLogger := log.G(shimCtx).WithField("port", port)
97+
listener, err := vm.VSockListener(shimCtx, vsockLogger, uint32(port))
9898
if err != nil {
9999
log.G(shimCtx).WithError(err).Fatalf("failed to listen to vsock on port %d", port)
100100
}

docs/getting-started.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,6 @@ You need to have the following things in order to use firecracker-containerd:
5050

5151
## Setup
5252

53-
### Build Firecracker with `vsock` support
54-
55-
Clone the repository to your computer in a directory of your choice:
56-
57-
```bash
58-
git clone https://github.com/firecracker-microvm/firecracker.git
59-
```
60-
Change into the new directory, and build with Cargo. Make sure to enable the
61-
optional `vsock` feature using the `--features vsock` flag.
62-
63-
> Note: Firecracker normally builds a statically-linked binary with musl libc.
64-
> On Amazon Linux 2, you must specify `--target x86_64-unknown-linux-gnu`
65-
> because musl libc is not available. Switching to this target changes the set
66-
> of syscalls invoked by Firecracker. If you intend to jail Firecracker using
67-
> seccomp, you must adjust your seccomp profile for these changes.
68-
69-
```bash
70-
git checkout v0.17.0 # latest released tag
71-
cargo build --release --features vsock # --target x86_64-unknown-linux-gnu
72-
```
73-
7453
### Download appropriate kernel
7554

7655
You can use the following kernel:
@@ -90,7 +69,7 @@ Clone this repository to your computer in a directory of your choice.
9069
We recommend choosing a directory outside of `$GOPATH` or `~/go`.
9170

9271
```bash
93-
git clone https://github.com/firecracker-microvm/firecracker-containerd
72+
git clone --recurse-submodules https://github.com/firecracker-microvm/firecracker-containerd
9473
make all
9574
```
9675

@@ -111,6 +90,21 @@ Once you have built the runtime, be sure to place the following binaries on your
11190
You can use the `make install` target to install the files to `/usr/local/bin`,
11291
or specify a different `INSTALLROOT` if you prefer another location.
11392

93+
### Build Firecracker
94+
95+
From the repository cloned in the previous step, run
96+
```bash
97+
make firecracker
98+
```
99+
100+
Once you have built firecracker, be sure to place the following binaries on your
101+
`$PATH`:
102+
* `_submodules/firecracker/target/x86_64-unknown-linux-musl/release/firecracker`
103+
* `_submodules/firecracker/target/x86_64-unknown-linux-musl/release/jailer`
104+
105+
You can use the `make install-firecracker` target to install the files to `/usr/local/bin`,
106+
or specify a different `INSTALLROOT` if you prefer another location.
107+
114108
### Build a root filesystem
115109

116110
The firecracker-containerd repository includes an image builder component that

docs/quickstart.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,8 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get \
4141
git \
4242
curl \
4343
e2fsprogs \
44-
musl-tools \
4544
util-linux
4645

47-
# Install Rust
48-
curl https://sh.rustup.rs -sSf | sh -s -- --verbose -y --default-toolchain 1.32.0
49-
source $HOME/.cargo/env
50-
rustup target add x86_64-unknown-linux-musl
51-
52-
# Check out Firecracker and build it from the v0.17.0 tag
53-
git clone https://github.com/firecracker-microvm/firecracker.git
54-
cd firecracker
55-
git checkout v0.17.0
56-
cargo build --release --features vsock --target x86_64-unknown-linux-musl
57-
sudo cp target/x86_64-unknown-linux-musl/release/{firecracker,jailer} /usr/local/bin
58-
5946
cd ~
6047

6148
# Install Docker CE
@@ -87,9 +74,8 @@ cd ~
8774
git clone https://github.com/firecracker-microvm/firecracker-containerd.git
8875
cd firecracker-containerd
8976
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y dmsetup
90-
sg docker -c 'make all image'
91-
sudo make install
92-
sudo make demo-network
77+
sg docker -c 'make all image firecracker'
78+
sudo make install install-firecracker demo-network
9379

9480
cd ~
9581

@@ -142,9 +128,6 @@ sudo tee /etc/containerd/firecracker-runtime.json <<EOF
142128
}]
143129
}
144130
EOF
145-
146-
# Enable vhost-vsock
147-
sudo modprobe vhost-vsock
148131
```
149132

150133
4. Open a new terminal and start the `naive_snapshotter` program in the

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ integ-test:
4040
--env EXTRAGOARGS="${EXTRAGOARGS}" \
4141
--workdir="/firecracker-containerd/examples" \
4242
localhost/firecracker-containerd-naive-integ-test:${DOCKER_IMAGE_TAG} \
43-
"make examples && make testtap && ./taskworkflow -ip $(TEST_IP)$(TEST_SUBNET) -gw $(TEST_GATEWAY)"
43+
"make examples && make testtap && sleep 3 && ./taskworkflow -ip $(TEST_IP)$(TEST_SUBNET) -gw $(TEST_GATEWAY)"
4444

4545
TEST_GATEWAY?=172.16.0.1
4646
TEST_IP?=172.16.0.2

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect
1717
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 // indirect
1818
github.com/docker/go-units v0.3.3
19-
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190912001513-a4afb10dd9d7
19+
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190920221449-6afccc1d121f
2020
github.com/go-ole/go-ole v1.2.4 // indirect
2121
github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384 // indirect
2222
github.com/gofrs/uuid v3.2.0+incompatible

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82 h1:X0fj836zx99zF
5959
github.com/docker/go-metrics v0.0.0-20181218153428-b84716841b82/go.mod h1:/u0gXw0Gay3ceNrsHubL3BtdOL2fHf93USgMTe0W5dI=
6060
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
6161
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
62-
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190912001513-a4afb10dd9d7 h1:9suT/hW4u++sJdgHLU1duoiRuRHwrGf/RKSKG2prsJY=
63-
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190912001513-a4afb10dd9d7/go.mod h1:tVXziw7GjioCKVjI5/agymYxUaqJM6q7cp9e6kwjo8Q=
62+
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190920221449-6afccc1d121f h1:G81Ey0lQDWCqwdIRq6aLN5RyYbnSDx2O7FKFl433shc=
63+
github.com/firecracker-microvm/firecracker-go-sdk v0.17.1-0.20190920221449-6afccc1d121f/go.mod h1:tVXziw7GjioCKVjI5/agymYxUaqJM6q7cp9e6kwjo8Q=
6464
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb h1:D4uzjWwKYQ5XnAvUbuvHW93esHg7F8N/OYeBBcJoTr0=
6565
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
6666
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=

internal/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const (
3131

3232
// FirecrackerSockName is the name of the Firecracker VMM API socket
3333
FirecrackerSockName = "firecracker.sock"
34+
// FirecrackerVSockName is the name of the Firecracker VSock unix path used for communication
35+
// between the runtime and the agent
36+
FirecrackerVSockName = "firecracker.vsock"
3437
// FirecrackerLogFifoName is the name of the Firecracker VMM log FIFO
3538
FirecrackerLogFifoName = "fc-logs.fifo"
3639
// FirecrackerMetricsFifoName is the name of the Firecracker VMM metrics FIFO

internal/vm/dir.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ func (d Dir) FirecrackerSockPath() string {
8383
return filepath.Join(d.RootPath(), internal.FirecrackerSockName)
8484
}
8585

86+
// FirecrackerVSockPath returns the path to the vsock unix socket that the runtime uses
87+
// to communicate with the VM agent.
88+
func (d Dir) FirecrackerVSockPath() string {
89+
return filepath.Join(d.RootPath(), internal.FirecrackerVSockName)
90+
}
91+
8692
// FirecrackerLogFifoPath returns the path to the FIFO at which the firecracker VMM writes
8793
// its logs
8894
func (d Dir) FirecrackerLogFifoPath() string {

0 commit comments

Comments
 (0)