11//! QEMU virtualization integration and VM management.
22//!
3- //! Supports direct kernel boot and disk image boot with VirtIO devices,
4- //! automatic process cleanup, and SMBIOS credential injection.
3+ //! Supports direct kernel boot with VirtIO devices, automatic process cleanup ,
4+ //! and SMBIOS credential injection.
55
66use std:: fs:: { File , OpenOptions } ;
77use std:: future:: Future ;
@@ -111,7 +111,7 @@ impl Default for ResourceLimits {
111111 }
112112}
113113
114- /// VM boot configuration: direct kernel boot or disk image boot .
114+ /// VM boot configuration: direct kernel boot.
115115#[ derive( Debug ) ]
116116pub enum BootMode {
117117 /// Direct kernel boot (fast, testing-focused)
@@ -122,12 +122,6 @@ pub enum BootMode {
122122 /// VirtIO-FS socket for root filesystem
123123 virtiofs_socket : Utf8PathBuf ,
124124 } ,
125- #[ allow( dead_code) ]
126- DiskBoot {
127- primary_disk : String ,
128- /// Use UEFI instead of BIOS
129- uefi : bool ,
130- } ,
131125}
132126
133127/// Complete QEMU VM configuration with builder pattern.
@@ -153,10 +147,6 @@ pub struct QemuConfig {
153147 pub resource_limits : ResourceLimits ,
154148 /// Deprecated: use display_mode
155149 pub enable_console : bool ,
156- /// UEFI firmware path (auto-detected if None)
157- pub uefi_firmware_path : Option < String > ,
158- /// UEFI variables file
159- pub uefi_vars_path : Option < String > ,
160150 /// SMBIOS credentials for systemd
161151 smbios_credentials : Vec < String > ,
162152
@@ -207,18 +197,6 @@ impl QemuConfig {
207197 self
208198 }
209199
210- /// Enable UEFI boot (only for disk boot)
211- #[ allow( dead_code) ]
212- pub fn set_uefi_boot ( & mut self , uefi : bool ) -> & mut Self {
213- if let Some ( BootMode :: DiskBoot {
214- uefi : uefi_flag, ..
215- } ) = self . boot_mode . as_mut ( )
216- {
217- * uefi_flag = uefi;
218- }
219- self
220- }
221-
222200 /// Enable console output
223201 pub fn set_console ( & mut self , enable : bool ) -> & mut Self {
224202 self . enable_console = enable;
@@ -486,67 +464,6 @@ fn spawn(
486464 let append_str = kernel_cmdline. join ( " " ) ;
487465 cmd. args ( [ "-append" , & append_str] ) ;
488466 }
489- Some ( BootMode :: DiskBoot { primary_disk, uefi } ) => {
490- // Configure UEFI firmware if requested
491- if * uefi {
492- if let Some ( ref firmware_path) = config. uefi_firmware_path {
493- // UEFI firmware configuration
494- cmd. args ( [
495- "-drive" ,
496- & format ! ( "if=pflash,format=raw,readonly=on,file={}" , firmware_path) ,
497- ] ) ;
498-
499- // UEFI variables (if specified)
500- if let Some ( ref vars_path) = config. uefi_vars_path {
501- cmd. args ( [
502- "-drive" ,
503- & format ! ( "if=pflash,format=raw,file={}" , vars_path) ,
504- ] ) ;
505- }
506-
507- // Disable default SeaBIOS
508- cmd. args ( [ "-machine" , "q35" ] ) ;
509- debug ! ( "UEFI boot configured with firmware: {}" , firmware_path) ;
510- } else {
511- // Try to auto-detect UEFI firmware paths
512- let common_uefi_paths = [
513- "/usr/share/edk2/ovmf/OVMF_CODE.fd" ,
514- "/usr/share/OVMF/OVMF_CODE.fd" ,
515- "/usr/share/ovmf/OVMF.fd" ,
516- ] ;
517-
518- let mut found_firmware = None ;
519- for path in & common_uefi_paths {
520- if std:: path:: Path :: new ( path) . exists ( ) {
521- found_firmware = Some ( path) ;
522- break ;
523- }
524- }
525-
526- if let Some ( firmware_path) = found_firmware {
527- cmd. args ( [
528- "-drive" ,
529- & format ! ( "if=pflash,format=raw,readonly=on,file={}" , firmware_path) ,
530- ] ) ;
531- cmd. args ( [ "-machine" , "q35" ] ) ;
532- debug ! (
533- "UEFI boot configured with auto-detected firmware: {}" ,
534- firmware_path
535- ) ;
536- } else {
537- warn ! ( "UEFI boot requested but no firmware found, falling back to BIOS" ) ;
538- }
539- }
540- }
541-
542- // Add primary boot disk
543- cmd. args ( [
544- "-drive" ,
545- & format ! ( "file={},format=raw,if=none,id=boot_drive" , primary_disk) ,
546- "-device" ,
547- "virtio-blk-pci,drive=boot_drive,serial=boot_disk,bootindex=1" ,
548- ] ) ;
549- }
550467 None => { }
551468 }
552469
@@ -693,7 +610,9 @@ struct VsockCopier {
693610
694611pub struct RunningQemu {
695612 pub qemu_process : Child ,
613+ #[ allow( dead_code) ]
696614 pub virtiofsd_processes : Vec < Pin < Box < dyn Future < Output = std:: io:: Result < Output > > > > > ,
615+ #[ allow( dead_code) ]
697616 sd_notification : Option < VsockCopier > ,
698617}
699618
@@ -1042,25 +961,6 @@ pub async fn spawn_virtiofsd_async(config: &VirtiofsConfig) -> Result<tokio::pro
1042961 Ok ( child)
1043962}
1044963
1045- /// Wait for virtiofsd socket to become available.
1046- /// Polls every 100ms until socket exists or timeout.
1047- pub async fn wait_for_virtiofsd_socket ( socket_path : & str , timeout : Duration ) -> Result < ( ) > {
1048- let start = std:: time:: Instant :: now ( ) ;
1049-
1050- while start. elapsed ( ) < timeout {
1051- if std:: path:: Path :: new ( socket_path) . exists ( ) {
1052- debug ! ( "Virtiofsd socket ready: {}" , socket_path) ;
1053- return Ok ( ( ) ) ;
1054- }
1055- tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . await ;
1056- }
1057-
1058- Err ( eyre ! (
1059- "Timeout waiting for virtiofsd socket: {}" ,
1060- socket_path
1061- ) )
1062- }
1063-
1064964/// Validate virtiofsd configuration.
1065965/// Checks shared directory exists/readable, socket path valid,
1066966/// and cache/sandbox modes are valid values.
0 commit comments