mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: vhost_user: Adapt state() to return Result
This is a refactoring step in preparation for fetching backend device state via SET_DEVICE_STATE_FD which can fail. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -191,7 +191,7 @@ impl Blk {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state(&self) -> State {
|
fn state(&self) -> std::result::Result<State, MigratableError> {
|
||||||
self.vu_common.state(&self.common, self.config)
|
self.vu_common.state(&self.common, self.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ impl Snapshottable for Blk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
self.vu_common.snapshot(&self.state())
|
self.vu_common.snapshot(&self.state()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Blk {}
|
impl Transportable for Blk {}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ impl Fs {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state(&self) -> State {
|
fn state(&self) -> std::result::Result<State, MigratableError> {
|
||||||
self.vu_common.state(&self.common, self.config)
|
self.vu_common.state(&self.common, self.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,7 @@ impl Snapshottable for Fs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
self.vu_common.snapshot(&self.state())
|
self.vu_common.snapshot(&self.state()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Fs {}
|
impl Transportable for Fs {}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ since the backend only supports {backend_num_queues}\n",
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state(&self) -> State {
|
fn state(&self) -> std::result::Result<State, MigratableError> {
|
||||||
self.vu_common.state(&self.common, ())
|
self.vu_common.state(&self.common, ())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ impl Snapshottable for GenericVhostUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
self.vu_common.snapshot(&self.state())
|
self.vu_common.snapshot(&self.state()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for GenericVhostUser {}
|
impl Transportable for GenericVhostUser {}
|
||||||
|
|||||||
@@ -457,15 +457,21 @@ impl VhostUserCommon {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn state<C: Default>(&self, common: &crate::VirtioCommon, config: C) -> VhostUserState<C> {
|
pub fn state<C: Default>(
|
||||||
VhostUserState {
|
&self,
|
||||||
|
common: &crate::VirtioCommon,
|
||||||
|
config: C,
|
||||||
|
) -> std::result::Result<VhostUserState<C>, MigratableError> {
|
||||||
|
let state = VhostUserState {
|
||||||
avail_features: common.avail_features,
|
avail_features: common.avail_features,
|
||||||
acked_features: common.acked_features,
|
acked_features: common.acked_features,
|
||||||
config,
|
config,
|
||||||
acked_protocol_features: self.acked_protocol_features,
|
acked_protocol_features: self.acked_protocol_features,
|
||||||
vu_num_queues: self.vu_num_queues,
|
vu_num_queues: self.vu_num_queues,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn snapshot<T>(&mut self, state: &T) -> std::result::Result<Snapshot, MigratableError>
|
pub fn snapshot<T>(&mut self, state: &T) -> std::result::Result<Snapshot, MigratableError>
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ impl Net {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn state(&self) -> State {
|
fn state(&self) -> std::result::Result<State, MigratableError> {
|
||||||
self.vu_common.state(&self.common, self.config)
|
self.vu_common.state(&self.common, self.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -425,7 +425,7 @@ impl Snapshottable for Net {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||||
self.vu_common.snapshot(&self.state())
|
self.vu_common.snapshot(&self.state()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Transportable for Net {}
|
impl Transportable for Net {}
|
||||||
|
|||||||
Reference in New Issue
Block a user