virtio-devices: vhost_user: Add common migration logic

Adding the common vhost-user code for starting logging dirty pages when
the migration is started, and its counterpart for stopping, as well as
the code in charge of retrieving the bitmap of the dirty pages that have
been logged.

All these functions are meant to be leveraged from vhost-user devices.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-08-02 17:35:06 +02:00
committed by Bo Chen
parent 61994cdb14
commit b3f5630c27
2 changed files with 200 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ use std::sync::{atomic::AtomicBool, Arc, Barrier, Mutex};
use vhost::vhost_user::message::{VhostUserInflight, VhostUserVirtioFeatures};
use vhost::vhost_user::{MasterReqHandler, VhostUserMasterReqHandler};
use vhost::Error as VhostError;
use vm_memory::{Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
use vm_memory::{mmap::MmapRegionError, Error as MmapError, GuestAddressSpace, GuestMemoryAtomic};
use vm_virtio::Error as VirtioError;
use vmm_sys_util::eventfd::EventFd;
use vu_common_ctrl::VhostUserHandle;
@@ -109,6 +109,8 @@ pub enum Error {
VhostUserGetInflight(VhostError),
/// Failed setting inflight shm log.
VhostUserSetInflight(VhostError),
/// Failed setting the log base.
VhostUserSetLogBase(VhostError),
/// Invalid used address.
UsedAddress,
/// Invalid features provided from vhost-user backend
@@ -119,6 +121,18 @@ pub enum Error {
MissingIrqFd,
/// Failed getting the available index.
GetAvailableIndex(VirtioError),
/// Migration is not supported by this vhost-user device.
MigrationNotSupported,
/// Failed creating memfd.
MemfdCreate(io::Error),
/// Failed truncating the file size to the expected size.
SetFileSize(io::Error),
/// Failed to set the seals on the file.
SetSeals(io::Error),
/// Failed creating new mmap region
NewMmapRegion(MmapRegionError),
/// Could not find the shm log region
MissingShmLogRegion,
}
type Result<T> = std::result::Result<T, Error>;