Change in vdsm[master]: remoteFileHandler: Remove harmful libvirt dependency
nsoffer at redhat.com
nsoffer at redhat.com
Thu Dec 12 07:23:12 UTC 2013
Nir Soffer has uploaded a new change for review.
Change subject: remoteFileHandler: Remove harmful libvirt dependency
......................................................................
remoteFileHandler: Remove harmful libvirt dependency
Commit ae7fbc6d4f2 added caps.isOvirtNode function, which was imported
into storage.misc, used by storage.remoteFileHandler. Since libvirt is
imported into caps, this caused libvirt to be imported into every out of
process remoteFileHandler.
Turns out that importing libvirt create a hidden libvirt event loop
thread, which seems to be quite busy, consuming about 50% cpu time,
and overloading the host.
This patch moves isOvirtNode and related functions to new host module,
and import this module instead of caps.
Change-Id: I41205675f88fdf45d0edffe1d1007ab45d174cf5
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm.spec.in
M vdsm/API.py
M vdsm/Makefile.am
M vdsm/caps.py
M vdsm/clientIF.py
A vdsm/host.py
M vdsm/storage/misc.py
7 files changed, 70 insertions(+), 37 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/22316/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 0bd4202..9f831a2 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -853,6 +853,7 @@
%{_datadir}/%{vdsm_name}/API.py*
%{_datadir}/%{vdsm_name}/hooking.py*
%{_datadir}/%{vdsm_name}/hooks.py*
+%{_datadir}/%{vdsm_name}/host.py*
%{_datadir}/%{vdsm_name}/lsblk.py*
%{_datadir}/%{vdsm_name}/md_utils.py*
%{_datadir}/%{vdsm_name}/mk_sysprep_floppy
diff --git a/vdsm/API.py b/vdsm/API.py
index 44d5817..3c5238e 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -38,6 +38,7 @@
from netconf import RollbackIncomplete
from vdsm import netinfo
from vdsm import constants
+import host
import storage.misc
import storage.clusterlock
import storage.volume
@@ -226,7 +227,7 @@
vmParams['vmId'])
vmParams['volatileFloppy'] = True
- if caps.osversion()['name'] == caps.OSName.UNKNOWN:
+ if caps.osversion()['name'] == host.OSName.UNKNOWN:
return {'status': {'code': errCode['createErr']
['status']['code'],
'message': 'Unknown host operating system'}}
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 1044f66..b22e17f 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -35,6 +35,7 @@
guestIF.py \
hooking.py \
hooks.py \
+ host.py \
kaxmlrpclib.py \
ksm.py \
logUtils.py \
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 3839134..9a81dc5 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -27,7 +27,6 @@
import logging
import time
import linecache
-import glob
import libvirt
import rpm
@@ -37,6 +36,7 @@
import dsaversion
from vdsm import netinfo
import hooks
+from host import getOSName, OSName
from vdsm import utils
import storage.hba
@@ -55,14 +55,6 @@
except ImportError:
_glusterEnabled = False
-
-class OSName:
- UNKNOWN = 'unknown'
- OVIRT = 'oVirt Node'
- RHEL = 'RHEL'
- FEDORA = 'Fedora'
- RHEVH = 'RHEV Hypervisor'
- DEBIAN = 'Debian'
RNG_SOURCES = {'random': '/dev/random',
'hwrng': '/dev/hwrng'}
@@ -269,26 +261,10 @@
@utils.memoized
-def getos():
- if os.path.exists('/etc/rhev-hypervisor-release'):
- return OSName.RHEVH
- elif glob.glob('/etc/ovirt-node-*-release'):
- return OSName.OVIRT
- elif os.path.exists('/etc/fedora-release'):
- return OSName.FEDORA
- elif os.path.exists('/etc/redhat-release'):
- return OSName.RHEL
- elif os.path.exists('/etc/debian_version'):
- return OSName.DEBIAN
- else:
- return OSName.UNKNOWN
-
-
- at utils.memoized
def osversion():
version = release = ''
- osname = getos()
+ osname = getOSName()
try:
if osname == OSName.RHEVH or osname == OSName.OVIRT:
d = _parseKeyVal(file('/etc/default/version'))
@@ -383,7 +359,9 @@
pkgs = {'kernel': kernelDict()}
- if getos() in (OSName.RHEVH, OSName.OVIRT, OSName.FEDORA, OSName.RHEL):
+ osname = getOSName()
+
+ if osname in (OSName.RHEVH, OSName.OVIRT, OSName.FEDORA, OSName.RHEL):
KEY_PACKAGES = {'qemu-kvm': ('qemu-kvm', 'qemu-kvm-rhev'),
'qemu-img': ('qemu-img', 'qemu-img-rhev'),
'vdsm': ('vdsm',),
@@ -414,7 +392,7 @@
except:
logging.error('', exc_info=True)
- elif getos() == OSName.DEBIAN and python_apt:
+ elif osname == OSName.DEBIAN and python_apt:
KEY_PACKAGES = {'qemu-kvm': 'qemu-kvm', 'qemu-img': 'qemu-utils',
'vdsm': 'vdsmd', 'spice-server': 'libspice-server1',
'libvirt': 'libvirt0', 'mom': 'mom'}
@@ -434,7 +412,3 @@
logging.error('', exc_info=True)
return pkgs
-
-
-def isOvirtNode():
- return getos() in (OSName.RHEVH, OSName.OVIRT)
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index c083991..91691aa 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -32,6 +32,7 @@
import ksm
from momIF import MomThread, isMomAvailable
from vdsm.define import doneCode, errCode
+import host
import libvirt
from vdsm import libvirtconnection
import vm
@@ -459,9 +460,9 @@
for entry in entries:
if entry.getAttribute("name") == "product":
prod = entry.firstChild.data
- if prod in (caps.OSName.RHEL, caps.OSName.OVIRT,
- caps.OSName.RHEVH, caps.OSName.FEDORA,
- caps.OSName.DEBIAN):
+ if prod in (host.OSName.RHEL, host.OSName.OVIRT,
+ host.OSName.RHEVH, host.OSName.FEDORA,
+ host.OSName.DEBIAN):
return True
return False
diff --git a/vdsm/host.py b/vdsm/host.py
new file mode 100644
index 0000000..62e3046
--- /dev/null
+++ b/vdsm/host.py
@@ -0,0 +1,55 @@
+#
+# Copyright 2013 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+"""Host info"""
+
+import os
+import glob
+
+from vdsm import utils
+
+
+class OSName:
+ UNKNOWN = 'unknown'
+ OVIRT = 'oVirt Node'
+ RHEL = 'RHEL'
+ FEDORA = 'Fedora'
+ RHEVH = 'RHEV Hypervisor'
+ DEBIAN = 'Debian'
+
+
+ at utils.memoized
+def getOSName():
+ if os.path.exists('/etc/rhev-hypervisor-release'):
+ return OSName.RHEVH
+ elif glob.glob('/etc/ovirt-node-*-release'):
+ return OSName.OVIRT
+ elif os.path.exists('/etc/fedora-release'):
+ return OSName.FEDORA
+ elif os.path.exists('/etc/redhat-release'):
+ return OSName.RHEL
+ elif os.path.exists('/etc/debian_version'):
+ return OSName.DEBIAN
+ else:
+ return OSName.UNKNOWN
+
+
+def isOvirtNode():
+ return getOSName() in (OSName.RHEVH, OSName.OVIRT)
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index 48020b6..0e6405c 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -55,7 +55,7 @@
import storage_exception as se
import fileUtils
import logUtils
-from caps import isOvirtNode
+from host import isOvirtNode
IOUSER = "vdsm"
DIRECTFLAG = "direct"
--
To view, visit http://gerrit.ovirt.org/22316
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41205675f88fdf45d0edffe1d1007ab45d174cf5
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