Skip to content

Commit

Permalink
vmm: pre-create console devices
Browse files Browse the repository at this point in the history
Create console devices before vm_create. This will ensure required
device paths exist on the host and will allow landlock to add relevant
rules to allow cloud-hypervisor to access those devices at runtime.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
  • Loading branch information
praveen-pk committed Apr 22, 2024
1 parent dad55fc commit 0154559
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 56 deletions.
4 changes: 4 additions & 0 deletions fuzz/fuzz_targets/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ impl RequestHandler for StubApiRequestHandler {
mode: ConsoleOutputMode::Null,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
console: ConsoleConfig {
file: None,
mode: ConsoleOutputMode::Tty,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
#[cfg(target_arch = "x86_64")]
debug_console: DebugConsoleConfig::default(),
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,12 +913,16 @@ mod unit_tests {
mode: ConsoleOutputMode::Null,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
console: ConsoleConfig {
file: None,
mode: ConsoleOutputMode::Tty,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
#[cfg(target_arch = "x86_64")]
debug_console: DebugConsoleConfig::default(),
Expand Down
30 changes: 29 additions & 1 deletion vmm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,8 @@ impl ConsoleConfig {
mode,
iommu,
socket,
main_fd: None,
sub_fd: None,
})
}
}
Expand Down Expand Up @@ -1746,7 +1748,13 @@ impl DebugConsoleConfig {
}
}

Ok(Self { file, mode, iobase })
Ok(Self {
file,
mode,
iobase,
main_fd: None,
sub_fd: None,
})
}
}

Expand Down Expand Up @@ -3268,6 +3276,8 @@ mod tests {
iommu: false,
file: None,
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3277,6 +3287,8 @@ mod tests {
iommu: false,
file: None,
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3286,6 +3298,8 @@ mod tests {
iommu: false,
file: None,
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3295,6 +3309,8 @@ mod tests {
iommu: false,
file: None,
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3304,6 +3320,8 @@ mod tests {
iommu: false,
file: Some(PathBuf::from("/tmp/console")),
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3313,6 +3331,8 @@ mod tests {
iommu: true,
file: None,
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3322,6 +3342,8 @@ mod tests {
iommu: true,
file: Some(PathBuf::from("/tmp/console")),
socket: None,
main_fd: None,
sub_fd: None,
}
);
assert_eq!(
Expand All @@ -3331,6 +3353,8 @@ mod tests {
iommu: true,
file: None,
socket: Some(PathBuf::from("/tmp/serial.sock")),
main_fd: None,
sub_fd: None,
}
);
Ok(())
Expand Down Expand Up @@ -3515,12 +3539,16 @@ mod tests {
mode: ConsoleOutputMode::Null,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
console: ConsoleConfig {
file: None,
mode: ConsoleOutputMode::Tty,
iommu: false,
socket: None,
main_fd: None,
sub_fd: None,
},
#[cfg(target_arch = "x86_64")]
debug_console: DebugConsoleConfig::default(),
Expand Down
Loading

0 comments on commit 0154559

Please sign in to comment.