vmm: Fix clippy lints

This PR fixes some clippy lints in the vmm crate.

Signed-off-by: Oliver Anderson <oliver.anderson@cyberus-technology.de>
On-behalf-of: SAP oliver.anderson@sap.com
This commit is contained in:
Oliver Anderson 2025-12-09 14:41:14 +01:00 committed by Rob Bradford
parent 0be7d1bd82
commit 8de24b5f08
2 changed files with 20 additions and 21 deletions

View file

@ -1615,26 +1615,23 @@ impl RequestHandler for Vmm {
fn vm_create(&mut self, config: Box<VmConfig>) -> result::Result<(), VmError> {
// We only store the passed VM config.
// The VM will be created when being asked to boot it.
if self.vm_config.is_none() {
self.vm_config = Some(Arc::new(Mutex::new(*config)));
self.console_info =
Some(pre_create_console_devices(self).map_err(VmError::CreateConsoleDevices)?);
if self
.vm_config
.as_ref()
.unwrap()
.lock()
.unwrap()
.landlock_enable
{
apply_landlock(self.vm_config.as_ref().unwrap().as_ref())
.map_err(VmError::ApplyLandlock)?;
}
Ok(())
} else {
Err(VmError::VmAlreadyCreated)
if self.vm_config.is_some() {
return Err(VmError::VmAlreadyCreated);
}
self.vm_config = Some(Arc::new(Mutex::new(*config)));
self.console_info =
Some(pre_create_console_devices(self).map_err(VmError::CreateConsoleDevices)?);
if self
.vm_config
.as_ref()
.is_some_and(|config| config.lock().unwrap().landlock_enable)
{
apply_landlock(self.vm_config.as_ref().unwrap().as_ref())
.map_err(VmError::ApplyLandlock)?;
}
Ok(())
}
fn vm_boot(&mut self) -> result::Result<(), VmError> {

View file

@ -408,8 +408,10 @@ fn memory_zone_get_align_size(zone: &MemoryZoneConfig) -> Result<u64, Error> {
}
// The `hugepages` is enabled and the `hugepage_size` is specified, just use it directly.
if zone.hugepages && zone.hugepage_size.is_some() {
return Ok(zone.hugepage_size.unwrap());
if let Some(hugepage_size) = zone.hugepage_size
&& zone.hugepages
{
return Ok(hugepage_size);
}
// There are two scenarios here: