mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-18 10:35:23 +00:00
virtio-devices: vhost_user: Store ability to migrate
Adding a simple field `migration_support` to VhostUserHandle in order to store the information about the device supporting migration or not. The value of this flag depends on the feature set negotiated with the backend. It's considered as supporting migration if VHOST_F_LOG_ALL is present in the virtio features and if VHOST_USER_PROTOCOL_F_LOG_SHMFD is present in the vhost-user protocol features. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
c1b962048c
commit
61994cdb14
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1127,6 +1127,7 @@ source = "git+https://github.com/rust-vmm/vhost?branch=master#37a6a8e46444e9e4b5
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"vm-memory",
|
||||
"vmm-sys-util",
|
||||
]
|
||||
|
||||
|
@ -29,7 +29,7 @@ serde_derive = ">=1.0.27"
|
||||
serde_json = ">=1.0.9"
|
||||
versionize = "0.1.6"
|
||||
versionize_derive = "0.1.4"
|
||||
vhost = { git = "https://github.com/rust-vmm/vhost", branch = "master", package = "vhost", features = ["vhost-user-master", "vhost-user-slave"] }
|
||||
vhost = { git = "https://github.com/rust-vmm/vhost", branch = "master", package = "vhost", features = ["vhost-user-master", "vhost-user-slave", "vhost-kern"] }
|
||||
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
|
||||
vm-allocator = { path = "../vm-allocator" }
|
||||
vm-device = { path = "../vm-device" }
|
||||
|
@ -32,6 +32,7 @@ pub struct VhostUserConfig {
|
||||
pub struct VhostUserHandle {
|
||||
vu: Master,
|
||||
ready: bool,
|
||||
supports_migration: bool,
|
||||
}
|
||||
|
||||
impl VhostUserHandle {
|
||||
@ -120,6 +121,8 @@ impl VhostUserHandle {
|
||||
self.vu.set_hdr_flags(VhostUserHeaderFlag::NEED_REPLY);
|
||||
}
|
||||
|
||||
self.update_supports_migration(acked_features, acked_protocol_features.bits());
|
||||
|
||||
Ok((acked_features, acked_protocol_features.bits()))
|
||||
}
|
||||
|
||||
@ -284,6 +287,8 @@ impl VhostUserHandle {
|
||||
}
|
||||
}
|
||||
|
||||
self.update_supports_migration(acked_features, acked_protocol_features);
|
||||
|
||||
self.setup_vhost_user(
|
||||
mem,
|
||||
queues,
|
||||
@ -314,6 +319,7 @@ impl VhostUserHandle {
|
||||
Ok(VhostUserHandle {
|
||||
vu: Master::from_stream(stream, num_queues),
|
||||
ready: false,
|
||||
supports_migration: false,
|
||||
})
|
||||
} else {
|
||||
let now = Instant::now();
|
||||
@ -325,6 +331,7 @@ impl VhostUserHandle {
|
||||
return Ok(VhostUserHandle {
|
||||
vu: m,
|
||||
ready: false,
|
||||
supports_migration: false,
|
||||
})
|
||||
}
|
||||
Err(e) => e,
|
||||
@ -363,4 +370,12 @@ impl VhostUserHandle {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_supports_migration(&mut self, acked_features: u64, acked_protocol_features: u64) {
|
||||
if (acked_features & u64::from(vhost::vhost_kern::vhost_binding::VHOST_F_LOG_ALL) != 0)
|
||||
&& (acked_protocol_features & VhostUserProtocolFeatures::LOG_SHMFD.bits() != 0)
|
||||
{
|
||||
self.supports_migration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user