This project was developed as part of the coursework for the university subject AOR2 (Computer Architecture and Organization 2).
It implements a simple mini-hypervisor using the KVM API with three levels of functionality:
- Version A: Basic hypervisor features
- Version B: Support for multiple virtual machines (VMs)
- Version C: File I/O support for guest VMs
mini_hypervisor– the hypervisor executableguest*.img– guest machine code files
The hypervisor supports:
- Fixed physical memory sizes for the VM: 2 MB, 4 MB or 8 MB
Command line option: -m, --memory <size_MB> - VMs run in 64-bit long mode
- Page size: 4 KB or 2 MB
Command line option: -p, --page <page_size> - Single virtual CPU per VM
- Serial I/O through port
0xE9(1 byte per operation) - Only VMs that terminate with the
hltinstruction are supported - Launching a guest VM:
-g, --guest <file.img>
Example command: ./mini_hypervisor --memory 4 --page 2 --guest guest.img
This version adds support for running multiple VMs:
- Number of VMs is specified via the -g option with a list of guest files
- Each VM runs in its own POSIX thread
Example command: ./mini_hypervisor --memory 4 --page 2 --guest guest1.img guest2.img
This version adds file operations for guest VMs:
- Supports opening, closing, reading and writing files via I/O port 0x0278
- Opening a non-existing file for writing creates that file
- File paths are specified via command line: -f, --file ...
- Copy-on-write: Shared files between VMs are copied locally when a VM writes to prevent conflicts
- Hypervisor ensures that each guest accesses only its own files or allowed shared files
Example command: ./mini_hypervisor -m 4 -p 2 -g guest1.img guest2.img -f ./flowers.png
- The hypervisor runs as a 64-bit process
- Guest programs must terminate using the hlt instruction.
- Each VM is isolated in its own thread with separate virtual memory and I/O
- File handling is managed to prevent conflicts between VMs
- Linux environment
gccmake- POSIX threads support
The hypervisor is built using a provided Makefile. Navigate to the wanted version directory.
- To compile the hypervisor, run: make
- To clean the build artifacts, run: make clean
To build a guest program, navigate to the wanted directory and run: make.
This will:
- Compile guest.c into guest.o
- Link the object file using guest.ld
- Generate the final guest image guest.img
To clean guest build files: make clean.
After building the hypervisor and guest images, run wanted commands and ensure correct file paths to the guest images.