Skip to content

Commit 4ee2a18

Browse files
committed
python-agent-driver: enable networking in rootfs and kernel
Add hostsock networking config to kraft.yaml (pointing to danbugs/unikraft networking branch) and bundle DNS resolv.conf, nsswitch.conf, hosts, and CA certificates into the CPIO rootfs so the guest can resolve hostnames and make TLS connections. Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent e032eca commit 4ee2a18

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

examples/python-agent-driver/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ COPY --from=driver-build /src/hl_pydriver /bin/hl_pydriver
4444

4545
# Stage 4: pack CPIO.
4646
FROM alpine:3.20 AS cpio
47-
RUN apk add --no-cache cpio findutils
47+
RUN apk add --no-cache cpio findutils ca-certificates
4848
COPY --from=rootfs / /rootfs/
49+
50+
# DNS configuration for glibc's getaddrinfo
51+
RUN mkdir -p /rootfs/etc && \
52+
echo "nameserver 8.8.8.8" > /rootfs/etc/resolv.conf && \
53+
echo "nameserver 8.8.4.4" >> /rootfs/etc/resolv.conf && \
54+
echo "hosts: files dns" > /rootfs/etc/nsswitch.conf && \
55+
echo "127.0.0.1 localhost" > /rootfs/etc/hosts
56+
57+
# CA certificates for TLS
58+
RUN mkdir -p /rootfs/etc/ssl/certs /rootfs/usr/lib/ssl && \
59+
cp /etc/ssl/certs/ca-certificates.crt /rootfs/etc/ssl/certs/ && \
60+
ln -sf /etc/ssl/certs/ca-certificates.crt /rootfs/usr/lib/ssl/cert.pem
61+
4962
RUN cd /rootfs && find . | cpio -o -H newc > /output.cpio 2>/dev/null

examples/python-agent-driver/kraft.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ specification: '0.6'
22
name: python-agent-driver-hyperlight
33

44
unikraft:
5-
source: https://github.com/unikraft/unikraft.git
6-
version: plat-hyperlight
5+
source: https://github.com/danbugs/unikraft.git
6+
version: networking
77
kconfig:
88
CONFIG_PLAT_HYPERLIGHT: 'y'
99
CONFIG_PAGING: 'n'
@@ -34,6 +34,15 @@ unikraft:
3434
CONFIG_LIBHOSTFS: 'y'
3535
CONFIG_LIBHOSTFS_AUTOMOUNT: 'y'
3636

37+
# Networking: host-proxied sockets
38+
CONFIG_LIBPOSIX_SOCKET: 'y'
39+
CONFIG_LIBHOSTSOCK: 'y'
40+
41+
# FD infrastructure (required by posix-socket)
42+
CONFIG_LIBPOSIX_FDIO: 'y'
43+
CONFIG_LIBPOSIX_FDTAB: 'y'
44+
CONFIG_LIBUKFILE: 'y'
45+
3746
# Target our driver binary, not /usr/local/bin/python3.
3847
CONFIG_APPELFLOADER: 'y'
3948
CONFIG_APPELFLOADER_VFSEXEC: 'y'

0 commit comments

Comments
 (0)