Skip to content

Commit f0e2849

Browse files
committed
qemu: Remove some dead code
Signed-off-by: Colin Walters <[email protected]>
1 parent c75df35 commit f0e2849

File tree

1 file changed

+0
-118
lines changed

1 file changed

+0
-118
lines changed

crates/kit/src/qemu.rs

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,6 @@ impl QemuConfig {
185185
}
186186
}
187187

188-
/// Create a new config with disk boot
189-
pub fn new_disk_boot(memory_mb: u32, vcpus: u32, primary_disk: String) -> Self {
190-
Self {
191-
memory_mb,
192-
vcpus,
193-
boot_mode: Some(BootMode::DiskBoot {
194-
primary_disk,
195-
uefi: false,
196-
}),
197-
..Default::default()
198-
}
199-
}
200-
201188
// Enable vsock
202189
pub fn enable_vsock(&mut self) -> Result<()> {
203190
let fd = OpenOptions::new()
@@ -278,11 +265,6 @@ impl QemuConfig {
278265
Ok(())
279266
}
280267

281-
/// Add a virtio-blk device
282-
pub fn add_virtio_blk_device(&mut self, disk_file: String, serial: String) -> &mut Self {
283-
self.add_virtio_blk_device_with_format(disk_file, serial, crate::to_disk::Format::Raw)
284-
}
285-
286268
/// Add a virtio-blk device with specified format
287269
pub fn add_virtio_blk_device_with_format(
288270
&mut self,
@@ -315,13 +297,6 @@ impl QemuConfig {
315297
self
316298
}
317299

318-
/// Add a virtiofs mount (for pre-spawned daemons)
319-
pub fn add_virtiofs_mount(&mut self, socket_path: String, tag: String) -> &mut Self {
320-
self.additional_mounts
321-
.push(VirtiofsMount { socket_path, tag });
322-
self
323-
}
324-
325300
/// Add a virtio-serial output device
326301
pub fn add_virtio_serial_out(
327302
&mut self,
@@ -887,40 +862,6 @@ mod tests {
887862
"/tmp/output.txt"
888863
);
889864
}
890-
891-
#[test]
892-
fn test_virtio_blk_device_creation() {
893-
let mut config = QemuConfig::new_disk_boot(1024, 1, "/tmp/boot.img".to_string());
894-
config
895-
.add_virtio_blk_device("/tmp/test.img".to_string(), "output".to_string())
896-
.set_console(true);
897-
898-
// Test that the config is created correctly
899-
assert_eq!(config.virtio_blk_devices.len(), 1);
900-
assert_eq!(config.virtio_blk_devices[0].disk_file, "/tmp/test.img");
901-
assert_eq!(config.virtio_blk_devices[0].serial, "output");
902-
assert_eq!(
903-
config.virtio_blk_devices[0].format,
904-
crate::to_disk::Format::Raw
905-
);
906-
}
907-
908-
#[test]
909-
fn test_disk_boot_config() {
910-
let mut config = QemuConfig::new_disk_boot(2048, 2, "/tmp/disk.img".to_string());
911-
config.set_uefi_boot(true).set_console(false);
912-
913-
if let Some(BootMode::DiskBoot { primary_disk, uefi }) = config.boot_mode.as_ref() {
914-
assert_eq!(primary_disk, "/tmp/disk.img");
915-
assert_eq!(*uefi, true);
916-
} else {
917-
panic!("Expected DiskBoot mode");
918-
}
919-
920-
assert_eq!(config.memory_mb, 2048);
921-
assert_eq!(config.vcpus, 2);
922-
assert_eq!(config.enable_console, false);
923-
}
924865
}
925866

926867
/// VirtiofsD daemon configuration.
@@ -1018,65 +959,6 @@ pub async fn spawn_virtiofsd_async(config: &VirtiofsConfig) -> Result<tokio::pro
1018959
Ok(child)
1019960
}
1020961

1021-
/// Spawn virtiofsd daemon process.
1022-
/// Searches for binary in /usr/libexec, /usr/bin, /usr/local/bin.
1023-
/// Creates socket directory if needed, redirects output unless debug=true.
1024-
pub fn spawn_virtiofsd(config: &VirtiofsConfig) -> Result<Child> {
1025-
// Validate configuration
1026-
validate_virtiofsd_config(config)?;
1027-
1028-
// Try common virtiofsd binary locations
1029-
let virtiofsd_paths = [
1030-
"/usr/libexec/virtiofsd",
1031-
"/usr/bin/virtiofsd",
1032-
"/usr/local/bin/virtiofsd",
1033-
];
1034-
1035-
let virtiofsd_binary = virtiofsd_paths
1036-
.iter()
1037-
.find(|path| std::path::Path::new(path).exists())
1038-
.ok_or_else(|| {
1039-
eyre!(
1040-
"virtiofsd binary not found. Searched paths: {}. Please install virtiofsd.",
1041-
virtiofsd_paths.join(", ")
1042-
)
1043-
})?;
1044-
1045-
let mut cmd = Command::new(virtiofsd_binary);
1046-
cmd.args([
1047-
"--socket-path",
1048-
&config.socket_path,
1049-
"--shared-dir",
1050-
&config.shared_dir,
1051-
"--cache",
1052-
&config.cache_mode,
1053-
"--sandbox",
1054-
&config.sandbox,
1055-
]);
1056-
1057-
// Redirect stdout/stderr to /dev/null unless debug mode is enabled
1058-
if !config.debug {
1059-
cmd.stdout(Stdio::null()).stderr(Stdio::null());
1060-
} else {
1061-
// In debug mode, prefix output to distinguish from QEMU
1062-
cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
1063-
}
1064-
1065-
let child = cmd.spawn().with_context(|| {
1066-
format!(
1067-
"Failed to spawn virtiofsd. Binary: {}, Socket: {}, Shared dir: {}",
1068-
virtiofsd_binary, config.socket_path, config.shared_dir
1069-
)
1070-
})?;
1071-
1072-
debug!(
1073-
"Spawned virtiofsd: binary={}, socket={}, shared_dir={}, debug={}",
1074-
virtiofsd_binary, config.socket_path, config.shared_dir, config.debug
1075-
);
1076-
1077-
Ok(child)
1078-
}
1079-
1080962
/// Wait for virtiofsd socket to become available.
1081963
/// Polls every 100ms until socket exists or timeout.
1082964
pub async fn wait_for_virtiofsd_socket(socket_path: &str, timeout: Duration) -> Result<()> {

0 commit comments

Comments
 (0)