MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / valid_transition

Method valid_transition

vmm/src/vm.rs:409–443  ·  view source on GitHub ↗
(self, new_state: VmState)

Source from the content-addressed store, hash-verified

407
408impl VmState {
409 fn valid_transition(self, new_state: VmState) -> Result<()> {
410 match self {
411 VmState::Created => match new_state {
412 VmState::Created => Err(Error::InvalidStateTransition(self, new_state)),
413 VmState::Running | VmState::Paused | VmState::BreakPoint | VmState::Shutdown => {
414 Ok(())
415 }
416 },
417
418 VmState::Running => match new_state {
419 VmState::Created | VmState::Running => {
420 Err(Error::InvalidStateTransition(self, new_state))
421 }
422 VmState::Paused | VmState::Shutdown | VmState::BreakPoint => Ok(()),
423 },
424
425 VmState::Shutdown => match new_state {
426 VmState::Paused | VmState::Created | VmState::Shutdown | VmState::BreakPoint => {
427 Err(Error::InvalidStateTransition(self, new_state))
428 }
429 VmState::Running => Ok(()),
430 },
431
432 VmState::Paused => match new_state {
433 VmState::Created | VmState::Paused | VmState::BreakPoint => {
434 Err(Error::InvalidStateTransition(self, new_state))
435 }
436 VmState::Running | VmState::Shutdown => Ok(()),
437 },
438 VmState::BreakPoint => match new_state {
439 VmState::Created | VmState::Running => Ok(()),
440 _ => Err(Error::InvalidStateTransition(self, new_state)),
441 },
442 }
443 }
444}
445
446struct VmOpsHandler {

Callers 5

shutdownMethod · 0.80
bootMethod · 0.80
pauseMethod · 0.80
resumeMethod · 0.80

Calls

no outgoing calls

Tested by 1