Skip to content

Commit 2aedb23

Browse files
committed
Improve DAXFS support
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent e3a057a commit 2aedb23

5 files changed

Lines changed: 64 additions & 245 deletions

File tree

src/kerf/daxfs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
"""DAXFS filesystem image creation for multikernel."""
1616

17-
from .mkdaxfs import create_daxfs_image, DaxfsError, DaxfsImage
17+
from .mkdaxfs import create_daxfs_image, DaxfsError, DaxfsImage, inject_kerf_init
1818

19-
__all__ = ["create_daxfs_image", "DaxfsError", "DaxfsImage"]
19+
__all__ = ["create_daxfs_image", "DaxfsError", "DaxfsImage", "inject_kerf_init"]
2020

2121

2222

src/kerf/daxfs/mkdaxfs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,23 @@ def _allocate_dma_heap(heap_path: str, size: int) -> tuple[int, mmap.mmap]:
310310

311311
KERF_DAXFS_MNT_DIR = "/var/lib/kerf/daxfs"
312312

313+
KERF_INIT_TEMPLATE = """#!/bin/sh
314+
mount -t proc proc /proc
315+
mount -t sysfs sysfs /sys
316+
mkdir -p /dev/pts
317+
mount -t devpts devpts /dev/pts
318+
ifconfig eth0 192.168.122.157
319+
cat /proc/uptime > /dev/kmsg
320+
exec {entrypoint}
321+
"""
322+
323+
324+
def inject_kerf_init(rootfs_path: str, entrypoint: str) -> None:
325+
"""Inject /init wrapper script into rootfs."""
326+
init_path = Path(rootfs_path) / "init"
327+
init_path.write_text(KERF_INIT_TEMPLATE.format(entrypoint=entrypoint))
328+
os.chmod(init_path, 0o755)
329+
313330

314331
def _mount_daxfs(instance_name: str, phys_addr: int, size: int) -> None:
315332
"""

src/kerf/initrd.py

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)