Merge pull request #1808 from ogayot/early-v2-orig-config

filesystem: don't crash if v2/orig_config is called early
This commit is contained in:
Olivier Gayot 2023-09-27 09:05:58 +02:00 committed by GitHub
commit f951146d6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -1435,6 +1435,7 @@ class FilesystemModel:
# use on the V2 storage API.
orig_model = FilesystemModel(self.bootloader, root=self.root)
orig_model.target = self.target
if self._probe_data is not None:
orig_model.load_probe_data(self._probe_data)
return orig_model

View File

@ -328,6 +328,15 @@ class TestFilesystemModel(unittest.TestCase):
self.assertFalse(lv.ok_for_raid)
self.assertFalse(lv.ok_for_lvm_vg)
def test_get_orig_model_no_probe_data(self):
# When v2/get_orig_data gets called early, model._probe_data is still
# None. Ensure get_orig_model() does not fail.
model = make_model()
model._probe_data = None
orig_model = model.get_orig_model()
self.assertIsNone(orig_model._probe_data)
def fake_up_blockdata_disk(disk, **kw):
model = disk._m