diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 507648728..85e40ab3c 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -267,6 +267,7 @@ pub enum EpollDispatch { ActivateVirtioDevices = 3, Debug = 4, GuestExit = 5, + CheckMigration = 6, Unknown, } @@ -280,6 +281,7 @@ impl From for EpollDispatch { 3 => ActivateVirtioDevices, 4 => Debug, 5 => GuestExit, + 6 => CheckMigration, _ => Unknown, } } @@ -684,6 +686,7 @@ pub struct Vmm { console_resize_pipe: Option>, console_info: Option, no_shutdown: bool, + check_migration_evt: EventFd, } /// Just a wrapper for the data that goes into @@ -853,6 +856,7 @@ impl Vmm { let reset_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?; let guest_exit_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?; let activate_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?; + let check_migration_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?; epoll .add_event(&exit_evt, EpollDispatch::Exit) @@ -879,6 +883,10 @@ impl Vmm { .add_event(&debug_evt, EpollDispatch::Debug) .map_err(Error::Epoll)?; + epoll + .add_event(&check_migration_evt, EpollDispatch::CheckMigration) + .map_err(Error::Epoll)?; + Ok(Vmm { epoll, exit_evt, @@ -901,6 +909,7 @@ impl Vmm { console_resize_pipe: None, console_info: None, no_shutdown, + check_migration_evt, }) } @@ -1761,6 +1770,9 @@ impl Vmm { self.vm.as_mut().unwrap().restore() } + /// Handles the outcome of the migration thread. + fn check_migration(&mut self) {} + fn control_loop( &mut self, api_receiver: &Receiver, @@ -1861,6 +1873,14 @@ impl Vmm { } #[cfg(not(feature = "guest_debug"))] EpollDispatch::Debug => {} + EpollDispatch::CheckMigration => { + info!("VM check migration event"); + // Consume the event. + self.check_migration_evt + .read() + .map_err(Error::EventFdRead)?; + self.check_migration(); + } } } }