Change in vdsm[master]: domain_descriptor: Use stable devices hash
nsoffer at redhat.com
nsoffer at redhat.com
Wed Oct 29 22:11:55 UTC 2014
Nir Soffer has uploaded a new change for review.
Change subject: domain_descriptor: Use stable devices hash
......................................................................
domain_descriptor: Use stable devices hash
Commit af09a3ff50 changed the way we compute the devices hash. Before
this commit, we used:
hash(devxml.toxml())
And now we use:
hash(devxml)
Hashing minidom xml element returns a different hash for objects with
same xml content. It is possible that another libary will compute a
correct hash from parsed xml, but we should not depend on this.
Change-Id: I6190722653267ab45baec2302819c8995c468b1f
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/domainDescriptorTests.py
M vdsm/virt/domain_descriptor.py
2 files changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/34621/1
diff --git a/tests/domainDescriptorTests.py b/tests/domainDescriptorTests.py
index b426e1e..f04a02b 100644
--- a/tests/domainDescriptorTests.py
+++ b/tests/domainDescriptorTests.py
@@ -21,7 +21,6 @@
from virt.domain_descriptor import DomainDescriptor
from testlib import VdsmTestCase
-from testValidation import brokentest
NO_DEVICES = """
<domain>
@@ -74,7 +73,6 @@
desc2 = DomainDescriptor(REORDERED_DEVICES)
self.assertNotEqual(desc1.devicesHash, desc2.devicesHash)
- @brokentest("hashing is not stable")
def test_stable_hash(self):
desc1 = DomainDescriptor(SOME_DEVICES)
desc2 = DomainDescriptor(SOME_DEVICES)
diff --git a/vdsm/virt/domain_descriptor.py b/vdsm/virt/domain_descriptor.py
index 3100a25..baca905 100644
--- a/vdsm/virt/domain_descriptor.py
+++ b/vdsm/virt/domain_descriptor.py
@@ -27,7 +27,8 @@
self._dom = xml.dom.minidom.parseString(xmlStr)
self._devices = self._firstElementByTagName('devices')
# VDSM by default reports '0' as hash when it has no device list yet
- self._devicesHash = hash(self._devices) if self._devices else 0
+ self._devicesHash = (hash(self._devices.toxml()) if self._devices
+ else 0)
@classmethod
def fromId(cls, uuid):
--
To view, visit http://gerrit.ovirt.org/34621
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6190722653267ab45baec2302819c8995c468b1f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list