mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: vhost-user-fs: Expect an identifier upon device creation
This identifier is chosen from the DeviceManager so that it will manage all identifiers across the VM, which will ensure uniqueness. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
ec5ff395cf
commit
bb7fa71fcb
@@ -267,6 +267,7 @@ impl Default for VirtioFsConfig {
|
|||||||
unsafe impl ByteValued for VirtioFsConfig {}
|
unsafe impl ByteValued for VirtioFsConfig {}
|
||||||
|
|
||||||
pub struct Fs {
|
pub struct Fs {
|
||||||
|
id: String,
|
||||||
vu: Master,
|
vu: Master,
|
||||||
queue_sizes: Vec<u16>,
|
queue_sizes: Vec<u16>,
|
||||||
avail_features: u64,
|
avail_features: u64,
|
||||||
@@ -287,6 +288,7 @@ pub struct Fs {
|
|||||||
impl Fs {
|
impl Fs {
|
||||||
/// Create a new virtio-fs device.
|
/// Create a new virtio-fs device.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
id: String,
|
||||||
path: &str,
|
path: &str,
|
||||||
tag: &str,
|
tag: &str,
|
||||||
req_num_queues: usize,
|
req_num_queues: usize,
|
||||||
@@ -352,6 +354,7 @@ impl Fs {
|
|||||||
config.num_request_queues = req_num_queues as u32;
|
config.num_request_queues = req_num_queues as u32;
|
||||||
|
|
||||||
Ok(Fs {
|
Ok(Fs {
|
||||||
|
id,
|
||||||
vu: master,
|
vu: master,
|
||||||
queue_sizes: vec![queue_size; num_queues],
|
queue_sizes: vec![queue_size; num_queues],
|
||||||
avail_features,
|
avail_features,
|
||||||
@@ -605,6 +608,10 @@ impl VirtioDevice for Fs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtio_pausable!(Fs);
|
virtio_pausable!(Fs);
|
||||||
impl Snapshottable for Fs {}
|
impl Snapshottable for Fs {
|
||||||
|
fn id(&self) -> String {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl Transportable for Fs {}
|
impl Transportable for Fs {}
|
||||||
impl Migratable for Fs {}
|
impl Migratable for Fs {}
|
||||||
|
|||||||
@@ -1458,9 +1458,13 @@ impl DeviceManager {
|
|||||||
&mut self,
|
&mut self,
|
||||||
fs_cfg: &mut FsConfig,
|
fs_cfg: &mut FsConfig,
|
||||||
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
||||||
if fs_cfg.id.is_none() {
|
let id = if let Some(id) = &fs_cfg.id {
|
||||||
fs_cfg.id = Some(self.next_device_name(FS_DEVICE_NAME_PREFIX)?);
|
id.clone()
|
||||||
}
|
} else {
|
||||||
|
let id = self.next_device_name(FS_DEVICE_NAME_PREFIX)?;
|
||||||
|
fs_cfg.id = Some(id.clone());
|
||||||
|
id
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(fs_sock) = fs_cfg.sock.to_str() {
|
if let Some(fs_sock) = fs_cfg.sock.to_str() {
|
||||||
let cache = if fs_cfg.dax {
|
let cache = if fs_cfg.dax {
|
||||||
@@ -1519,6 +1523,7 @@ impl DeviceManager {
|
|||||||
|
|
||||||
let virtio_fs_device = Arc::new(Mutex::new(
|
let virtio_fs_device = Arc::new(Mutex::new(
|
||||||
vm_virtio::vhost_user::Fs::new(
|
vm_virtio::vhost_user::Fs::new(
|
||||||
|
id,
|
||||||
fs_sock,
|
fs_sock,
|
||||||
&fs_cfg.tag,
|
&fs_cfg.tag,
|
||||||
fs_cfg.num_queues,
|
fs_cfg.num_queues,
|
||||||
|
|||||||
Reference in New Issue
Block a user