mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: vhost_user: Consolidate device State into VhostUserState
Each vhost-user device type had near identical State structs. Deduplicate those by introducing a new common struct (and parameterising it when it needs to embed a config member.) This will make it easier to reuse more code in the future and to add more struct members to handle the requirements of snapshot/restore. These changes have been designed to have no impact on the existing snapshot/restore state. Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -9,7 +9,6 @@ use event_monitor::event;
|
||||
use log::{error, info};
|
||||
use net_util::{CtrlQueue, MacAddr, VirtioNetConfig, build_net_config_space};
|
||||
use seccompiler::SeccompAction;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
|
||||
use vhost::vhost_user::{FrontendReqHandler, VhostUserFrontend, VhostUserFrontendReqHandler};
|
||||
use virtio_bindings::virtio_net::{
|
||||
@@ -28,7 +27,7 @@ use vmm_sys_util::eventfd::EventFd;
|
||||
use crate::seccomp_filters::Thread;
|
||||
use crate::thread_helper::spawn_virtio_thread;
|
||||
use crate::vhost_user::vu_common_ctrl::{VhostUserConfig, VhostUserHandle};
|
||||
use crate::vhost_user::{DEFAULT_VIRTIO_FEATURES, Error, Result, VhostUserCommon};
|
||||
use crate::vhost_user::{DEFAULT_VIRTIO_FEATURES, Error, Result, VhostUserCommon, VhostUserState};
|
||||
use crate::{
|
||||
ActivateResult, GuestMemoryMmap, GuestRegionMmap, NetCtrlEpollHandler,
|
||||
VIRTIO_F_ACCESS_PLATFORM, VirtioCommon, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
|
||||
@@ -36,14 +35,7 @@ use crate::{
|
||||
|
||||
const DEFAULT_QUEUE_NUMBER: usize = 2;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct State {
|
||||
pub avail_features: u64,
|
||||
pub acked_features: u64,
|
||||
pub config: VirtioNetConfig,
|
||||
pub acked_protocol_features: u64,
|
||||
pub vu_num_queues: usize,
|
||||
}
|
||||
pub type State = VhostUserState<VirtioNetConfig>;
|
||||
|
||||
struct BackendReqHandler {}
|
||||
impl VhostUserFrontendReqHandler for BackendReqHandler {}
|
||||
@@ -235,6 +227,7 @@ impl Net {
|
||||
config: self.config,
|
||||
acked_protocol_features: self.vu_common.acked_protocol_features,
|
||||
vu_num_queues: self.vu_common.vu_num_queues,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user