mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: migration: prepare EventFd for async migration events
This is a pre-requisite for the following commit which puts the migration into a dedicated thread. It allows the VMM to react to migration events (success/failure). The commit series was inspired by @ljcore [0] but was changed quite significantly. [0] https://github.com/cloud-hypervisor/cloud-hypervisor/pull/7038 On-behalf-of: SAP philipp.schuster@sap.com Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
This commit is contained in:
committed by
Bo Chen
parent
e034567690
commit
5d835bdff4
@@ -267,6 +267,7 @@ pub enum EpollDispatch {
|
|||||||
ActivateVirtioDevices = 3,
|
ActivateVirtioDevices = 3,
|
||||||
Debug = 4,
|
Debug = 4,
|
||||||
GuestExit = 5,
|
GuestExit = 5,
|
||||||
|
CheckMigration = 6,
|
||||||
Unknown,
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,6 +281,7 @@ impl From<u64> for EpollDispatch {
|
|||||||
3 => ActivateVirtioDevices,
|
3 => ActivateVirtioDevices,
|
||||||
4 => Debug,
|
4 => Debug,
|
||||||
5 => GuestExit,
|
5 => GuestExit,
|
||||||
|
6 => CheckMigration,
|
||||||
_ => Unknown,
|
_ => Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -684,6 +686,7 @@ pub struct Vmm {
|
|||||||
console_resize_pipe: Option<Arc<File>>,
|
console_resize_pipe: Option<Arc<File>>,
|
||||||
console_info: Option<ConsoleInfo>,
|
console_info: Option<ConsoleInfo>,
|
||||||
no_shutdown: bool,
|
no_shutdown: bool,
|
||||||
|
check_migration_evt: EventFd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Just a wrapper for the data that goes into
|
/// 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 reset_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?;
|
||||||
let guest_exit_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 activate_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?;
|
||||||
|
let check_migration_evt = EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?;
|
||||||
|
|
||||||
epoll
|
epoll
|
||||||
.add_event(&exit_evt, EpollDispatch::Exit)
|
.add_event(&exit_evt, EpollDispatch::Exit)
|
||||||
@@ -879,6 +883,10 @@ impl Vmm {
|
|||||||
.add_event(&debug_evt, EpollDispatch::Debug)
|
.add_event(&debug_evt, EpollDispatch::Debug)
|
||||||
.map_err(Error::Epoll)?;
|
.map_err(Error::Epoll)?;
|
||||||
|
|
||||||
|
epoll
|
||||||
|
.add_event(&check_migration_evt, EpollDispatch::CheckMigration)
|
||||||
|
.map_err(Error::Epoll)?;
|
||||||
|
|
||||||
Ok(Vmm {
|
Ok(Vmm {
|
||||||
epoll,
|
epoll,
|
||||||
exit_evt,
|
exit_evt,
|
||||||
@@ -901,6 +909,7 @@ impl Vmm {
|
|||||||
console_resize_pipe: None,
|
console_resize_pipe: None,
|
||||||
console_info: None,
|
console_info: None,
|
||||||
no_shutdown,
|
no_shutdown,
|
||||||
|
check_migration_evt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1761,6 +1770,9 @@ impl Vmm {
|
|||||||
self.vm.as_mut().unwrap().restore()
|
self.vm.as_mut().unwrap().restore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handles the outcome of the migration thread.
|
||||||
|
fn check_migration(&mut self) {}
|
||||||
|
|
||||||
fn control_loop(
|
fn control_loop(
|
||||||
&mut self,
|
&mut self,
|
||||||
api_receiver: &Receiver<ApiRequest>,
|
api_receiver: &Receiver<ApiRequest>,
|
||||||
@@ -1861,6 +1873,14 @@ impl Vmm {
|
|||||||
}
|
}
|
||||||
#[cfg(not(feature = "guest_debug"))]
|
#[cfg(not(feature = "guest_debug"))]
|
||||||
EpollDispatch::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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user