Adam Litke has uploaded a new change for review.

Change subject: verify_untrusted_volume: Only allow compat designated by config
......................................................................

verify_untrusted_volume: Only allow compat designated by config

Currently each host sets which qemuimg compat level is allowed.  Use
this setting also during volume verification until 0.10 and 1.1 can be
supported at the same time.

Change-Id: I86da01d885c3f265761fa323aea8b50524c0fcbe
Signed-off-by: Adam Litke <[email protected]>
---
M tests/storage_hsm_test.py
M vdsm/storage/hsm.py
2 files changed, 26 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/60113/1

diff --git a/tests/storage_hsm_test.py b/tests/storage_hsm_test.py
index c3504a0..42e8349 100644
--- a/tests/storage_hsm_test.py
+++ b/tests/storage_hsm_test.py
@@ -22,6 +22,7 @@
 from contextlib import contextmanager
 
 from monkeypatch import MonkeyPatchScope
+from testlib import make_config
 from testlib import VdsmTestCase
 from testlib import permutations, expandPermutations
 from storagetestlib import fake_file_env
@@ -85,6 +86,23 @@
                                   h.verify_untrusted_volume, 'sp',
                                   vol.sdUUID, vol.imgUUID, vol.volUUID)
 
+    @permutations((
+        ('0.10', '1.1'),
+        ('1.1', '0.10'),
+    ))
+    def test_disabled_compat_raises(self, qemu_compat, hsm_compat):
+        with self.fake_volume(sc.COW_FORMAT) as vol:
+            create_conf = make_config([('irs', 'qcow2_compat', qemu_compat)])
+            check_conf = make_config([('irs', 'qcow2_compat', hsm_compat)])
+            with MonkeyPatchScope([(qemuimg, 'config', create_conf),
+                                   (hsm, 'config', check_conf)]):
+                qemuimg.create(vol.volumePath, size=self.SIZE,
+                               format=qemuimg.FORMAT.QCOW2)
+                h = FakeHSM()
+                self.assertRaises(se.ImageVerificationError,
+                                  h.verify_untrusted_volume, 'sp',
+                                  vol.sdUUID, vol.imgUUID, vol.volUUID)
+
     def test_compat_not_checked_for_raw(self):
         with self.fake_volume(sc.RAW_FORMAT) as vol:
             qemu_fmt = qemuimg.FORMAT.RAW
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index e245bf2..101e7f5 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1515,6 +1515,14 @@
                 raise se.ImageVerificationError(
                     "qcow2 compat %r is not supported" % compat)
 
+            # Although we can handle both 0.1 and 1.1 compat qcow2 files, we
+            # currently limit support to one or the other via the vdsm config.
+            # Once both are supported concurrently this check can be removed.
+            required_compat = config.get('irs', 'qcow2_compat')
+            if compat != required_compat:
+                raise se.ImageVerificationError(
+                    "qcow2 compat %r is not supported by this host" % compat)
+
     def validateImageMove(self, srcDom, dstDom, imgUUID):
         """
         Determines if the image move is legal.


-- 
To view, visit https://gerrit.ovirt.org/60113
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86da01d885c3f265761fa323aea8b50524c0fcbe
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to