@@ -36,6 +36,7 @@ async fn test_real_vm_creation() -> anyhow::Result<()> {
3636 vcpus : 2 , // Dual-core power! ⚡
3737 disk_path : PathBuf :: from ( "/var/lib/gpu-share/images/test-vm-1.qcow2" ) ,
3838 disk_size_gb : 20 , // Room for activities!
39+ gpu_passthrough : None ,
3940 } ;
4041
4142 // Create and verify our new digital pet 🐕
@@ -78,6 +79,10 @@ async fn test_real_gpu_passthrough() -> anyhow::Result<()> {
7879 vcpus : 4 , // Quad-core power for our GPU overlord!
7980 disk_path : PathBuf :: from ( "/var/lib/gpu-share/images/test-gpu-vm.qcow2" ) ,
8081 disk_size_gb : 40 , // Extra space for those GPU drivers! 📦
82+ gpu_passthrough : Some ( GPUConfig {
83+ gpu_id : test_gpu. id . clone ( ) ,
84+ iommu_group : "0" . to_string ( ) , // Default group for testing
85+ } ) ,
8186 } ;
8287
8388 let vm = libvirt. create_vm ( & config) . await ?;
@@ -119,6 +124,7 @@ async fn test_real_metrics_collection() -> anyhow::Result<()> {
119124 vcpus : 2 ,
120125 disk_path : PathBuf :: from ( "/var/lib/gpu-share/images/test-metrics.qcow2" ) ,
121126 disk_size_gb : 20 ,
127+ gpu_passthrough : None ,
122128 } ;
123129
124130 let vm = libvirt. create_vm ( & config) . await ?;
@@ -255,6 +261,7 @@ async fn test_cross_platform_vm_operations() -> anyhow::Result<()> {
255261 vcpus : 2 ,
256262 disk_path : PathBuf :: from ( "/var/lib/gpu-share/images/cross-platform-test.qcow2" ) ,
257263 disk_size_gb : 20 ,
264+ gpu_passthrough : None ,
258265 } ;
259266
260267 // Basic VM operations
@@ -276,4 +283,52 @@ async fn test_cross_platform_vm_operations() -> anyhow::Result<()> {
276283 vm. destroy ( ) ?;
277284 vm. undefine ( ) ?;
278285 Ok ( ( ) )
286+ }
287+
288+ // Test 1: Basic VM Creation
289+ async fn create_basic_vm ( ) -> VMConfig {
290+ VMConfig {
291+ name : "test-vm-basic" . into ( ) ,
292+ memory_kb : 2048 * 1024 ,
293+ vcpus : 2 ,
294+ disk_path : PathBuf :: from ( "/var/lib/libvirt/images/test-vm-basic.qcow2" ) ,
295+ disk_size_gb : 20 ,
296+ gpu_passthrough : None ,
297+ }
298+ }
299+
300+ // Test 2: GPU Passthrough Test
301+ async fn create_gpu_vm ( ) -> VMConfig {
302+ VMConfig {
303+ name : "test-vm-gpu" . into ( ) ,
304+ memory_kb : 4096 * 1024 ,
305+ vcpus : 4 ,
306+ disk_path : PathBuf :: from ( "/var/lib/libvirt/images/test-vm-gpu.qcow2" ) ,
307+ disk_size_gb : 40 ,
308+ gpu_passthrough : Some ( "0000:01:00.0" . into ( ) ) ,
309+ }
310+ }
311+
312+ // Test 3: Big Scale VM
313+ async fn create_large_vm ( ) -> VMConfig {
314+ VMConfig {
315+ name : "test-vm-large" . into ( ) ,
316+ memory_kb : 16384 * 1024 ,
317+ vcpus : 8 ,
318+ disk_path : PathBuf :: from ( "/var/lib/libvirt/images/test-vm-large.qcow2" ) ,
319+ disk_size_gb : 100 ,
320+ gpu_passthrough : None ,
321+ }
322+ }
323+
324+ // Test 4: Edge Case - Minimum Resources
325+ async fn create_minimal_vm ( ) -> VMConfig {
326+ VMConfig {
327+ name : "test-vm-minimal" . into ( ) ,
328+ memory_kb : 512 * 1024 ,
329+ vcpus : 1 ,
330+ disk_path : PathBuf :: from ( "/var/lib/libvirt/images/test-vm-minimal.qcow2" ) ,
331+ disk_size_gb : 10 ,
332+ gpu_passthrough : None ,
333+ }
279334}
0 commit comments