From d9d55b05863293e6142043caa57bee9696c055a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 5 Jul 2020 18:03:01 +0200 Subject: [PATCH] storage: pass a copy of volume_config to pool.init_volume Avoid local modification in a pool's init_volume influence vm.volume_config. Currently every pool driver replaces volume_config['pool'] with a pool object (instead of name) and it leads to confusing cases where depending on start stage, it is sometimes an object and sometimes a string. Additionally, some pool drivers may modify volume_config in unexpected way - for example test pool driver removes 'pool' entry entirely. Avoid this fragile interface by giving pool driver a copy of volume_config, instead of vm.volume_config directly. Note one side effect is that 'vid' (and other pool-specific parameters) is not set into vm.volume_config directly after creating a VM, but possibly only after loading from XML. This should not be an issue in theory (no core code should expect it), but if some place use volume_config instead of Volume instance for getting pool-specific options, it should be fixed. --- qubes/storage/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 03af6312..519c8bf3 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -423,7 +423,7 @@ class Storage: if 'internal' in volume_config: # migrate old config del volume_config['internal'] - volume = pool.init_volume(self.vm, volume_config) + volume = pool.init_volume(self.vm, volume_config.copy()) self.vm.volumes[name] = volume return volume