cloudhypervisor module #16

Closed
opened 2025-12-21 11:47:13 +00:00 by thabeta · 2 comments
Owner

Cloud Hypervisor implementation for , providing a modern, secure, and lightweight VMM built on Rust with focus on cloud workloads and security.

Functionality

  • Cloud Hypervisor binary integration
  • Secure VMM with minimal attack surface
  • Cloud-optimized virtualization
  • Hot-plug support (CPU, memory, devices)
  • VFIO support for device assignment
  • Snapshot/restore capabilities
  • Live migration support
  • vhost-user backend support

Module API

Cloud Hypervisor Runtime

  • CloudHypervisorRuntime::new(config: CloudHypervisorConfig) -> Result<Self, CloudHypervisorError> - Create runtime
  • CloudHypervisorRuntime::create_vm(&self, spec: VMSpec) -> Result<VMHandle, CloudHypervisorError> - Create VM
  • CloudHypervisorRuntime::start_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError> - Start VM
  • CloudHypervisorRuntime::stop_vm(&self, handle: &VMHandle, force: bool) -> Result<(), CloudHypervisorError> - Stop VM
  • CloudHypervisorRuntime::pause_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError> - Pause VM
  • CloudHypervisorRuntime::resume_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError> - Resume VM
  • CloudHypervisorRuntime::reset_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError> - Reset VM
  • CloudHypervisorRuntime::resize_memory(&self, handle: &VMHandle, size: u64) -> Result<(), CloudHypervisorError> - Resize memory
  • CloudHypervisorRuntime::add_vcpu(&self, handle: &VMHandle, count: u32) -> Result<(), CloudHypervisorError> - Add vCPU
  • CloudHypervisorRuntime::remove_vcpu(&self, handle: &VMHandle, count: u32) -> Result<(), CloudHypervisorError> - Remove vCPU
  • CloudHypervisorRuntime::get_vm_status(&self, handle: &VMHandle) -> Result<VMStatus, CloudHypervisorError> - Get status

Cloud Hypervisor Process Management

  • CloudHypervisorProcess::new(binary: &str) -> Result<Self, CloudHypervisorError> - Create process
  • CloudHypervisorProcess::with_api_socket(socket: &str) -> Self - Set API socket
  • CloudHypervisorProcess::with_log_file(file: &str) -> Self - Set log file
  • CloudHypervisorProcess::start(&mut self) -> Result<(), CloudHypervisorError> - Start process
  • CloudHypervisorProcess::stop(&mut self) -> Result<(), CloudHypervisorError> - Stop process
  • CloudHypervisorProcess::wait(&self) -> Result<ExitStatus, CloudHypervisorError> - Wait for exit

VM Configuration

  • VMConfig::new() -> Self - Create VM config
  • VMConfig::with_kernel(path: &str) -> Self - Set kernel path
  • VMConfig::with_initramfs(path: &str) -> Self - Set initramfs path
  • VMConfig::with_cmdline(args: Vec<&str>) -> Self - Set kernel cmdline
  • VMConfig::with_cpus(cpus: u32) -> Self - Set CPU count
  • VMConfig::with_memory(size: u64) -> Self - Set memory size
  • VMConfig::with_rng(src: RngSource) -> Self - Set RNG source
  • VMConfig::build() -> VMSpec - Build spec

Device Management

  • add_virtio_blk(&mut self, path: &Path, readonly: bool) -> &mut Self - Add block device
  • add_virtio_net(&mut self, tap: &str) -> &mut Self - Add network device
  • add_virtio_rng(&mut self) -> &mut Self - Add RNG device
  • add_virtio_fs(&mut self, tag: &str, path: &Path) -> &mut Self - Add fs device
  • add_vhost_user_net(&mut self, socket: &str) -> &mut Self - Add vhost-user net
  • add_vhost_user_blk(&mut self, socket: &str) -> &mut Self - Add vhost-user blk
  • add_vfio(&mut self, device: &str) -> &mut Self - Add VFIO device

Snapshot/Restore

  • create_snapshot(&self, vm_id: &str, path: &Path) -> Result<(), CloudHypervisorError> - Create snapshot
  • restore_snapshot(&self, path: &Path) -> Result<VMHandle, CloudHypervisorError> - Restore snapshot
  • list_snapshots(&self, vm_id: &str) -> Result<Vec<SnapshotInfo>, CloudHypervisorError> - List snapshots
  • delete_snapshot(&self, vm_id: &str, name: &str) -> Result<(), CloudHypervisorError> - Delete snapshot

API Client

  • APIClient::new(socket: &Path) -> Result<Self, CloudHypervisorError> - Create API client
  • APIClient::vm_create(&self, config: VMConfig) -> Result<String, CloudHypervisorError> - Create VM
  • APIClient::vm_boot(&self, vm_id: &str) -> Result<(), CloudHypervisorError> - Boot VM
  • APIClient::vm_info(&self, vm_id: &str) -> Result<VMInfo, CloudHypervisorError> - Get VM info
  • APIClient::vm_delete(&self, vm_id: &str) -> Result<(), CloudHypervisorError> - Delete VM
  • APIClient::vm_resize(&self, vm_id: &str, size: u64) -> Result<(), CloudHypervisorError> - Resize VM
  • APIClient::vm_add_device(&self, vm_id: &str, device: DeviceConfig) -> Result<(), CloudHypervisorError> - Add device
  • APIClient::vm_remove_device(&self, vm_id: &str, device: &str) -> Result<(), CloudHypervisorError> - Remove device
Cloud Hypervisor implementation for , providing a modern, secure, and lightweight VMM built on Rust with focus on cloud workloads and security. ## Functionality - Cloud Hypervisor binary integration - Secure VMM with minimal attack surface - Cloud-optimized virtualization - Hot-plug support (CPU, memory, devices) - VFIO support for device assignment - Snapshot/restore capabilities - Live migration support - vhost-user backend support ## Module API ### Cloud Hypervisor Runtime - `CloudHypervisorRuntime::new(config: CloudHypervisorConfig) -> Result<Self, CloudHypervisorError>` - Create runtime - `CloudHypervisorRuntime::create_vm(&self, spec: VMSpec) -> Result<VMHandle, CloudHypervisorError>` - Create VM - `CloudHypervisorRuntime::start_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError>` - Start VM - `CloudHypervisorRuntime::stop_vm(&self, handle: &VMHandle, force: bool) -> Result<(), CloudHypervisorError>` - Stop VM - `CloudHypervisorRuntime::pause_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError>` - Pause VM - `CloudHypervisorRuntime::resume_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError>` - Resume VM - `CloudHypervisorRuntime::reset_vm(&self, handle: &VMHandle) -> Result<(), CloudHypervisorError>` - Reset VM - `CloudHypervisorRuntime::resize_memory(&self, handle: &VMHandle, size: u64) -> Result<(), CloudHypervisorError>` - Resize memory - `CloudHypervisorRuntime::add_vcpu(&self, handle: &VMHandle, count: u32) -> Result<(), CloudHypervisorError>` - Add vCPU - `CloudHypervisorRuntime::remove_vcpu(&self, handle: &VMHandle, count: u32) -> Result<(), CloudHypervisorError>` - Remove vCPU - `CloudHypervisorRuntime::get_vm_status(&self, handle: &VMHandle) -> Result<VMStatus, CloudHypervisorError>` - Get status ### Cloud Hypervisor Process Management - `CloudHypervisorProcess::new(binary: &str) -> Result<Self, CloudHypervisorError>` - Create process - `CloudHypervisorProcess::with_api_socket(socket: &str) -> Self` - Set API socket - `CloudHypervisorProcess::with_log_file(file: &str) -> Self` - Set log file - `CloudHypervisorProcess::start(&mut self) -> Result<(), CloudHypervisorError>` - Start process - `CloudHypervisorProcess::stop(&mut self) -> Result<(), CloudHypervisorError>` - Stop process - `CloudHypervisorProcess::wait(&self) -> Result<ExitStatus, CloudHypervisorError>` - Wait for exit ### VM Configuration - `VMConfig::new() -> Self` - Create VM config - `VMConfig::with_kernel(path: &str) -> Self` - Set kernel path - `VMConfig::with_initramfs(path: &str) -> Self` - Set initramfs path - `VMConfig::with_cmdline(args: Vec<&str>) -> Self` - Set kernel cmdline - `VMConfig::with_cpus(cpus: u32) -> Self` - Set CPU count - `VMConfig::with_memory(size: u64) -> Self` - Set memory size - `VMConfig::with_rng(src: RngSource) -> Self` - Set RNG source - `VMConfig::build() -> VMSpec` - Build spec ### Device Management - `add_virtio_blk(&mut self, path: &Path, readonly: bool) -> &mut Self` - Add block device - `add_virtio_net(&mut self, tap: &str) -> &mut Self` - Add network device - `add_virtio_rng(&mut self) -> &mut Self` - Add RNG device - `add_virtio_fs(&mut self, tag: &str, path: &Path) -> &mut Self` - Add fs device - `add_vhost_user_net(&mut self, socket: &str) -> &mut Self` - Add vhost-user net - `add_vhost_user_blk(&mut self, socket: &str) -> &mut Self` - Add vhost-user blk - `add_vfio(&mut self, device: &str) -> &mut Self` - Add VFIO device ### Snapshot/Restore - `create_snapshot(&self, vm_id: &str, path: &Path) -> Result<(), CloudHypervisorError>` - Create snapshot - `restore_snapshot(&self, path: &Path) -> Result<VMHandle, CloudHypervisorError>` - Restore snapshot - `list_snapshots(&self, vm_id: &str) -> Result<Vec<SnapshotInfo>, CloudHypervisorError>` - List snapshots - `delete_snapshot(&self, vm_id: &str, name: &str) -> Result<(), CloudHypervisorError>` - Delete snapshot ### API Client - `APIClient::new(socket: &Path) -> Result<Self, CloudHypervisorError>` - Create API client - `APIClient::vm_create(&self, config: VMConfig) -> Result<String, CloudHypervisorError>` - Create VM - `APIClient::vm_boot(&self, vm_id: &str) -> Result<(), CloudHypervisorError>` - Boot VM - `APIClient::vm_info(&self, vm_id: &str) -> Result<VMInfo, CloudHypervisorError>` - Get VM info - `APIClient::vm_delete(&self, vm_id: &str) -> Result<(), CloudHypervisorError>` - Delete VM - `APIClient::vm_resize(&self, vm_id: &str, size: u64) -> Result<(), CloudHypervisorError>` - Resize VM - `APIClient::vm_add_device(&self, vm_id: &str, device: DeviceConfig) -> Result<(), CloudHypervisorError>` - Add device - `APIClient::vm_remove_device(&self, vm_id: &str, device: &str) -> Result<(), CloudHypervisorError>` - Remove device
Owner

don't try to do all phase 1 focus on what we need for our usecases

  • e.g. live migration can wait

usecase

  • run ubuntu 24.04 and 25.10 from rhai as preconfigured OS
  • run alpine
  • connect mycelium address
  • nat out to go to internet
  • ssh key
  • start with zinit as first process
  • as part of zinit run herodo with rhaiscript for initial config
  • btrfs filesystem (define max size)
  • mem & cpu max

requirementd

  • rhai scripts which demonstrate all
# don't try to do all phase 1 focus on what we need for our usecases - e.g. live migration can wait ## usecase - run ubuntu 24.04 and 25.10 from rhai as preconfigured OS - run alpine - connect mycelium address - nat out to go to internet - ssh key - start with zinit as first process - as part of zinit run herodo with rhaiscript for initial config - btrfs filesystem (define max size) - mem & cpu max ## requirementd - rhai scripts which demonstrate all
despiegk added this to the priority project 2025-12-21 20:29:03 +00:00
despiegk added this to the now milestone 2025-12-21 20:38:43 +00:00
Owner

also use the builder pattern

also use the builder pattern
despiegk modified the milestone from now to next 2025-12-27 15:08:12 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_research/herolib_rust#16
No description provided.