From b682e87a99b37c33988593c45e7d9f55ac5e45db Mon Sep 17 00:00:00 2001 From: bmeagherix <118192357+bmeagherix@users.noreply.github.com> Date: Fri, 23 Aug 2024 22:02:43 +0100 Subject: [PATCH] NAS-130796 / 25.04 / Do not allow iSCSI extents to use zvols on boot-pool (#14337) * Do not allow iSCSI extents to use zvols on boot-pool --- src/middlewared/middlewared/plugins/boot.py | 4 ++++ src/middlewared/middlewared/plugins/iscsi_/extents.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/middlewared/middlewared/plugins/boot.py b/src/middlewared/middlewared/plugins/boot.py index 30e1577c92e5b..6b53f6ea11cdb 100644 --- a/src/middlewared/middlewared/plugins/boot.py +++ b/src/middlewared/middlewared/plugins/boot.py @@ -329,6 +329,10 @@ async def check_update_ashift_property(self): if properties: await self.middleware.call('zfs.pool.update', BOOT_POOL_NAME, {'properties': properties}) + @private + async def is_boot_pool_path(self, path): + return path.startswith(f'/dev/zvol/{await self.pool_name()}/') + async def on_config_upload(middleware, path): await middleware.call('boot.update_initramfs', {'database': path}) diff --git a/src/middlewared/middlewared/plugins/iscsi_/extents.py b/src/middlewared/middlewared/plugins/iscsi_/extents.py index c7186baf65d58..ebb317f75a2a4 100755 --- a/src/middlewared/middlewared/plugins/iscsi_/extents.py +++ b/src/middlewared/middlewared/plugins/iscsi_/extents.py @@ -335,6 +335,9 @@ def clean_type_and_path(self, data, schema_name, verrors): if not os.path.exists(device): verrors.add(f'{schema_name}.disk', f'Device {device!r} for volume {zvol_name!r} does not exist') + if self.middleware.call_sync('boot.is_boot_pool_path', device): + verrors.add(f'{schema_name}.disk', 'Disk residing in boot pool cannot be consumed and is not supported') + if '@' in zvol_name and not data['ro']: verrors.add(f'{schema_name}.ro', 'Must be set when disk is a ZFS Snapshot')