vmm: Lock disks after validating state change

On `VM::boot` call, lock disks only after the state change has been
checked for validity. Otherwise, on invalid state change, boot is
aborted, but file locks aren't rolled back.

On-behalf-of: SAP julian.schindel@sap.com
Signed-off-by: Julian Schindel <julian.schindel@cyberus-technology.de>
This commit is contained in:
Julian Schindel
2026-07-22 16:51:27 +02:00
committed by Rob Bradford
parent e0f2d99d6f
commit 4b5e2ef3a0

View File

@@ -2749,14 +2749,6 @@ impl Vm {
return self.resume().map_err(Error::Resume);
}
// We acquire all advisory disk image locks here and not on device creation
// to enable live-migration without locking issues.
self.device_manager
.lock()
.unwrap()
.try_lock_disks()
.map_err(Error::LockingError)?;
let new_state = if self.stop_on_boot {
VmState::BreakPoint
} else {
@@ -2765,6 +2757,14 @@ impl Vm {
current_state.valid_transition(new_state)?;
// We acquire all advisory disk image locks here and not on device creation
// to enable live-migration without locking issues.
self.device_manager
.lock()
.unwrap()
.try_lock_disks()
.map_err(Error::LockingError)?;
#[cfg(feature = "fw_cfg")]
{
let fw_cfg_enabled = self