mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-18 10:35:23 +00:00
virtio-devices: vhost_user: Fully implement Migratable trait
All vhost-user devices are now equipped to support migration. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
b3f5630c27
commit
9d88e0b417
@ -29,9 +29,10 @@ use virtio_bindings::bindings::virtio_blk::{
|
|||||||
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX,
|
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_MQ, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_SEG_MAX,
|
||||||
VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_WRITE_ZEROES,
|
VIRTIO_BLK_F_SIZE_MAX, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_WRITE_ZEROES,
|
||||||
};
|
};
|
||||||
use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic};
|
use vm_memory::{Address, ByteValued, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};
|
||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
|
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable,
|
||||||
|
Transportable, VersionMapped,
|
||||||
};
|
};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
@ -399,4 +400,54 @@ impl Snapshottable for Blk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Blk {}
|
impl Transportable for Blk {}
|
||||||
impl Migratable for Blk {}
|
|
||||||
|
impl Migratable for Blk {
|
||||||
|
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
if let Some(guest_memory) = &self.guest_memory {
|
||||||
|
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||||
|
self.vu
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.start_dirty_log(last_ram_addr)
|
||||||
|
.map_err(|e| {
|
||||||
|
MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Error starting migration for vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||||
|
MigratableError::MigrateStop(anyhow!(
|
||||||
|
"Error stopping migration for vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||||
|
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| {
|
||||||
|
MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Error retrieving dirty ranges from vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,7 +32,8 @@ use vm_memory::{
|
|||||||
Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
|
Address, ByteValued, GuestAddress, GuestAddressSpace, GuestMemory, GuestMemoryAtomic,
|
||||||
};
|
};
|
||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
|
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable,
|
||||||
|
Transportable, VersionMapped,
|
||||||
};
|
};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
@ -680,4 +681,54 @@ impl Snapshottable for Fs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Fs {}
|
impl Transportable for Fs {}
|
||||||
impl Migratable for Fs {}
|
|
||||||
|
impl Migratable for Fs {
|
||||||
|
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
if let Some(guest_memory) = &self.guest_memory {
|
||||||
|
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||||
|
self.vu
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.start_dirty_log(last_ram_addr)
|
||||||
|
.map_err(|e| {
|
||||||
|
MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Error starting migration for vhost-user-fs backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||||
|
MigratableError::MigrateStop(anyhow!(
|
||||||
|
"Error stopping migration for vhost-user-fs backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||||
|
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| {
|
||||||
|
MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Error retrieving dirty ranges from vhost-user-fs backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -30,9 +30,10 @@ use virtio_bindings::bindings::virtio_net::{
|
|||||||
VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, VIRTIO_NET_F_HOST_UFO,
|
VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6, VIRTIO_NET_F_HOST_UFO,
|
||||||
VIRTIO_NET_F_MAC, VIRTIO_NET_F_MRG_RXBUF,
|
VIRTIO_NET_F_MAC, VIRTIO_NET_F_MRG_RXBUF,
|
||||||
};
|
};
|
||||||
use vm_memory::{ByteValued, GuestAddressSpace, GuestMemoryAtomic};
|
use vm_memory::{Address, ByteValued, GuestAddressSpace, GuestMemory, GuestMemoryAtomic};
|
||||||
use vm_migration::{
|
use vm_migration::{
|
||||||
Migratable, MigratableError, Pausable, Snapshot, Snapshottable, Transportable, VersionMapped,
|
protocol::MemoryRangeTable, Migratable, MigratableError, Pausable, Snapshot, Snapshottable,
|
||||||
|
Transportable, VersionMapped,
|
||||||
};
|
};
|
||||||
use vmm_sys_util::eventfd::EventFd;
|
use vmm_sys_util::eventfd::EventFd;
|
||||||
|
|
||||||
@ -486,4 +487,54 @@ impl Snapshottable for Net {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Net {}
|
impl Transportable for Net {}
|
||||||
impl Migratable for Net {}
|
|
||||||
|
impl Migratable for Net {
|
||||||
|
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
if let Some(guest_memory) = &self.guest_memory {
|
||||||
|
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||||
|
self.vu
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.start_dirty_log(last_ram_addr)
|
||||||
|
.map_err(|e| {
|
||||||
|
MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Error starting migration for vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateStart(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||||
|
self.vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||||
|
MigratableError::MigrateStop(anyhow!(
|
||||||
|
"Error stopping migration for vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> {
|
||||||
|
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| {
|
||||||
|
MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Error retrieving dirty ranges from vhost-user-blk backend: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(MigratableError::MigrateDirtyRanges(anyhow!(
|
||||||
|
"Missing guest memory"
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user