Closed
Description
When using jailer with vsock even with the seccomp filters disabled VM launch fails.
Firecracker version: commit f4349ca
Firecracker build process: ./tools/devtool --unattended build --debug -- --features vsock
The error reported by firecracker is
[anonymous-instance:ERROR:api_server/src/http_service.rs:586] Received Error on synchronous Put request on "/actions" with body "{\n \"action_type\": \"InstanceStart\"\n }". Status code: 500 Internal Server Error.
Error reported to the caller of the API is on InstanceStart is
{
"fault_message": "Cannot create vsock device. VhostGetFeatures(IoctlError(Os { code: 25, kind: Other, message: Not a tty }))"
}
A simple test case
Launch Jailer
Note: The vhost-vsock bind mounting is done later in the VM launch script
sudo ip netns add nsfire
sudo ip tuntap add dev fire0 mode tap
sudo ip link set fire0 netns nsfire
mkdir -p /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/
ln $HOME/firecracker/hello-vmlinux.bin /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/vmlinux
ln $HOME/firecracker/hello-rootfs.ext4 /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/rootfs.img
sudo $HOME/firecracker/build/debug/jailer --id 551e7604-e35c-42b3-b825-416853441234 --node 0 --exec-file $HOME/firecracker/build/debug/firecracker --uid 0 --gid 0 --chroot-base-dir /tmp/firecracker --netns /var/run/netns/nsfire --seccomp-level 0
Launch the VM
SOCKET=/tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/api.socket
sudo -E curl --unix-socket "$SOCKET" -i \
-X PUT 'http://localhost/boot-source' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"kernel_image_path": "./vmlinux",
"boot_args": "console=ttyS0 reboot=k panic=1 pci=off init=/bin/ash"
}'
sudo -E curl --unix-socket "$SOCKET" -i \
-X PUT 'http://localhost/drives/rootfs' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"drive_id": "rootfs",
"path_on_host": "./rootfs.img",
"is_root_device": true,
"is_read_only": false
}'
# Allow vhost-vsock access
sudo touch /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/dev/vhost-vsock
sudo mount --bind /dev/vhost-vsock /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/dev/vhost-vsock
sudo ls -alp /tmp/firecracker/firecracker/551e7604-e35c-42b3-b825-416853441234/root/dev/vhost-vsock
sudo ls -alp /dev/vhost-vsock
sudo -E curl --unix-socket "$SOCKET" -i \
-X PUT "http://localhost/vsocks/root" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d "{
\"id\": \"root\",
\"guest_cid\": 8
}"
sudo -E curl --unix-socket "$SOCKET" -i \
-X GET "http://localhost/" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
sudo -E curl --unix-socket "$SOCKET" -i \
-X PUT 'http://localhost/actions' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"action_type": "InstanceStart"
}'
sudo -E curl --unix-socket "$SOCKET" -i \
-X GET "http://localhost/" \
-H "accept: application/json" \
-H "Content-Type: application/json" \