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:
Sebastien Boeuf
2020-04-27 13:53:45 +02:00
committed by Rob Bradford
parent ec5ff395cf
commit bb7fa71fcb
2 changed files with 16 additions and 4 deletions

View File

@@ -1458,9 +1458,13 @@ impl DeviceManager {
&mut self,
fs_cfg: &mut FsConfig,
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
if fs_cfg.id.is_none() {
fs_cfg.id = Some(self.next_device_name(FS_DEVICE_NAME_PREFIX)?);
}
let id = if let Some(id) = &fs_cfg.id {
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() {
let cache = if fs_cfg.dax {
@@ -1519,6 +1523,7 @@ impl DeviceManager {
let virtio_fs_device = Arc::new(Mutex::new(
vm_virtio::vhost_user::Fs::new(
id,
fs_sock,
&fs_cfg.tag,
fs_cfg.num_queues,