# rust-os-qemu **Repository Path**: luzhihaoTestingLab/rust-os-qemu ## Basic Information - **Project Name**: rust-os-qemu - **Description**: 用rust语言写的操作系统,构建产物后可以在qemu中启动 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-12 - **Last Updated**: 2025-10-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Rust OS QEMU Workflow This repository builds the kernel inside a Docker container so that the host environment no longer needs to download toolchains or run `cargo bootimage` directly. ## Prerequisites - Docker Desktop (Linux container backend enabled) - QEMU installed on Windows (matches `qemu-system-x86_64` from the package) ## Build the boot image inside Docker ```powershell cd C:\Users\luzhihao\Desktop\workplace\rust-os-qemu .\scripts\build-bootimage.ps1 ``` PowerShell downloads the toolchain (using the Dockerfile) and produces the bootable image at: - `kernel\target\x86_64-blog_os\debug\bootimage-kernel.bin` If you prefer a POSIX shell (Git Bash/WSL), run: ```sh cd /c/Users/luzhihao/Desktop/workplace/rust-os-qemu ./scripts/build-bootimage.sh ``` Both scripts accept an optional `IMAGE_TAG` environment variable to reuse or customize the Docker image name. ## Run the build under QEMU on Windows Once the Docker build finishes, launch the resulting image with the Windows QEMU installation: ```powershell qemu-system-x86_64 -drive format=raw,file=kernel\target\x86_64-blog_os\debug\bootimage-kernel.bin -serial stdio -display none ``` This mirrors the `package.metadata.bootimage.run-command` defined in `kernel/Cargo.toml`. ## Notes - The Docker image installs `rustup` nightly plus `rust-src` and `llvm-tools-preview`, matching the `rust-toolchain.toml`. - The container includes `qemu-system-x86` so you can run smoke tests inside Docker if desired, although the primary workflow runs QEMU on Windows. - The `vendor/bootloader-0.9.23` directory contains a patched copy of the upstream bootloader crate so that modern nightly compilers build cleanly. `kernel/Cargo.toml` wires it in through `[patch.crates-io]`. - If Docker Hub is unreachable, retry `docker build` once connectivity is restored; the build cache keeps subsequent runs fast.