Testing in QEMU
QEMU is the recommended emulator for testing Portix OS during development due to its speed and debugging capabilities.Quick Start
Build and run in one command:- Build the kernel and disk image
- Launch QEMU with appropriate flags
- Show serial output in the console
Manual QEMU Launch
For more control, build first and run manually:- Raw Disk Image
- ISO Image
- With Debugging
QEMU Flags Explained
| Flag | Purpose |
|---|---|
-m 128M | Allocate 128 MB of RAM |
-serial stdio | Route COM1 to console |
-no-reboot | Halt on kernel panic instead of rebooting |
-no-shutdown | Keep QEMU open after shutdown |
-d int,cpu_reset | Log interrupts and CPU resets |
-D logfile | Write debug log to file |
-s | Start GDB server on port 1234 |
-S | Pause on startup (wait for GDB) |
The
-serial stdio flag is important for seeing kernel debug output.
Portix writes diagnostic messages to COM1 (0x3F8).Testing in VirtualBox
VirtualBox provides a more realistic test environment closer to real hardware.Creating a VM
Create new VM
Open VirtualBox and create a new VM:
- Name: Portix OS
- Type: Other
- Version: Other/Unknown (64-bit)
- Memory: 128 MB
- Hard disk: Use existing (select
build/dist/portix.vdi)
Configure VM
Under Settings:
- System → Motherboard: Disable EFI, enable I/O APIC
- System → Processor: 1 CPU
- Display → Screen: 8 MB video memory
- Storage: Ensure disk is on IDE controller
Testing with ISO
Alternatively, use the ISO image:build/dist/portix.iso as a CD-ROM in VirtualBox settings.
Debugging with GDB
QEMU supports remote debugging via GDB.Setup
Useful GDB Commands
Serial Port Debugging
Portix sends diagnostic output to COM1 (serial port 0x3F8).Viewing Serial Output
When running with--run, serial output appears in the console:
build/logs/serial.log:
Adding Debug Messages
In your Rust code:Testing Different Boot Modes
ISO (CD-ROM Boot)
Test El Torito bootable CD:- QEMU boots from CD-ROM
- El Torito HD emulation loads bootloader
- System boots identically to disk image
Ventoy Simulation
Test Ventoy compatibility:Performance Testing
Measuring Boot Time
Add timing code to the kernel:Memory Allocation Performance
Test allocator speed:Common Issues
QEMU shows 'Boot failed'
QEMU shows 'Boot failed'
- Check that boot sector ends with
0x55AA - Verify stage2 LBA is correct in boot.bin
- Try
-boot cinstead of auto-detection
Triple fault on boot
Triple fault on boot
- Enable interrupt logging:
-d int -D qemu.log - Check IDT initialization in
arch/idt.rs - Verify GDT is set up correctly
- Check for stack overflow
VirtualBox shows black screen
VirtualBox shows black screen
- Disable EFI in VM settings
- Verify video memory is at least 8 MB
- Check that framebuffer is initialized
- Try with ‘VBoxVGA’ graphics controller
No serial output
No serial output
- Verify COM1 initialization:
drivers::serial::init() - Check that
-serial stdiois passed to QEMU - Look for output in
build/logs/serial.log
Page fault on startup
Page fault on startup
- Check page tables are identity-mapped
- Verify kernel is loaded at correct address
- Use GDB to examine CR2 (fault address)
Testing Checklist
Before submitting changes, verify:- Kernel builds without warnings
- Boots successfully in QEMU
- Boots successfully in VirtualBox
- Serial output shows no errors
- All tabs are accessible (F1-F5)
- Keyboard input works
- Mouse cursor moves
- Terminal accepts commands
- File explorer shows FAT32 contents
- No memory leaks (check allocator stats)
- No triple faults or panics
Next Steps
Contributing
Ready to contribute? Read the guidelines
Architecture
Understand the system architecture