| 514 | } |
| 515 | |
| 516 | bool RuntimeManager::StopVm(const std::string& vm_id, std::string* error) { |
| 517 | auto session = FindSession(vm_id); |
| 518 | if (!session) { |
| 519 | if (error) *error = "VM is not running"; |
| 520 | return false; |
| 521 | } |
| 522 | if (session->process_pid > 0) { |
| 523 | session->stop_requested = true; |
| 524 | ::kill(session->process_pid, SIGTERM); |
| 525 | } |
| 526 | session->info.state = VmState::kStopping; |
| 527 | session->info.guest_agent_connected = false; |
| 528 | store_.UpdateRuntime(vm_id, session->info); |
| 529 | NotifyStateChanged(vm_id, session->info); |
| 530 | return true; |
| 531 | } |
| 532 | |
| 533 | bool RuntimeManager::RebootVm(const std::string& vm_id, std::string* error) { |
| 534 | auto session = FindSession(vm_id); |
no test coverage detected