Run UML command with path to rootfs and additional arguments based on user input. Parameters: * kernel_image (Path): kernel Path object containing full path to kernel. * rootfs (Path): rootfs Path object containing full path to rootfs. * interactive (bool): Whet
(kernel_image: Path, rootfs: Path, interactive: bool)
| 40 | |
| 41 | |
| 42 | def run_kernel(kernel_image: Path, rootfs: Path, interactive: bool) -> None: |
| 43 | """ |
| 44 | Run UML command with path to rootfs and additional arguments based on user |
| 45 | input. |
| 46 | |
| 47 | Parameters: |
| 48 | * kernel_image (Path): kernel Path object containing full path to kernel. |
| 49 | * rootfs (Path): rootfs Path object containing full path to rootfs. |
| 50 | * interactive (bool): Whether or not to run UML interactively. |
| 51 | """ |
| 52 | uml_cmd = [kernel_image, f"ubd0={rootfs}"] |
| 53 | if interactive: |
| 54 | uml_cmd += ["init=/bin/sh"] |
| 55 | print(f"$ {' '.join([str(element) for element in uml_cmd])}") |
| 56 | subprocess.run(uml_cmd, check=True) |
| 57 | |
| 58 | |
| 59 | if __name__ == '__main__': |