mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: blk: 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
ff9c8b847f
commit
be946caf4b
@@ -1181,9 +1181,13 @@ impl DeviceManager {
|
||||
&mut self,
|
||||
disk_cfg: &mut DiskConfig,
|
||||
) -> DeviceManagerResult<(VirtioDeviceArc, bool, Option<String>)> {
|
||||
if disk_cfg.id.is_none() {
|
||||
disk_cfg.id = Some(self.next_device_name(DISK_DEVICE_NAME_PREFIX)?);
|
||||
}
|
||||
let id = if let Some(id) = &disk_cfg.id {
|
||||
id.clone()
|
||||
} else {
|
||||
let id = self.next_device_name(DISK_DEVICE_NAME_PREFIX)?;
|
||||
disk_cfg.id = Some(id.clone());
|
||||
id
|
||||
};
|
||||
|
||||
if disk_cfg.vhost_user {
|
||||
let sock = if let Some(sock) = disk_cfg.vhost_socket.clone() {
|
||||
@@ -1235,6 +1239,7 @@ impl DeviceManager {
|
||||
match image_type {
|
||||
ImageType::Raw => {
|
||||
let dev = vm_virtio::Block::new(
|
||||
id,
|
||||
raw_img,
|
||||
disk_cfg
|
||||
.path
|
||||
@@ -1262,6 +1267,7 @@ impl DeviceManager {
|
||||
let qcow_img =
|
||||
QcowFile::from(raw_img).map_err(DeviceManagerError::QcowDeviceCreate)?;
|
||||
let dev = vm_virtio::Block::new(
|
||||
id,
|
||||
qcow_img,
|
||||
disk_cfg
|
||||
.path
|
||||
|
||||
Reference in New Issue
Block a user