Change in vdsm[master]: virt: rng: Rng device should not depend on caps.py
fromani at redhat.com
fromani at redhat.com
Wed Feb 24 12:02:55 UTC 2016
Francesco Romani has uploaded a new change for review.
Change subject: virt: rng: Rng device should not depend on caps.py
......................................................................
virt: rng: Rng device should not depend on caps.py
Pack RNG_SOURCES inside Rng devices, where actually belongs.
As nice side effect, we turn the previous dependency link
upside down: caps should query Rng devices for availability.
Change-Id: If74f6c262f6a0bd4ed6a968e17e883e1e264ed54
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/caps.py
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/core.py
3 files changed, 26 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/53558/1
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 3c27943..28e5e3c 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -44,6 +44,7 @@
from vdsm import commands
from vdsm import utils
import storage.hba
+from virt import vmdevices
# For debian systems we can use python-apt if available
try:
@@ -84,10 +85,6 @@
DISABLE = 0
ENABLE = 1
UNKNOWN = 2
-
-
-RNG_SOURCES = {'random': '/dev/random',
- 'hwrng': '/dev/hwrng'}
class CpuTopology(object):
@@ -418,11 +415,6 @@
return ''
-def _getRngSources():
- return [source for (source, path) in RNG_SOURCES.items()
- if os.path.exists(path)]
-
-
def _getKdumpStatus():
try:
# check if kdump service is running
@@ -569,7 +561,7 @@
logging.debug('VirtioRNG DISABLED: libvirt version %s required >= %s',
libvirtVer, requiredVer)
else:
- caps['rngSources'] = _getRngSources()
+ caps['rngSources'] = vmdevices.core.Rng.available_sources()
caps['numaNodes'] = getNumaTopology()
caps['numaNodeDistance'] = getNumaNodeDistance()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index df58d1b..af5bcfe 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4149,16 +4149,15 @@
nodeValue
for dev in self._devices[hwclass.RNG]:
- if caps.RNG_SOURCES[dev.specParams['source']] == source and \
- not hasattr(dev, 'alias'):
+ if dev.uses(source) and not hasattr(dev, 'alias'):
dev.address = address
dev.alias = alias
break
for dev in self.conf['devices']:
if dev['type'] == hwclass.RNG and \
- caps.RNG_SOURCES[dev['specParams']['source']] == \
- source and 'alias' not in dev:
+ vmdevices.core.Rng.configured_for(dev, source) \
+ and 'alias' not in dev:
dev['address'] = address
dev['alias'] = alias
break
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index d2b8d55..005adb5 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -24,8 +24,6 @@
from vdsm import supervdsm
from vdsm import utils
-import caps
-
from ..utils import cleanup_guest_socket
from .. import vmxml
@@ -235,6 +233,26 @@
class Rng(Base):
+
+ _SOURCES = {
+ 'random': '/dev/random',
+ 'hwrng': '/dev/hwrng'
+ }
+
+ @staticmethod
+ def available_sources():
+ return [
+ source for (source, path) in Rng._SOURCES
+ if os.path.exists(path)
+ ]
+
+ @staticmethod
+ def configured_for(conf, source):
+ return Rng._SOURCES[conf['specParams']['source']] == source
+
+ def uses(self, source):
+ return self._SOURCES[self.specParams['source']] == source
+
def getXML(self):
"""
<rng model='virtio'>
@@ -254,7 +272,7 @@
# <backend... /> element
rng.appendChildWithArgs('backend',
- caps.RNG_SOURCES[self.specParams['source']],
+ self._SOURCES[self.specParams['source']],
model='random')
return rng
--
To view, visit https://gerrit.ovirt.org/53558
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If74f6c262f6a0bd4ed6a968e17e883e1e264ed54
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
More information about the vdsm-patches
mailing list