From 5140d1118337696441166ee26b715557490996bb Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Tue, 4 Aug 2026 13:26:43 +0300 Subject: [PATCH] Remove CD-ROM from block devices --- coriolis/osmorphing/osmount/base.py | 8 ++++++-- coriolis/tests/osmorphing/osmount/test_base.py | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/coriolis/osmorphing/osmount/base.py b/coriolis/osmorphing/osmount/base.py index 1d6f824cc..dace5d757 100644 --- a/coriolis/osmorphing/osmount/base.py +++ b/coriolis/osmorphing/osmount/base.py @@ -22,6 +22,9 @@ MAJOR_COLUMN_INDEX = 4 +# lsblk TYPE values that represent migration volumes. +_VOLUME_BLOCK_DEVICE_TYPES = frozenset({"disk"}) + class BaseOSMountTools(object, with_metaclass(abc.ABCMeta)): @@ -443,11 +446,12 @@ def _get_volume_block_devices(self): raw = self._exec_cmd("lsblk -lnao KNAME,TYPE") LOG.debug("All block devices: %s", raw) - # Exclude partitions; each line is " ". + # Include top-level disk devices only. volume_devs = [] for line in raw.splitlines(): parts = line.split() - if len(parts) >= 2 and parts[1] != "part": + if (len(parts) >= 2 + and parts[1] in _VOLUME_BLOCK_DEVICE_TYPES): volume_devs.append("/dev/%s" % parts[0]) LOG.debug("Ignoring block devices: %s", self._ignore_devices) diff --git a/coriolis/tests/osmorphing/osmount/test_base.py b/coriolis/tests/osmorphing/osmount/test_base.py index c4c769115..bed68e850 100644 --- a/coriolis/tests/osmorphing/osmount/test_base.py +++ b/coriolis/tests/osmorphing/osmount/test_base.py @@ -699,6 +699,8 @@ def test__get_volume_block_devices(self, mock_exec_cmd, _mock_test_path): "sdb disk\n" "sdb1 part\n" "sdb2 part\n" + "sr0 rom\n" + "loop0 loop\n" ) mock_exec_cmd.return_value = lsblk_output self.base_os_mount_tools._ignore_devices = ["/dev/sda1"]