Change in vdsm[master]: spec: Add numactl dependency in spec file
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has posted comments on this change.
Change subject: spec: Add numactl dependency in spec file
......................................................................
Patch Set 1:
please verify.
--
To view, visit http://gerrit.ovirt.org/27233
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2257acef9b2aa67d1457cf4b59dc377218720223
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Xiaolei Shi <xiao-lei.shi(a)hp.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Douglas Schilling Landgraf <dougsland(a)redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 12 months
Change in vdsm[master]: spec: Add numactl dependency in spec file
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has posted comments on this change.
Change subject: spec: Add numactl dependency in spec file
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit http://gerrit.ovirt.org/27233
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I2257acef9b2aa67d1457cf4b59dc377218720223
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Xiaolei Shi <xiao-lei.shi(a)hp.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Douglas Schilling Landgraf <dougsland(a)redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 12 months
Change in vdsm[master]: storage: check if mount specification is a symlink
by Nir Soffer
Nir Soffer has posted comments on this change.
Change subject: storage: check if mount specification is a symlink
......................................................................
Patch Set 1:
(1 comment)
Thanks for your patch Enrico!
http://gerrit.ovirt.org/#/c/27321/1/vdsm/storage/mount.py
File vdsm/storage/mount.py:
Line 265: realSpec = self.fs_spec
Line 266: # if this is a symlink we need the real path
Line 267: # to check against /proc/mounts
Line 268: if os.path.lexists(realSpec):
Line 269: realSpec = os.path.realpath(self.fs_spec)
Any reason to use os.path.lexists? Why not always normalize the path?
realSpec = os.path.realpath(self.fs_spec)
Line 270: if (record.fs_spec == realSpec and
Line 271: record.fs_file == self.fs_file):
Line 272: return record
Line 273:
--
To view, visit http://gerrit.ovirt.org/27321
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I32aa019b52c28377c064966684986d20414df6db
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Enrico Tagliavini <enrico.tagliavini(a)gmail.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 12 months
Change in vdsm[master]: storage: check if mount specification is a symlink
by Jenkins CI RO
oVirt Jenkins CI Server has posted comments on this change.
Change subject: storage: check if mount specification is a symlink
......................................................................
Patch Set 1:
No Builds Executed
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/8504/ : To avoid overloading the infrastructure, a whitelist for running gerrit triggered jobs has been set in place, if you feel like you should be in it, please contact infra at ovirt dot org.
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit_el/7714/ : To avoid overloading the infrastructure, a whitelist for running gerrit triggered jobs has been set in place, if you feel like you should be in it, please contact infra at ovirt dot org.
http://jenkins.ovirt.org/job/vdsm_master_unit_tests_gerrit/8630/ : To avoid overloading the infrastructure, a whitelist for running gerrit triggered jobs has been set in place, if you feel like you should be in it, please contact infra at ovirt dot org.
--
To view, visit http://gerrit.ovirt.org/27321
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I32aa019b52c28377c064966684986d20414df6db
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Enrico Tagliavini <enrico.tagliavini(a)gmail.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 12 months
Change in vdsm[master]: recovery: try to restore VMs from recovery files
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: recovery: try to restore VMs from recovery files
......................................................................
recovery: try to restore VMs from recovery files
on recovery, VDSM tries to recover the all the VMs reported
as active by libvirt.
If a VM disappears while VDSM is down or restarting, the
VM silently disappears without VDSM noticing, and the recovery
file is discarded.
This patch adds a second recovery try for the VMs which have
a recovery file but not yet restored using the standard recovry
loop.
Those VMs are most down on the recovering host, but VDSM has
to notify the engine so it is can do proper cleanup and it can
ensure the correct state is reported to users.
This patch depends on
I00ef12883c8035209de0f273925eb8603d6b6da8
which make sure VMs are setup and reported correctly if
the underlying QEMU process disappeared.
Change-Id: Id495f6047ba658c2b04da19bd7bf76425b3b9659
Bug-Url: https://bugzilla.redhat.com/1045626
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/clientIF.py
1 file changed, 19 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/25276/1
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index f8fe499..de3b648 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -19,6 +19,7 @@
#
import os
+import os.path
import time
import threading
import pickle
@@ -415,6 +416,13 @@
'process with id: %s',
vmId, exc_info=True)
+ # we do this to safely handle VMs which disappeared
+ # from the host while VDSM was down/restarting
+ for vmId in self._getVDSMVmsFromRecovery():
+ if not self._recoverVm(vmId):
+ self.log.info('expected VM %s from recovery file but'
+ 'missing, reported as Down', vmId)
+
while (self._enabled and
'WaitForLaunch' in [v.lastStatus for v in
self.vmContainer.values()]):
@@ -492,6 +500,17 @@
vms.append(vm)
return [vm for vm in vms if self.isVDSMVm(vm)]
+ def _getVDSMVmsFromRecovery(self):
+ vms = []
+ for f in os.listdir(constants.P_VDSM_RUN):
+ vmId, fileType = os.path.splitext(f)
+ if fileType == ".recovery":
+ if vmId in self.vmContainer:
+ self.log.info('vm %s already recovered', vmId)
+ else:
+ vms.append(vmId)
+ return vms
+
def _recoverVm(self, vmid):
try:
recoveryFile = constants.P_VDSM_RUN + vmid + ".recovery"
--
To view, visit http://gerrit.ovirt.org/25276
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id495f6047ba658c2b04da19bd7bf76425b3b9659
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 12 months
Change in vdsm[master]: vm: handle missing domains on recovery
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: vm: handle missing domains on recovery
......................................................................
vm: handle missing domains on recovery
When VDSM tries to reconnect to libvirt, it is possible
that the domain lookup fails. This is especially true on
recovering.
This patch add an explicit check in the recovery path to
make sure that a VM is either created with a valid libvirt
domain handle, or it is reported as Down so the engine
can collect its state and explicitely destroy it.
This patch can stand on its own to increase the robustness
of VDSM, but is the first of a two-part series which
collectively fix the bz 1045626.
Change-Id: I00ef12883c8035209de0f273925eb8603d6b6da8
Bug-Url: https://bugzilla.redhat.com/1045626
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 17 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/25275/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index af8b3be..bc5e3ba 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1891,6 +1891,10 @@
pass
+class LibvirtConnectionError(Exception):
+ pass
+
+
class Vm(object):
"""
Used for abstracting communication between various parts of the
@@ -2298,6 +2302,15 @@
# behaviors on VM start/destroy, because the tuning can be
# done automatically according to its statistical data.
self.cif.ksmMonitor.adjust()
+ except libvirt.libvirtError as e:
+ # we cannot continue without a libvirt connection handle
+ # to avoid state desync or worse split-brain scenarios.
+ if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
+ raise LibvirtConnectionError()
+ if not self.recovering:
+ raise
+ else:
+ self.log.info("Skipping errors on recovery", exc_info=True)
except Exception:
if not self.recovering:
raise
@@ -2325,6 +2338,10 @@
self.recovering = False
self.saveState()
+ except LibvirtConnectionError:
+ self.recovering = False
+ # we cannot ever deal with this, not even on recovery.
+ self.setDownStatus(ERROR, "failed to connect to libvirt")
except Exception as e:
if self.recovering:
self.log.info("Skipping errors on recovery", exc_info=True)
--
To view, visit http://gerrit.ovirt.org/25275
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I00ef12883c8035209de0f273925eb8603d6b6da8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 12 months
Change in vdsm[master]: tests: initial tests for vm libvirt callbacks
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: tests: initial tests for vm libvirt callbacks
......................................................................
tests: initial tests for vm libvirt callbacks
This patch adds initial tests for the libvirt callbacks
of vdsm.virt.Vm.
The dispatching logic for the libvirt callbacks in clientIF
is not covered by this patch.
Change-Id: I059ef6cd42e8cfa03e2891dade00ff21e4c435bb
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/vmTests.py
1 file changed, 23 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/27128/1
diff --git a/tests/vmTests.py b/tests/vmTests.py
index c431fb8..15bde59 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -773,7 +773,7 @@
@contextmanager
-def FakeVM(params=None, devices=None):
+def FakeVM(params=None, devices=None, run=False):
with namedTemporaryDir() as tmpDir:
with MonkeyPatchScope([(constants, 'P_VDSM_RUN', tmpDir + '/'),
(libvirtconnection, 'get',
@@ -783,6 +783,7 @@
fake = vm.Vm(None, vmParams)
fake.guestAgent = FakeGuestAgent()
fake.conf['devices'] = [] if devices is None else devices
+ fake._guestCpuRunning = run
yield fake
@@ -919,3 +920,24 @@
res = fake.getStats()
self.assertIn('balloonInfo', res)
self.assertIn('balloon_cur', res['balloonInfo'])
+
+
+class TestLibVirtCallbacks(TestCaseBase):
+ FAKE_ERROR = 'EFAKERROR'
+
+ def test_onIOErrorPause(self):
+ with FakeVM(run=True) as fake:
+ self.assertTrue(fake._guestCpuRunning)
+ error = 'EFAKEERROR'
+ fake._onIOError('fakedev', self.FAKE_ERROR,
+ libvirt.VIR_DOMAIN_EVENT_IO_ERROR_PAUSE)
+ self.assertFalse(fake._guestCpuRunning)
+ self.assertEqual(fake.conf.get('pauseCode'), self.FAKE_ERROR)
+
+ def test_onIOErrorReport(self):
+ with FakeVM(run=True) as fake:
+ self.assertTrue(fake._guestCpuRunning)
+ fake._onIOError('fakedev', self.FAKE_ERROR,
+ libvirt.VIR_DOMAIN_EVENT_IO_ERROR_REPORT)
+ self.assertTrue(fake._guestCpuRunning)
+ self.assertNotEquals(fake.conf.get('pauseCode'), self.FAKE_ERROR)
--
To view, visit http://gerrit.ovirt.org/27128
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I059ef6cd42e8cfa03e2891dade00ff21e4c435bb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 12 months
Change in vdsm[master]: caps: Repair collect numa information
by Dan Kenigsberg
Dan Kenigsberg has posted comments on this change.
Change subject: caps: Repair collect numa information
......................................................................
Patch Set 2: Code-Review-1
(3 comments)
I have minor comments to this patch, but a bigger comment regarding an already accepted one.
http://gerrit.ovirt.org/#/c/27090/2/vdsm/caps.py
File vdsm/caps.py:
Line 191: memInfo = _getUMAHostMemoryStats()
Line 192: cellInfo['totalMemory'] = memInfo['total'] / 1024
Line 193: else:
Line 194: memInfo = _getMemoryStatsByNumaCell(int(cellIndex))
Line 195: cellInfo['totalMemory'] = int(memInfo['total']) / 1024
why is the int() suddenly needed here?
Line 196: cellsInfo[cellIndex] = cellInfo
Line 197: return cellsInfo
Line 198:
Line 199:
Line 202: Get the memory stats of a specified numa node.
Line 203:
Line 204: :param cell: the index of numa node.
Line 205: :type cell: int
Line 206: :return: dict like {'total': 50321208L, 'free': 47906488L}
in another patch: please document the units of totalMemory (KiB) in the schema.
Due to xmlrpc's 31bit limitation on int size, we are now limited to 2TiB numa node.
Vdsm reports all other memory sizes in MiB. Please conform with that (and sorry for not having noted this before). It also reports them as strings avoid the xmlrcp limitation.
Line 207: """
Line 208: return libvirtconnection.get().getMemoryStats(cell, 0)
Line 209:
Line 210:
Line 214:
Line 215: :return: dict like {'total': 50321208, 'free': 47906488}
Line 216: """
Line 217: memDict = {}
Line 218: memDict['total'] = utils.readMemInfo()['MemTotal']
it's not a big deal, but please avoid parsing /proc/meminfo twice when the price is only a temporary variable.
Line 219: memDict['free'] = utils.readMemInfo()['MemFree']
Line 220: return memDict
Line 221:
Line 222:
--
To view, visit http://gerrit.ovirt.org/27090
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ifb70231c81e75d29107f4ea89367aa33d8e85bad
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Xiaolei Shi <xiao-lei.shi(a)hp.com>
Gerrit-Reviewer: Adam Litke <alitke(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Gilad Chaplik <gchaplik(a)redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak(a)redhat.com>
Gerrit-Reviewer: Xiaolei Shi <xiao-lei.shi(a)hp.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 12 months
Change in vdsm[master]: libvirtconnection: Register atexit function only if started
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: libvirtconnection: Register atexit function only if started
......................................................................
libvirtconnection: Register atexit function only if started
Commit eb2ef55534 added atexit function, closing libvirt connections. On
RHEL 6.5, this change causes this error during vdsm startup:
vdsm: Running nwfilter
libvir: error : invalid connection pointer in virConnectClose
This patch moves the atexit registeration to the event loop thread, so we
register connections only if the event loop was started.
The __close_connections function was rename to _close_connections, since
double underscore cause unwanted name mangeling when using in a class
scope.
Change-Id: I638ad3621da0405d316e07f329ee03b5225c00b3
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/libvirtconnection.py
1 file changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/27313/1
diff --git a/lib/vdsm/libvirtconnection.py b/lib/vdsm/libvirtconnection.py
index 31b6a3a..88faf0e 100644
--- a/lib/vdsm/libvirtconnection.py
+++ b/lib/vdsm/libvirtconnection.py
@@ -54,6 +54,7 @@
@utils.traceback(on=log.name)
def __run(self):
try:
+ atexit.register(_close_connections)
libvirt.virEventRegisterDefaultImpl()
while self.run:
libvirt.virEventRunDefaultImpl()
@@ -173,8 +174,6 @@
return conn
-def __close_connections():
+def _close_connections():
for conn in __connections.values():
conn.close()
-
-atexit.register(__close_connections)
--
To view, visit http://gerrit.ovirt.org/27313
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I638ad3621da0405d316e07f329ee03b5225c00b3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 12 months
Change in vdsm[master]: validate verb: replace libvirt_configure.sh call with python...
by mtayer@redhat.com
mooli tayer has uploaded a new change for review.
Change subject: validate verb: replace libvirt_configure.sh call with python code.
......................................................................
validate verb: replace libvirt_configure.sh call with python code.
Change-Id: I3fe07463fd500cb5720f4e8869e27e2c24d7d4c9
Signed-off-by: Mooli Tayer <mtayer(a)redhat.com>
---
M lib/vdsm/tool/configfile.py
M lib/vdsm/tool/configurator.py
M tests/toolTests.py
3 files changed, 141 insertions(+), 39 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/27220/1
diff --git a/lib/vdsm/tool/configfile.py b/lib/vdsm/tool/configfile.py
index 33ab002..358fef8 100644
--- a/lib/vdsm/tool/configfile.py
+++ b/lib/vdsm/tool/configfile.py
@@ -17,10 +17,12 @@
# Refer to the README and COPYING files for full details of the license
#
+import ConfigParser
import os
import tempfile
import re
import selinux
+import StringIO
(
@@ -141,3 +143,29 @@
self.remove = True
else:
raise RuntimeError("Must be called from a managed context.")
+
+
+class ParserWrapper(object):
+ """
+ ConfigParser is for parsing of ini files. Use this
+ class for files with no sections.
+ """
+ def __init__(self, defaults=None):
+ self.wrapped = ConfigParser.RawConfigParser(defaults=defaults)
+
+ def get(self, option):
+ return self.wrapped.get('root', option)
+
+ def getboolean(self, option):
+ return self.wrapped.getboolean('root', option)
+
+ def getfloat(self, option):
+ return self.wrapped.getfloat('root', option)
+
+ def getint(self, option):
+ return self.wrapped.getint('root', option)
+
+ def read(self, path):
+ wrap = '[root]\n' + open(path, 'r').read()
+ wrap = StringIO.StringIO(wrap)
+ return self.wrapped.readfp(wrap)
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index e782762..349b3a7 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -30,7 +30,7 @@
from .. import utils
from . import service, expose, validate_ovirt_certs
-from .configfile import ConfigFile
+from .configfile import ConfigFile, ParserWrapper
from ..constants import P_VDSM_EXEC, QEMU_PROCESS_GROUP, \
SANLOCK_USER, VDSM_GROUP, SYSCONF_PATH, P_VDSM_CERT, \
SANLOCK_ENABLED, LIBVIRT_SELINUX
@@ -40,6 +40,17 @@
from ovirtnode import ovirtfunctions
except ImportError:
pass
+
+
+def envget(fname):
+ return {
+ 'VDSMM_CONF': os.path.join(SYSCONF_PATH, '/etc/vdsm/vdsm.conf'),
+ 'LCONF': os.path.join(SYSCONF_PATH, '/etc/libvirt/libvirtd.conf'),
+ 'QCONF': os.path.join(SYSCONF_PATH, 'libvirt/qemu.conf'),
+ 'LDCONF': os.path.join(SYSCONF_PATH, '/sysconfig/libvirtd'),
+ 'QLCONF': os.path.join(SYSCONF_PATH, 'libvirt/qemu-sanlock.conf'),
+ 'LRCONF': os.path.join(SYSCONF_PATH, '/etc/logrotate.d/libvirtd')
+ }[fname]
CONF_PREFIX = '## beginning of configuration section by vdsm'
CONF_SUFFIX = '## end of configuration section by vdsm'
@@ -51,11 +62,7 @@
KEY_FILE = os.path.join(PKI, 'keys/vdsmkey.pem')
LS_CERT_DIR = os.path.join(PKI, 'libvirt-spice')
-VDSMM_CONF = os.path.join(SYSCONF_PATH, '/etc/vdsm/vdsm.conf')
-
# Libvirt daemon configuration
-LCONF = os.path.join(SYSCONF_PATH, '/etc/libvirt/libvirtd.conf')
-
LCONF_GENERAL = {
'listen_addr': '"0.0.0.0"',
'unix_sock_group': '"qemu"',
@@ -81,8 +88,6 @@
}
# qemu configuration
-QCONF = os.path.join(SYSCONF_PATH, 'libvirt/qemu.conf')
-
QCONF_GENERAL = {
'dynamic_ownership': 0,
'save_image_format': '"lzop"',
@@ -112,24 +117,18 @@
}
# libvirt sysconfig file
-LDCONF = os.path.join(SYSCONF_PATH, '/sysconfig/libvirtd')
-
LDCONF_GENERAL = {
'LIBVIRTD_ARGS': '--listen',
'DAEMON_COREFILE_LIMIT': 'unlimited',
}
# sanlock configuration file
-QLCONF = os.path.join(SYSCONF_PATH, 'libvirt/qemu-sanlock.conf')
-
QLCONF_SANLOCK = {
'auto_disk_leases': 0,
'require_lease_for_disks': 0,
}
# libvirt log rotate configuration
-LRCONF = os.path.join(SYSCONF_PATH, '/etc/logrotate.d/libvirtd')
-
LLOGR_CONF = """
/var/log/libvirt/libvirtd.log {
rotate 100
@@ -227,7 +226,7 @@
ldconf_maps = [LDCONF_GENERAL]
qlconf_maps = []
# determine configuration
- config.read(VDSMM_CONF)
+ config.read(envget('VDSMM_CONF'))
if config.getboolean('vars', 'ssl'):
qconf_maps.append(QCONF_SSL)
if all(os.path.isfile(f) for f in
@@ -247,8 +246,10 @@
# write configuration
for file_name, configuration_maps in \
- [(LCONF, lconf_maps), (QCONF, qconf_maps),
- (LDCONF, ldconf_maps), (QLCONF, qlconf_maps)]:
+ [(envget('LCONF'), lconf_maps),
+ (envget('QCONF'), qconf_maps),
+ (envget('LDCONF'), ldconf_maps),
+ (envget('QLCONF'), qlconf_maps)]:
with ConfigFile(file_name,
'-'.join((CONF_PREFIX, CONF_VER)),
'-'.join((CONF_SUFFIX, CONF_VER))) as conff:
@@ -257,11 +258,13 @@
os.remove('/etc/libvirt/qemu/networks/autostart/default.xml')
- with ConfigFile(LRCONF, CONF_PREFIX, CONF_SUFFIX) as conf:
+ with ConfigFile(envget('LRCONF'), CONF_PREFIX, CONF_SUFFIX) as conf:
conf.prefixLines('# VDSM backup')
conf.prependSection(LLOGR_CONF)
- for fname in (LCONF, QCONF, LDCONF, QLCONF, LRCONF):
+ for fname in (envget('LCONF'), envget('QCONF'),
+ envget('LDCONF'), envget('QLCONF'),
+ envget('LRCONF')):
if utils.isOvirtNode() and ovirtfunctions:
ovirtfunctions.ovirt_store_config(fname)
sys.stdout.write("Reconfiguration of libvirt is done.")
@@ -301,15 +304,56 @@
raise RuntimeError(
"Failed to reload upstart configuration.")
+ def is_ssl_conflict(self):
+ config.read(envget('VDSMM_CONF'))
+ ssl = config.getboolean('vars', 'ssl')
+
+ lconf_p = ParserWrapper({
+ 'listen_tcp': '0',
+ 'auth_tcp': 'none'
+ })
+ lconf_p.read(envget('LCONF'))
+ listen_tcp = lconf_p.getboolean('listen_tcp')
+ auth_tcp = lconf_p.get('auth_tcp')
+ qconf_p = ParserWrapper({'spice_tls': '0'})
+ qconf_p.read(envget('QCONF'))
+ spice_tls = qconf_p.getboolean('spice_tls')
+ if ssl:
+ if listen_tcp != 1 and auth_tcp != 'none' and spice_tls != 0:
+ sys.stdout.write(
+ "SUCCESS: ssl configured to true. No conflicts\n")
+ return True
+ else:
+ sys.stdout.write(
+ "FAILED: "
+ "conflicting vdsm and libvirt-qemu tls configuration.\n"
+ "vdsm.conf with ssl=True "
+ "requires the following changes:\n"
+ "libvirtd.conf: listen_tcp=0, auth_tcp=\"sasl\", \n"
+ "qemu.conf: spice_tls=1.\n"
+ )
+ return False
+ else:
+ if listen_tcp == 1 and auth_tcp == 'none' and spice_tls == 0:
+ sys.stdout.write(
+ "SUCCESS: ssl configured to false. No conflicts.\n")
+ return True
+ else:
+ sys.stdout.write(
+ "FAILED: "
+ "conflicting vdsm and libvirt-qemu tls configuration.\n"
+ "vdsm.conf with ssl=False "
+ "requires the following changes:\n"
+ "libvirtd.conf: listen_tcp=1, auth_tcp=\"none\", \n"
+ "qemu.conf: spice_tls=0.\n"
+ )
+ return False
+
def validate(self):
"""
Validate conflict in configured files
"""
- try:
- self._exec_libvirt_configure("test_conflict_configurations")
- return True
- except RuntimeError:
- return False
+ return self.is_ssl_conflict()
def isconfigured(self):
"""
@@ -324,11 +368,16 @@
def removeConf(self):
for path in self._get_conf_files():
if os.path.exists(path):
- with ConfigFile(path, CONF_PREFIX, CONF_SUFFIX) as conff:
+ with ConfigFile(path,
+ CONF_PREFIX,
+ CONF_SUFFIX) as conff:
conff.removeConf()
def _get_conf_files(self):
- return LCONF, QCONF, QLCONF, LDCONF
+ return (envget('LCONF'),
+ envget('QCONF'),
+ envget('QLCONF'),
+ envget('LDCONF'))
class SanlockModuleConfigure(_ModuleConfigure):
diff --git a/tests/toolTests.py b/tests/toolTests.py
index 3552c9a..8359879 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -18,14 +18,14 @@
# Refer to the README and COPYING files for full details of the license
#
from vdsm.tool import configurator
-from vdsm.tool.configfile import ConfigFile
+from vdsm.tool.configfile import ConfigFile, ParserWrapper
from vdsm import utils
import monkeypatch
+
from unittest import TestCase
from functools import partial
import tempfile
import os
-
test_env = {}
srcPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
@@ -49,16 +49,18 @@
sample_config['libvirt_conf'] = """
## beginning of configuration section by vdsm-4.13.0
-listen_addr="0.0.0.0"
-unix_sock_group="qemu"
-unix_sock_rw_perms="0770"
-auth_unix_rw="sasl"
-host_uuid="72d18a98-8d96-4687-967a-72d989d3b65f"
-keepalive_interval=-1
-log_outputs="1:file:/var/log/libvirt/libvirtd.log"
-ca_file="/etc/pki/vdsm/certs/cacert.pem"
-cert_file="/etc/pki/vdsm/certs/vdsmcert.pem"
-key_file="/etc/pki/vdsm/keys/vdsmkey.pem"
+listen_tcp=0
+auth_tcp="sasl"
+#listen_addr="0.0.0.0"
+#unix_sock_group="qemu"
+#unix_sock_rw_perms="0770"
+#auth_unix_rw="sasl"
+#host_uuid="72d18a98-8d96-4687-967a-72d989d3b65f"
+#keepalive_interval=-1
+#log_outputs="1:file:/var/log/libvirt/libvirtd.log"
+#ca_file="/etc/pki/vdsm/certs/cacert.pem"
+#cert_file="/etc/pki/vdsm/certs/vdsmcert.pem"
+#key_file="/etc/pki/vdsm/keys/vdsmkey.pem"
## end of configuration section by vdsm-4.13.0
"""
@@ -127,7 +129,6 @@
utils.touchFile(test_env['LIBVIRT_LOGROTATE'])
self._setConfig('QLCONF', 'libvirtd')
self._setConfig('QCONF', 'qemu')
- self._setConfig('LDCONF', 'qemu-sanlock')
self.patch = monkeypatch.Patch([
(os, 'getuid', lambda: 0),
(configurator.LibvirtModuleConfigure,
@@ -135,8 +136,18 @@
get_libvirt_exec),
(configurator.LibvirtModuleConfigure,
'_get_conf_files',
- partial(get_conf_files, self._test_dir))
+ partial(get_conf_files, self._test_dir)),
+ (configurator,
+ 'envget',
+ lambda x: {
+ 'VDSMM_CONF': test_env['VDSM_CONF_FILE'],
+ 'LCONF': test_env['LCONF'],
+ 'QCONF': test_env['QCONF'],
+ 'LDCONF': test_env['LDCONF'],
+ 'QLCONF': test_env['QLCONF'],
+ }[x])
])
+ self._setConfig('LDCONF', 'qemu-sanlock')
self.patch.apply()
def tearDown(self):
@@ -235,3 +246,17 @@
with open(self.tname, 'r') as f:
self.assertEqual(f.read(), "key=val\n"
"kay=val\n")
+
+ def testConfRead(self):
+ self.writeConf("key=val\n"
+ "key1=val1\n")
+ conff = ParserWrapper(None)
+ conff.read(self.tname)
+ self.assertEqual(conff.get('key'), 'val')
+
+ def testConfDefaults(self):
+ self.writeConf("key=val\n"
+ "key1=val1\n")
+ conff = ParserWrapper({'key2': 'val2'})
+ conff.read(self.tname)
+ self.assertEqual(conff.get('key2'), 'val2')
--
To view, visit http://gerrit.ovirt.org/27220
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3fe07463fd500cb5720f4e8869e27e2c24d7d4c9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer(a)redhat.com>
9 years, 12 months