mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
virtio-devices: vhost_user: Make vhost-user handle optional
This anticipates the need for creating a new Blk, Fs or Net object without having performed the connection with the vhost-user backend yet. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
06729bb3ba
commit
a738808604
@ -53,7 +53,7 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {}
|
||||
pub struct Blk {
|
||||
common: VirtioCommon,
|
||||
id: String,
|
||||
vu: Arc<Mutex<VhostUserHandle>>,
|
||||
vu: Option<Arc<Mutex<VhostUserHandle>>>,
|
||||
config: VirtioBlockConfig,
|
||||
guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>,
|
||||
acked_protocol_features: u64,
|
||||
@ -140,7 +140,7 @@ impl Blk {
|
||||
..Default::default()
|
||||
},
|
||||
id,
|
||||
vu: Arc::new(Mutex::new(vu)),
|
||||
vu: Some(Arc::new(Mutex::new(vu))),
|
||||
config,
|
||||
guest_memory: None,
|
||||
acked_protocol_features,
|
||||
@ -211,8 +211,8 @@ impl VirtioDevice for Blk {
|
||||
}
|
||||
|
||||
self.config.writeback = data[0];
|
||||
if let Err(e) = self
|
||||
.vu
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Err(e) = vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.socket_handle()
|
||||
@ -222,6 +222,7 @@ impl VirtioDevice for Blk {
|
||||
error!("Failed setting vhost-user-blk configuration: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(
|
||||
&mut self,
|
||||
@ -249,8 +250,12 @@ impl VirtioDevice for Blk {
|
||||
None
|
||||
};
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if self.vu.is_none() {
|
||||
error!("Missing vhost-user handle");
|
||||
return Err(ActivateError::BadActivate);
|
||||
}
|
||||
let vu = self.vu.as_ref().unwrap();
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.setup_vhost_user(
|
||||
&mem.memory(),
|
||||
@ -268,7 +273,7 @@ impl VirtioDevice for Blk {
|
||||
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
||||
|
||||
let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
|
||||
vu: self.vu.clone(),
|
||||
vu: vu.clone(),
|
||||
mem,
|
||||
kill_evt,
|
||||
pause_evt,
|
||||
@ -308,8 +313,8 @@ impl VirtioDevice for Blk {
|
||||
self.common.resume().ok()?;
|
||||
}
|
||||
|
||||
if let Err(e) = self
|
||||
.vu
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Err(e) = vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.reset_vhost_user(self.common.queue_sizes.len())
|
||||
@ -317,6 +322,7 @@ impl VirtioDevice for Blk {
|
||||
error!("Failed to reset vhost-user daemon: {:?}", e);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(kill_evt) = self.common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
@ -330,41 +336,46 @@ impl VirtioDevice for Blk {
|
||||
}
|
||||
|
||||
fn shutdown(&mut self) {
|
||||
let _ = unsafe { libc::close(self.vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
if let Some(vu) = &self.vu {
|
||||
let _ = unsafe { libc::close(vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
}
|
||||
}
|
||||
|
||||
fn add_memory_region(
|
||||
&mut self,
|
||||
region: &Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), crate::Error> {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits() != 0
|
||||
if let Some(vu) = &self.vu {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits()
|
||||
!= 0
|
||||
{
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_memory_region(region)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion);
|
||||
} else if let Some(guest_memory) = &self.guest_memory {
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_mem_table(guest_memory.memory().deref())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory)
|
||||
} else {
|
||||
Ok(())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Blk {
|
||||
fn pause(&mut self) -> result::Result<(), MigratableError> {
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.pause_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Pause(anyhow!("Error pausing vhost-user-blk backend: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
|
||||
self.common.pause()
|
||||
}
|
||||
@ -376,13 +387,19 @@ impl Pausable for Blk {
|
||||
epoll_thread.thread().unpark();
|
||||
}
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.resume_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Resume(anyhow!("Error resuming vhost-user-blk backend: {:?}", e))
|
||||
MigratableError::Resume(anyhow!(
|
||||
"Error resuming vhost-user-blk backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,10 +421,10 @@ impl Transportable for Blk {}
|
||||
|
||||
impl Migratable for Blk {
|
||||
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.start_dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
@ -421,25 +438,29 @@ impl Migratable for Blk {
|
||||
"Missing guest memory"
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
MigratableError::StopDirtyLog(anyhow!(
|
||||
"Error stopping migration for vhost-user-blk backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
vu.lock().unwrap().dirty_log(last_ram_addr).map_err(|e| {
|
||||
MigratableError::DirtyLog(anyhow!(
|
||||
"Error retrieving dirty ranges from vhost-user-blk backend: {:?}",
|
||||
e
|
||||
@ -448,5 +469,8 @@ impl Migratable for Blk {
|
||||
} else {
|
||||
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
|
||||
}
|
||||
} else {
|
||||
Ok(MemoryRangeTable::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ unsafe impl ByteValued for VirtioFsConfig {}
|
||||
pub struct Fs {
|
||||
common: VirtioCommon,
|
||||
id: String,
|
||||
vu: Arc<Mutex<VhostUserHandle>>,
|
||||
vu: Option<Arc<Mutex<VhostUserHandle>>>,
|
||||
config: VirtioFsConfig,
|
||||
// Hold ownership of the memory that is allocated for the device
|
||||
// which will be automatically dropped when the device is dropped
|
||||
@ -388,7 +388,7 @@ impl Fs {
|
||||
..Default::default()
|
||||
},
|
||||
id,
|
||||
vu: Arc::new(Mutex::new(vu)),
|
||||
vu: Some(Arc::new(Mutex::new(vu))),
|
||||
config,
|
||||
cache,
|
||||
slave_req_support,
|
||||
@ -493,8 +493,12 @@ impl VirtioDevice for Fs {
|
||||
None
|
||||
};
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if self.vu.is_none() {
|
||||
error!("Missing vhost-user handle");
|
||||
return Err(ActivateError::BadActivate);
|
||||
}
|
||||
let vu = self.vu.as_ref().unwrap();
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.setup_vhost_user(
|
||||
&mem.memory(),
|
||||
@ -511,7 +515,7 @@ impl VirtioDevice for Fs {
|
||||
// the backend as well as requests initiated by the backend.
|
||||
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
||||
let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
|
||||
vu: self.vu.clone(),
|
||||
vu: vu.clone(),
|
||||
mem,
|
||||
kill_evt,
|
||||
pause_evt,
|
||||
@ -558,8 +562,8 @@ impl VirtioDevice for Fs {
|
||||
self.common.resume().ok()?;
|
||||
}
|
||||
|
||||
if let Err(e) = self
|
||||
.vu
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Err(e) = vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.reset_vhost_user(self.common.queue_sizes.len())
|
||||
@ -567,6 +571,7 @@ impl VirtioDevice for Fs {
|
||||
error!("Failed to reset vhost-user daemon: {:?}", e);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(kill_evt) = self.common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
@ -580,7 +585,9 @@ impl VirtioDevice for Fs {
|
||||
}
|
||||
|
||||
fn shutdown(&mut self) {
|
||||
let _ = unsafe { libc::close(self.vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
if let Some(vu) = &self.vu {
|
||||
let _ = unsafe { libc::close(vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
}
|
||||
}
|
||||
|
||||
fn get_shm_regions(&self) -> Option<VirtioSharedMemoryList> {
|
||||
@ -603,23 +610,25 @@ impl VirtioDevice for Fs {
|
||||
&mut self,
|
||||
region: &Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), crate::Error> {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits() != 0
|
||||
if let Some(vu) = &self.vu {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits()
|
||||
!= 0
|
||||
{
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_memory_region(region)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion);
|
||||
} else if let Some(guest_memory) = &self.guest_memory {
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_mem_table(guest_memory.memory().deref())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory)
|
||||
} else {
|
||||
Ok(())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn userspace_mappings(&self) -> Vec<UserspaceMapping> {
|
||||
let mut mappings = Vec::new();
|
||||
@ -639,13 +648,14 @@ impl VirtioDevice for Fs {
|
||||
|
||||
impl Pausable for Fs {
|
||||
fn pause(&mut self) -> result::Result<(), MigratableError> {
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.pause_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Pause(anyhow!("Error pausing vhost-user-fs backend: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
|
||||
self.common.pause()
|
||||
}
|
||||
@ -657,13 +667,19 @@ impl Pausable for Fs {
|
||||
epoll_thread.thread().unpark();
|
||||
}
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.resume_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Resume(anyhow!("Error resuming vhost-user-fs backend: {:?}", e))
|
||||
MigratableError::Resume(anyhow!(
|
||||
"Error resuming vhost-user-fs backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,10 +701,10 @@ impl Transportable for Fs {}
|
||||
|
||||
impl Migratable for Fs {
|
||||
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.start_dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
@ -702,25 +718,29 @@ impl Migratable for Fs {
|
||||
"Missing guest memory"
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
MigratableError::StopDirtyLog(anyhow!(
|
||||
"Error stopping migration for vhost-user-fs backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
vu.lock().unwrap().dirty_log(last_ram_addr).map_err(|e| {
|
||||
MigratableError::DirtyLog(anyhow!(
|
||||
"Error retrieving dirty ranges from vhost-user-fs backend: {:?}",
|
||||
e
|
||||
@ -729,5 +749,8 @@ impl Migratable for Fs {
|
||||
} else {
|
||||
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
|
||||
}
|
||||
} else {
|
||||
Ok(MemoryRangeTable::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl EpollHelperHandler for NetCtrlEpollHandler {
|
||||
pub struct Net {
|
||||
common: VirtioCommon,
|
||||
id: String,
|
||||
vu: Arc<Mutex<VhostUserHandle>>,
|
||||
vu: Option<Arc<Mutex<VhostUserHandle>>>,
|
||||
config: VirtioNetConfig,
|
||||
guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>,
|
||||
acked_protocol_features: u64,
|
||||
@ -198,7 +198,7 @@ impl Net {
|
||||
min_queues: DEFAULT_QUEUE_NUMBER as u16,
|
||||
..Default::default()
|
||||
},
|
||||
vu: Arc::new(Mutex::new(vu)),
|
||||
vu: Some(Arc::new(Mutex::new(vu))),
|
||||
config,
|
||||
guest_memory: None,
|
||||
acked_protocol_features,
|
||||
@ -327,8 +327,12 @@ impl VirtioDevice for Net {
|
||||
None
|
||||
};
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if self.vu.is_none() {
|
||||
error!("Missing vhost-user handle");
|
||||
return Err(ActivateError::BadActivate);
|
||||
}
|
||||
let vu = self.vu.as_ref().unwrap();
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.setup_vhost_user(
|
||||
&mem.memory(),
|
||||
@ -346,7 +350,7 @@ impl VirtioDevice for Net {
|
||||
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
||||
|
||||
let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
|
||||
vu: self.vu.clone(),
|
||||
vu: vu.clone(),
|
||||
mem,
|
||||
kill_evt,
|
||||
pause_evt,
|
||||
@ -386,8 +390,8 @@ impl VirtioDevice for Net {
|
||||
self.common.resume().ok()?;
|
||||
}
|
||||
|
||||
if let Err(e) = self
|
||||
.vu
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Err(e) = vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.reset_vhost_user(self.common.queue_sizes.len())
|
||||
@ -395,6 +399,7 @@ impl VirtioDevice for Net {
|
||||
error!("Failed to reset vhost-user daemon: {:?}", e);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(kill_evt) = self.common.kill_evt.take() {
|
||||
// Ignore the result because there is nothing we can do about it.
|
||||
@ -408,7 +413,9 @@ impl VirtioDevice for Net {
|
||||
}
|
||||
|
||||
fn shutdown(&mut self) {
|
||||
let _ = unsafe { libc::close(self.vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
if let Some(vu) = &self.vu {
|
||||
let _ = unsafe { libc::close(vu.lock().unwrap().socket_handle().as_raw_fd()) };
|
||||
}
|
||||
|
||||
// Remove socket path if needed
|
||||
if self.server {
|
||||
@ -420,34 +427,37 @@ impl VirtioDevice for Net {
|
||||
&mut self,
|
||||
region: &Arc<GuestRegionMmap>,
|
||||
) -> std::result::Result<(), crate::Error> {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits() != 0
|
||||
if let Some(vu) = &self.vu {
|
||||
if self.acked_protocol_features & VhostUserProtocolFeatures::CONFIGURE_MEM_SLOTS.bits()
|
||||
!= 0
|
||||
{
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_memory_region(region)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion)
|
||||
.map_err(crate::Error::VhostUserAddMemoryRegion);
|
||||
} else if let Some(guest_memory) = &self.guest_memory {
|
||||
self.vu
|
||||
return vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.update_mem_table(guest_memory.memory().deref())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory)
|
||||
} else {
|
||||
Ok(())
|
||||
.map_err(crate::Error::VhostUserUpdateMemory);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Net {
|
||||
fn pause(&mut self) -> result::Result<(), MigratableError> {
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.pause_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Pause(anyhow!("Error pausing vhost-user-net backend: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
|
||||
self.common.pause()
|
||||
}
|
||||
@ -463,13 +473,19 @@ impl Pausable for Net {
|
||||
ctrl_queue_epoll_thread.thread().unpark();
|
||||
}
|
||||
|
||||
self.vu
|
||||
.lock()
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.resume_vhost_user(self.vu_num_queues)
|
||||
.map_err(|e| {
|
||||
MigratableError::Resume(anyhow!("Error resuming vhost-user-net backend: {:?}", e))
|
||||
MigratableError::Resume(anyhow!(
|
||||
"Error resuming vhost-user-net backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,10 +507,10 @@ impl Transportable for Net {}
|
||||
|
||||
impl Migratable for Net {
|
||||
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
vu.lock()
|
||||
.unwrap()
|
||||
.start_dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
@ -508,25 +524,29 @@ impl Migratable for Net {
|
||||
"Missing guest memory"
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
MigratableError::StopDirtyLog(anyhow!(
|
||||
"Error stopping migration for vhost-user-net backend: {:?}",
|
||||
e
|
||||
))
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
self.vu
|
||||
.lock()
|
||||
.unwrap()
|
||||
.dirty_log(last_ram_addr)
|
||||
.map_err(|e| {
|
||||
vu.lock().unwrap().dirty_log(last_ram_addr).map_err(|e| {
|
||||
MigratableError::DirtyLog(anyhow!(
|
||||
"Error retrieving dirty ranges from vhost-user-net backend: {:?}",
|
||||
e
|
||||
@ -535,5 +555,8 @@ impl Migratable for Net {
|
||||
} else {
|
||||
Err(MigratableError::DirtyLog(anyhow!("Missing guest memory")))
|
||||
}
|
||||
} else {
|
||||
Ok(MemoryRangeTable::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user