vmm, virtio-devices: Restore vhost-user devices in a dedicated way

We cannot let vhost-user devices connect to the backend when the Block,
Fs or Net object is being created during a restore/migration. The reason
is we can't have two VMs (source and destination) connected to the same
backend at the same time. That's why we must delay the connection with
the vhost-user backend until the restoration is performed.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-08-09 14:02:30 +02:00
committed by Bo Chen
parent a636411522
commit 4735cb8563
4 changed files with 176 additions and 2 deletions

View File

@@ -1864,7 +1864,7 @@ impl DeviceManager {
queue_size: disk_cfg.queue_size,
};
let vhost_user_block_device = Arc::new(Mutex::new(
match virtio_devices::vhost_user::Blk::new(id.clone(), vu_cfg) {
match virtio_devices::vhost_user::Blk::new(id.clone(), vu_cfg, self.restoring) {
Ok(vub_device) => vub_device,
Err(e) => {
return Err(DeviceManagerError::CreateVhostUserBlk(e));
@@ -2021,6 +2021,7 @@ impl DeviceManager {
vu_cfg,
server,
self.seccomp_action.clone(),
self.restoring,
) {
Ok(vun_device) => vun_device,
Err(e) => {
@@ -2288,6 +2289,7 @@ impl DeviceManager {
fs_cfg.queue_size,
cache,
self.seccomp_action.clone(),
self.restoring,
)
.map_err(DeviceManagerError::CreateVirtioFs)?,
));