Extending the Sandbox
Add a Sandbox method
Methods live in mixins in quicksand_core/sandbox/. Pick the one that fits your concern:
| File | Owns |
|---|---|
_execution.py | execute() |
_checkpoints.py | checkpoint(), revert() |
_saves.py | save() |
_input.py | screenshot(), type_text(), press_key(), mouse_*() |
_mounts.py | mount(), unmount() |
Example of adding read_file() to _execution.py:
python
async def read_file(self, guest_path: str) -> str:
if not self.is_running:
raise RuntimeError("Sandbox is not running")
result = await self.execute(f"cat {guest_path}")
if result.exit_code != 0:
raise FileNotFoundError(f"Guest file not found: {guest_path}: {result.stderr}")
return result.stdoutIf you need new shared state, add the field to _SandboxProtocol (_protocol.py) and initialize it in Sandbox.__init__() (_sandbox.py).
Export from quicksand_core and the quicksand wrapper if it's public API.
Add a new OS
- Add
OS.FREEBSDto the enum inhost/os_.py - Create
FreeBSDConfig(BaseOSConfig)and implementdetect_accelerator(),disk_aio, etc. - Add the detection branch in
OSConfig.__new__()and_detect_os() - If it needs unique QEMU flags, handle them in
build_qemu_command()(qemu/platform.py)
Add a new architecture
- Add
Architecture.RISCV64to the enum inhost/arch.py - Create
RISCV64Config(BaseArchitectureConfig)inqemu/arch.pyand set machine type, device names, console, GPU, CPU model - Add the detection branch in
ArchitectureConfig.__new__()and_detect_architecture() - Build QEMU and image packages for the new architecture
Add a new QEMU flag
- If user-configurable, add the kwarg to
Sandbox(and the underlyingSandboxConfigin_types.py) - Add the flag to
build_qemu_command()inqemu/platform.py(or a_build_*_args()helper) - Document in the relevant
docs/under-the-hood/file - Unit test: verify the flag appears in the generated command. Integration test: verify the feature works.