Change in vdsm[master]: svdsm: Remove superfluous unlinks
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: svdsm: Remove superfluous unlinks
......................................................................
svdsm: Remove superfluous unlinks
This causes races and is generally unnecessary
Bug-Id: https://bugzilla.redhat.com/910005
Change-Id: I6c3e1968666a34fdfc4b9df8d8c320bcc82c47ca
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/supervdsm.py
M vdsm/supervdsmServer.py
2 files changed, 48 insertions(+), 49 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/11989/1
diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 10abae0..127dd78 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -112,10 +112,10 @@
return self._manager.open(*args, **kwargs)
def _cleanOldFiles(self):
- self._log.debug("Cleanning svdsm old files: %s, %s, %s",
+ self._log.debug("Cleanning svdsm old files: %s, %s",
self.pidfile, self.timestamp, self.address)
- for f in (self.pidfile, self.timestamp, self.address):
- utils.rmFile(f)
+ for f in (self.pidfile, self.timestamps):
+ utils.rmFile(str(f))
def _start(self):
self._authkey = str(uuid.uuid4())
@@ -194,7 +194,7 @@
def launch(self):
self._firstLaunch = False
self._start()
- utils.retry(self._connect, Exception, timeout=60)
+ utils.retry(self._connect, Exception, timeout=1)
def __getattr__(self, name):
return ProxyCaller(self, name)
diff --git a/vdsm/supervdsmServer.py b/vdsm/supervdsmServer.py
index 83a5803..21cf579 100755
--- a/vdsm/supervdsmServer.py
+++ b/vdsm/supervdsmServer.py
@@ -366,57 +366,56 @@
log = logging.getLogger("SuperVdsm.Server")
+ log.debug("Making sure I'm root")
+ if os.geteuid() != 0:
+ sys.exit(errno.EPERM)
+
+ log.debug("Parsing cmd args")
+ authkey, parentPid, pidfile, timestamp, address, uid = sys.argv[1:]
+
+ log.debug("Creating PID and TIMESTAMP files: %s, %s",
+ pidfile, timestamp)
+ spid = os.getpid()
+ with open(pidfile, "w") as f:
+ f.write(str(spid) + "\n")
+ with open(timestamp, "w") as f:
+ f.write(str(misc.getProcCtime(spid) + "\n"))
+
+ log.debug("Cleaning old socket %s", address)
+ zombieReaper.registerSignalHandler()
+
+ log.debug("Setting up keep alive thread")
+
+ monThread = threading.Thread(target=__pokeParent,
+ args=[int(parentPid), address, log])
+ monThread.setDaemon(True)
+ monThread.start()
+
try:
- log.debug("Making sure I'm root")
- if os.geteuid() != 0:
- sys.exit(errno.EPERM)
-
- log.debug("Parsing cmd args")
- authkey, parentPid, pidfile, timestamp, address, uid = sys.argv[1:]
-
- log.debug("Creating PID and TIMESTAMP files: %s, %s",
- pidfile, timestamp)
- spid = os.getpid()
- with open(pidfile, "w") as f:
- f.write(str(spid) + "\n")
- with open(timestamp, "w") as f:
- f.write(str(misc.getProcCtime(spid) + "\n"))
-
- log.debug("Cleaning old socket %s", address)
- if os.path.exists(address):
- os.unlink(address)
-
- zombieReaper.registerSignalHandler()
-
- log.debug("Setting up keep alive thread")
-
- monThread = threading.Thread(target=__pokeParent,
- args=[int(parentPid), address, log])
- monThread.setDaemon(True)
- monThread.start()
-
+ log.debug("Creating remote object manager")
try:
- log.debug("Creating remote object manager")
- manager = _SuperVdsmManager(address=address, authkey=authkey)
- manager.register('instance', callable=_SuperVdsm)
+ os.unlink(address)
+ except (OSError, IOError) as e:
+ if e.errno != errno.ENOENT:
+ raise
- server = manager.get_server()
- servThread = threading.Thread(target=server.serve_forever)
- servThread.setDaemon(True)
- servThread.start()
+ manager = _SuperVdsmManager(address=address, authkey=authkey)
+ manager.register('instance', callable=_SuperVdsm)
- for f in (address, timestamp, pidfile):
- chown(f, int(uid), METADATA_GROUP)
+ server = manager.get_server()
+ servThread = threading.Thread(target=server.serve_forever)
+ servThread.setDaemon(True)
+ servThread.start()
- log.debug("Started serving super vdsm object")
+ for f in (address, timestamp, pidfile):
+ chown(f, int(uid), METADATA_GROUP)
- # Python bug of thread.join() will block signal
- # http://bugs.python.org/issue1167930
- while servThread.isAlive():
- servThread.join(5)
- finally:
- if os.path.exists(address):
- utils.rmFile(address)
+ log.debug("Started serving super vdsm object")
+
+ # Python bug of thread.join() will block signal
+ # http://bugs.python.org/issue1167930
+ while servThread.isAlive():
+ servThread.join(5)
except Exception:
log.error("Could not start Super Vdsm", exc_info=True)
--
To view, visit http://gerrit.ovirt.org/11989
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c3e1968666a34fdfc4b9df8d8c320bcc82c47ca
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 2 months
Change in vdsm[master]: Add create operation to qemu-img
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Add create operation to qemu-img
......................................................................
Add create operation to qemu-img
Change-Id: I078afcb0899792805584fc56832747d36908f18b
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/qemuImg.py
1 file changed, 29 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/6245/1
--
To view, visit http://gerrit.ovirt.org/6245
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I078afcb0899792805584fc56832747d36908f18b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 2 months
Change in vdsm[master]: [WIP] Continue moving VM code to it's own module
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Continue moving VM code to it's own module
......................................................................
[WIP] Continue moving VM code to it's own module
Change-Id: I374dae67449f65c7c55ed028bd301be8b6a01eb5
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
1 file changed, 16 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/7514/1
diff --git a/vdsm/API.py b/vdsm/API.py
index aab69cd..e6a1048 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -136,15 +136,18 @@
for methName in GUEST_AGENT_METHODS:
self.setattr(attrName, partial(guestTrampoline, methName))
+ def _getVmObject(self):
+ return self._cif.vmContainer.get(self._UUID)
+
def _runThinMethod(self, methodName, *args, **kwargs):
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v:
return errCode['noVM']
return getattr(v, methodName)(*args, **kwargs)
def _runGuestAgentMethod(self, methodName, *args, **kwargs):
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if v is None:
return errCode['noVM']
@@ -163,7 +166,7 @@
"""
vmParams['vmId'] = self._UUID
try:
- if self._cif.vmContainer.get(self._UUID) is not None:
+ if self._getVmObject() is not None:
self.log.warning('vm %s already exists' % vmParams['vmId'])
return errCode['exist']
@@ -286,7 +289,7 @@
"""
Obtain statistics of the specified VM
"""
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v:
return errCode['noVM']
stats = v.getStats().copy()
@@ -364,7 +367,7 @@
"""
params['vmId'] = self._UUID
self.log.debug(params)
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if v is None:
return errCode['noVM']
@@ -395,7 +398,7 @@
self.log.debug('Migration create - Failed')
return response
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v.waitForMigrationDestinationPrepare():
return errCode['createErr']
@@ -921,12 +924,14 @@
return d
else:
return {'vmId': d['vmId'], 'status': d['status']}
- # To improve complexity, convert 'vms' to set(vms)
- vmSet = set(vmList)
+
+ if vmList:
+ vms = (self._cif.vmContainer.get(vm) for vm in vmList)
+ else:
+ vms = self._cif.vmContainer.getVMs()
+
return {'status': doneCode,
- 'vmList': [reportedStatus(v, fullStatus)
- for v in self._cif.vmContainer.getVMs()
- if not vmSet or v.id in vmSet]}
+ 'vmList': [reportedStatus(vm, fullStatus) for vm in vms]}
# Networking-related functions
def setupNetworks(self, networks={}, bondings={}, options={}):
--
To view, visit http://gerrit.ovirt.org/7514
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I374dae67449f65c7c55ed028bd301be8b6a01eb5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 2 months
Change in vdsm[master]: Fix fix fix getDomUuidFromVolumePath()
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: Fix fix fix getDomUuidFromVolumePath()
......................................................................
Fix fix fix getDomUuidFromVolumePath()
Change-Id: I96b71b7839666d402ec5166eefeac618685c0ab0
Bug-Url: http://bugzilla.redhat.com/1017735
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/storage/fileVolume.py
1 file changed, 3 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/20790/1
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index cf26197..b28a8a5 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -18,13 +18,11 @@
# Refer to the README and COPYING files for full details of the license
#
-from os.path import normpath
import errno
import os
import sanlock
import storage_exception as se
-from vdsm.config import config
from vdsm.utils import ActionStopped, grepCmd
from sdc import sdCache
import outOfProcess as oop
@@ -44,16 +42,9 @@
def getDomUuidFromVolumePath(volPath):
- # Volume path has pattern:
- # /rhev/data-center/spUUID/sdUUID/images/imgUUID/volUUID
-
- # sdUUID position after data-center
- sdUUIDOffset = 1
-
- volList = volPath.split('/')
- sdUUIDPos = len(normpath(config.get('irs', 'repository')).split('/')) + \
- sdUUIDOffset
- return volList[sdUUIDPos]
+ # fileVolume path has pattern:
+ # */sdUUID/images/imgUUID/volUUID
+ return volPath.split('/')[-4]
class FileVolume(volume.Volume):
--
To view, visit http://gerrit.ovirt.org/20790
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96b71b7839666d402ec5166eefeac618685c0ab0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: vdsm: Catch the destkopLock AttributeError on Migration
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: vdsm: Catch the destkopLock AttributeError on Migration
......................................................................
vdsm: Catch the destkopLock AttributeError on Migration
During the migration, on the target the events for disconnected spice
channels are sent before VDSM is able to initialize the guestAgent
instance. In this case, we should not let the exception go through.
Change-Id: I5b6f6b2f2a3f049871902ee7777ae95ea9a52802
Bug-Url: https://bugzilla.redhat.com/955593
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/14395/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index ddb09c8..b0adc14 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -824,7 +824,10 @@
def _timedDesktopLock(self):
if not self.conf.get('clientIp', ''):
- self.guestAgent.desktopLock()
+ try:
+ self.guestAgent.desktopLock()
+ except AttributeError:
+ self.log.debug("Guest Agent not yet intialized")
def onDisconnect(self, detail=None):
self.conf['clientIp'] = ''
--
To view, visit http://gerrit.ovirt.org/14395
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b6f6b2f2a3f049871902ee7777ae95ea9a52802
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: Move virt things into vdsm/virt
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: Move virt things into vdsm/virt
......................................................................
Move virt things into vdsm/virt
Change-Id: Ibdfaefbe8837d2059674fdc4dc83fca431d76f8d
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M configure.ac
M tests/guestIFTests.py
M tests/vmTests.py
M vdsm.spec.in
M vdsm/API.py
M vdsm/Makefile.am
M vdsm/clientIF.py
A vdsm/virt/Makefile.am
A vdsm/virt/__init__.py
R vdsm/virt/guestIF.py
R vdsm/virt/sampling.py
R vdsm/virt/vm.py
R vdsm/virt/vmChannels.py
R vdsm/virt/vmstatus.py
14 files changed, 45 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/21792/1
diff --git a/configure.ac b/configure.ac
index 4ba4a9e..6d72726 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,6 +273,7 @@
vdsm/storage/imageRepository/Makefile
vdsm/storage/protect/Makefile
vdsm/storage/vdsm-lvm.rules
+ vdsm/virt/Makefile
vdsm_api/Makefile
vdsm_hooks/Makefile
vdsm_hooks/checkimages/Makefile
diff --git a/tests/guestIFTests.py b/tests/guestIFTests.py
index 94efe92..1a6e6d2 100644
--- a/tests/guestIFTests.py
+++ b/tests/guestIFTests.py
@@ -20,7 +20,7 @@
#
import logging
from collections import namedtuple
-import guestIF
+from virt import guestIF
import json
from testrunner import VdsmTestCase as TestCaseBase
diff --git a/tests/vmTests.py b/tests/vmTests.py
index 1f69f0a..b7ec102 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -22,7 +22,7 @@
import tempfile
import xml.etree.ElementTree as ET
-import vm
+from virt import vm
from vdsm import constants
from testrunner import VdsmTestCase as TestCaseBase
import caps
diff --git a/vdsm.spec.in b/vdsm.spec.in
index ca02046..1d2f87b 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -832,6 +832,7 @@
%dir %{_datadir}/%{vdsm_name}/netconf
%dir %{_datadir}/%{vdsm_name}/storage
%dir %{_datadir}/%{vdsm_name}/storage/imageRepository
+%dir %{_datadir}/%{vdsm_name}/virt
%{_datadir}/%{vdsm_name}/alignmentScan.py*
%{_datadir}/%{vdsm_name}/blkid.py*
%{_datadir}/%{vdsm_name}/caps.py*
@@ -850,7 +851,8 @@
%{_datadir}/%{vdsm_name}/sourceRouteThread.py*
%{_datadir}/%{vdsm_name}/supervdsm.py*
%{_datadir}/%{vdsm_name}/supervdsmServer
-%{_datadir}/%{vdsm_name}/vmChannels.py*
+%{_datadir}/%{vdsm_name}/virt/__init__.py*
+%{_datadir}/%{vdsm_name}/virt/vmChannels.py*
%{_datadir}/%{vdsm_name}/vmstatus.py*
%{_datadir}/%{vdsm_name}/tc.py*
%{_datadir}/%{vdsm_name}/vdsm
@@ -874,7 +876,7 @@
%{_sysconfdir}/sudoers.d/50_vdsm
%{_sysconfdir}/cron.hourly/vdsm-logrotate
%{_sysconfdir}/cron.d/vdsm-libvirt-logrotate
-%{_datadir}/%{vdsm_name}/guestIF.py*
+%{_datadir}/%{vdsm_name}/virt/guestIF.py*
%{_datadir}/%{vdsm_name}/logUtils.py*
%{_datadir}/%{vdsm_name}/dsaversion.py*
%{_libexecdir}/%{vdsm_name}/curl-img-wrap
@@ -992,7 +994,7 @@
%{_datadir}/%{vdsm_name}/neterrors.py*
%{_datadir}/%{vdsm_name}/netmodels.py*
%{_datadir}/%{vdsm_name}/respawn
-%{_datadir}/%{vdsm_name}/sampling.py*
+%{_datadir}/%{vdsm_name}/virt/sampling.py*
%{_datadir}/%{vdsm_name}/set-conf-item
%if 0%{?with_gluster}
%dir %{_datadir}/%{vdsm_name}/gluster
diff --git a/vdsm/API.py b/vdsm/API.py
index 9b722a2..a998e71 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -40,8 +40,8 @@
import storage.volume
import storage.sd
import storage.image
-import vm
-import vmstatus
+from virt import vm
+from virt import vmstatus
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 2dc0876..45ea118 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -18,7 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
-SUBDIRS = netconf sos storage gluster
+SUBDIRS = netconf sos storage gluster virt
include $(top_srcdir)/build-aux/Makefile.subs
@@ -32,7 +32,6 @@
configNetwork.py \
debugPluginClient.py \
dmidecodeUtil.py \
- guestIF.py \
hooking.py \
hooks.py \
kaxmlrpclib.py \
@@ -51,9 +50,6 @@
supervdsm.py \
tc.py \
vdsmDebugPlugin.py \
- vmChannels.py \
- vm.py \
- vmstatus.py \
$(NULL)
dist_vdsmexec_SCRIPTS = \
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index f65e556..f8266e3 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -35,16 +35,16 @@
from vdsm.define import doneCode, errCode
import libvirt
from vdsm import libvirtconnection
-import vm
+from virt import vm
from vdsm import constants
from vdsm import utils
from netconf import ifcfg
import caps
-from vmChannels import Listener
-from vm import Vm
+from virt.vmChannels import Listener
+from virt.vm import Vm
import blkid
import supervdsm
-import sampling
+from virt import sampling
import vmstatus
try:
import gluster.api as gapi
diff --git a/vdsm/virt/Makefile.am b/vdsm/virt/Makefile.am
new file mode 100644
index 0000000..4b4f21b
--- /dev/null
+++ b/vdsm/virt/Makefile.am
@@ -0,0 +1,30 @@
+#
+# 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
+#
+
+include $(top_srcdir)/build-aux/Makefile.subs
+
+vdsm_virtdir = $(vdsmdir)/virt
+dist_vdsm_virt_PYTHON = \
+ guestIF.py \
+ sampling.py \
+ vm.py \
+ vmChannels.py \
+ vmstatus.py \
+ $(NULL)
diff --git a/vdsm/virt/__init__.py b/vdsm/virt/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vdsm/virt/__init__.py
diff --git a/vdsm/guestIF.py b/vdsm/virt/guestIF.py
similarity index 100%
rename from vdsm/guestIF.py
rename to vdsm/virt/guestIF.py
diff --git a/vdsm/sampling.py b/vdsm/virt/sampling.py
similarity index 100%
rename from vdsm/sampling.py
rename to vdsm/virt/sampling.py
diff --git a/vdsm/vm.py b/vdsm/virt/vm.py
similarity index 100%
rename from vdsm/vm.py
rename to vdsm/virt/vm.py
diff --git a/vdsm/vmChannels.py b/vdsm/virt/vmChannels.py
similarity index 100%
rename from vdsm/vmChannels.py
rename to vdsm/virt/vmChannels.py
diff --git a/vdsm/vmstatus.py b/vdsm/virt/vmstatus.py
similarity index 100%
rename from vdsm/vmstatus.py
rename to vdsm/virt/vmstatus.py
--
To view, visit http://gerrit.ovirt.org/21792
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdfaefbe8837d2059674fdc4dc83fca431d76f8d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: Convert vm status strings to constants
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: Convert vm status strings to constants
......................................................................
Convert vm status strings to constants
This patch replaces all vmstatuses to constants.
Additionally added not documented 'Powering up' status to schema.
Change-Id: I95e6945c2ee9d443e22586f04dc0f9646cc5cbb3
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M tests/functional/storageTests.py
M tests/functional/virtTests.py
M vdsm/API.py
M vdsm/clientIF.py
M vdsm/guestIF.py
M vdsm/vm.py
A vdsm/vmstatus.py
M vdsm_api/vdsmapi-schema.json
8 files changed, 103 insertions(+), 56 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/21790/1
diff --git a/tests/functional/storageTests.py b/tests/functional/storageTests.py
index df3a043..983da36 100644
--- a/tests/functional/storageTests.py
+++ b/tests/functional/storageTests.py
@@ -48,6 +48,8 @@
from vdsm.utils import CommandPath
from vdsm import vdscli
+import vmstatus
+
_VARTMP = '/var/tmp'
if not config.getboolean('vars', 'xmlrpc_enable'):
@@ -62,7 +64,7 @@
@expandPermutations
class StorageTest(TestCaseBase):
- UPSTATES = frozenset(('Up', 'Powering up'))
+ UPSTATES = frozenset((vmstatus.UP, vmstatus.POWERING_UP))
def runTest(self):
pass
diff --git a/tests/functional/virtTests.py b/tests/functional/virtTests.py
index d49c439..c58273e 100644
--- a/tests/functional/virtTests.py
+++ b/tests/functional/virtTests.py
@@ -36,6 +36,8 @@
from utils import VdsProxy, SUCCESS
+import vmstatus
+
_mkinitrd = CommandPath("mkinitrd", "/usr/bin/mkinitrd")
_modprobe = CommandPath("modprobe",
"/usr/sbin/modprobe", # Fedora, Ubuntu
@@ -135,7 +137,7 @@
@expandPermutations
class VirtTest(TestCaseBase):
- UPSTATES = frozenset(('Up', 'Powering up'))
+ UPSTATES = frozenset((vmstatus.UP, vmstatus.POWERING_UP))
def setUp(self):
self.vdsm = VdsProxy()
@@ -147,12 +149,12 @@
def assertQemuSetupComplete(self, vmid):
result = self._getVmStatus(vmid)
- self.assertTrue(result['status'] != 'WaitForLaunch',
+ self.assertTrue(result['status'] != vmstatus.WAIT_FOR_LAUNCH,
'VM is not booting!')
def assertVmBooting(self, vmid):
result = self._getVmStatus(vmid)
- self.assertTrue(result['status'] != 'Down',
+ self.assertTrue(result['status'] != vmstatus.DOWN,
'VM is not booting!')
def assertVmUp(self, vmid):
@@ -164,7 +166,7 @@
if targetUptime > 0:
self.assertTrue(int(result['elapsedTime']) >= targetUptime)
else:
- self.assertEquals(result['status'], 'Up')
+ self.assertEquals(result['status'], vmstatus.UP)
def _waitForStartup(self, vmid, targetUptime=0):
self.retryAssert(partial(self.assertQemuSetupComplete, vmid),
diff --git a/vdsm/API.py b/vdsm/API.py
index f91910c..9b722a2 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -41,6 +41,7 @@
import storage.sd
import storage.image
import vm
+import vmstatus
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
@@ -473,7 +474,7 @@
return errCode['noVM']
vmParams = v.status()
- if vmParams['status'] in ('WaitForLaunch', 'Down'):
+ if vmParams['status'] in (vmstatus.WAIT_FOR_LAUNCHF, vmstatus.DOWN):
return errCode['noVM']
if params.get('mode') == 'file':
if 'dst' not in params:
@@ -1500,7 +1501,7 @@
try:
count += 1
status = v.lastStatus
- if status == 'Up':
+ if status == vmstatus.UP:
active += 1
elif 'Migration' in status:
migrating += 1
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 0b67e45..f65e556 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -45,6 +45,7 @@
import blkid
import supervdsm
import sampling
+import vmstatus
try:
import gluster.api as gapi
_glusterEnabled = True
@@ -435,8 +436,8 @@
vmId, exc_info=True)
while (self._enabled and
- 'WaitForLaunch' in [v.lastStatus for v in
- self.vmContainer.values()]):
+ vmstatus.WAIT_FOR_LAUNCH in [v.lastStatus for v in
+ self.vmContainer.values()]):
time.sleep(1)
self._cleanOldFiles()
self._recovery = False
diff --git a/vdsm/guestIF.py b/vdsm/guestIF.py
index 06ca71b..90b3e31 100644
--- a/vdsm/guestIF.py
+++ b/vdsm/guestIF.py
@@ -26,6 +26,8 @@
import supervdsm
import unicodedata
+import vmstatus
+
__REPLACEMENT_CHAR = u'\ufffd'
__RESTRICTED_CHARS = set(range(8 + 1)). \
@@ -169,9 +171,9 @@
def _handleMessage(self, message, args):
self.log.log(logging.TRACE, "Guest's message %s: %s", message, args)
if self.guestStatus is None:
- self.guestStatus = 'Up'
+ self.guestStatus = vmstatus.UP
if message == 'heartbeat':
- self.guestStatus = 'Up'
+ self.guestStatus = vmstatus.UP
self.guestInfo['memUsage'] = int(args['free-ram'])
# ovirt-guest-agent reports the following fields in 'memory-stat':
# 'mem_total', 'mem_free', 'mem_unused', 'swap_in', 'swap_out',
@@ -268,7 +270,7 @@
'guestFQDN': self.guestInfo['guestFQDN']}
def onReboot(self):
- self.guestStatus = 'RebootInProgress'
+ self.guestStatus = vmstatus.REBOOT_IN_PROGRESS
self.guestInfo['lastUser'] = '' + self.guestInfo['username']
self.guestInfo['username'] = 'Unknown'
self.guestInfo['lastLogout'] = time.time()
diff --git a/vdsm/vm.py b/vdsm/vm.py
index ccdf950..74717bd 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -57,6 +57,7 @@
import kaxmlrpclib
import sampling
import supervdsm
+import vmstatus
_VMCHANNEL_DEVICE_NAME = 'com.redhat.rhevm.vdsm'
# This device name is used as default both in the qemu-guest-agent
@@ -210,10 +211,10 @@
' unresponsive. Hiberanting without '
'desktopLock.')
break
- self._vm.pause('Saving State')
+ self._vm.pause(vmstatus.SAVING_STATE)
else:
self.log.debug("Migration started")
- self._vm.lastStatus = 'Migration Source'
+ self._vm.lastStatus = vmstatus.MIGRATION_SOURCE
def _recover(self, message):
if not self.status['status']['code']:
@@ -228,7 +229,7 @@
if self._mode == 'file' or self._method != 'online':
self._vm.cont()
# either way, migration has finished
- self._vm.lastStatus = 'Up'
+ self._vm.lastStatus = vmstats.UP
def _finishSuccessfully(self):
self.status['progress'] = 100
@@ -408,10 +409,11 @@
class DoubleDownError(RuntimeError):
pass
-VALID_STATES = ('Down', 'Migration Destination', 'Migration Source',
- 'Paused', 'Powering down', 'RebootInProgress',
- 'Restoring state', 'Saving State',
- 'Up', 'WaitForLaunch')
+VALID_STATES = (vmstatus.DOWN, vmstatus.MIGRATION_DESTINATION,
+ vmstatus.MIGRATION_SOURCE, vmstatus.PAUSED,
+ vmstatus.POWERING_DOWN, vmstatus.REBOOT_IN_PROGRESS,
+ vmstatus.RESTORING_STATE, vmstatus.SAVING_STATE,
+ vmstatus.UP, vmstatus.WAIT_FOR_LAUNCH)
class MERGESTATUS:
@@ -1762,11 +1764,11 @@
self._confLock = threading.Lock()
self._creationThread = threading.Thread(target=self._startUnderlyingVm)
if 'migrationDest' in self.conf:
- self._lastStatus = 'Migration Destination'
+ self._lastStatus = vmstatus.MIGRATION_DESTINATION
elif 'restoreState' in self.conf:
- self._lastStatus = 'Restoring state'
+ self._lastStatus = vmstatus.RESTORING_STATE
else:
- self._lastStatus = 'WaitForLaunch'
+ self._lastStatus = vmstatus.WAIT_FOR_LAUNCH
self._migrationSourceThread = self.MigrationSourceThreadClass(self)
self._kvmEnable = self.conf.get('kvmEnable', 'true')
self._guestSocketFile = constants.P_VDSM_RUN + self.conf['vmId'] + \
@@ -1776,7 +1778,7 @@
self._volPrepareLock = threading.Lock()
self._initTimePauseCode = None
self.guestAgent = None
- self._guestEvent = 'Powering up'
+ self._guestEvent = vmstatus.POWERING_UP
self._guestEventTime = 0
self._vmStats = None
self._guestCpuRunning = False
@@ -1804,16 +1806,17 @@
self.sdIds = []
def _get_lastStatus(self):
- PAUSED_STATES = ('Powering down', 'RebootInProgress', 'Up')
+ PAUSED_STATES = (vmstatus.POWERING_DOWN, vmstatus.REBOOT_IN_PROGRESS,
+ vmstatus.UP)
if not self._guestCpuRunning and self._lastStatus in PAUSED_STATES:
- return 'Paused'
+ return vmstatus.PAUSED
return self._lastStatus
def _set_lastStatus(self, value):
- if self._lastStatus == 'Down':
+ if self._lastStatus == vmstatus.DOWN:
self.log.warning('trying to set state to %s when already Down',
value)
- if value == 'Down':
+ if value == vmstatus.DOWN:
raise DoubleDownError
else:
return
@@ -2083,8 +2086,8 @@
self._vmCreationEvent.set()
try:
self._run()
- if self.lastStatus != 'Down' and 'recover' not in self.conf \
- and not self.cif.mom:
+ if self.lastStatus != vmstatus.DOWN and \
+ 'recover' not in self.conf and not self.cif.mom:
# If MOM is available, we needn't tell it to adjust KSM
# behaviors on VM start/destroy, because the tuning can be
# done automatically according to its statistical data.
@@ -2099,10 +2102,10 @@
self.log.debug("_ongoingCreations released")
if ('migrationDest' in self.conf or 'restoreState' in self.conf) \
- and self.lastStatus != 'Down':
+ and self.lastStatus != vmstatus.DOWN:
self._waitForIncomingMigrationFinish()
- self.lastStatus = 'Up'
+ self.lastStatus = vmstatus.UP
if self._initTimePauseCode:
self.conf['pauseCode'] = self._initTimePauseCode
if self._initTimePauseCode == 'ENOSPC':
@@ -2196,7 +2199,8 @@
with self._confLock:
toSave = deepcopy(self.status())
toSave['startTime'] = self._startTime
- if self.lastStatus != 'Down' and self._vmStats and self.guestAgent:
+ if self.lastStatus != vmstatus.DOWN and \
+ self._vmStats and self.guestAgent:
toSave['username'] = self.guestAgent.guestInfo['username']
toSave['guestIPs'] = self.guestAgent.guestInfo['guestIPs']
toSave['guestFQDN'] = self.guestAgent.guestInfo['guestFQDN']
@@ -2225,7 +2229,7 @@
self.log.debug('reboot event')
self._startTime = time.time()
self._guestEventTime = self._startTime
- self._guestEvent = 'RebootInProgress'
+ self._guestEvent = vmstatus.REBOOT_IN_PROGRESS
self.saveState()
self.guestAgent.onReboot()
if self.conf.get('volatileFloppy'):
@@ -2436,11 +2440,12 @@
raise RuntimeError('waiting more that %ss for _guestCpuLock' %
timeout)
- def cont(self, afterState='Up', guestCpuLocked=False):
+ def cont(self, afterState=vmstatus.UP, guestCpuLocked=False):
if not guestCpuLocked:
self._acquireCpuLockWithTimeout()
try:
- if self.lastStatus in ('Migration Source', 'Saving State', 'Down'):
+ if self.lastStatus in (vmstatus.MIGRATION_SOURCE,
+ vmstatus.SAVING_STATE, vmstatus.DOWN):
self.log.error('cannot cont while %s', self.lastStatus)
return errCode['unexpected']
self._underlyingCont()
@@ -2457,7 +2462,7 @@
if not guestCpuLocked:
self._guestCpuLock.release()
- def pause(self, afterState='Paused', guestCpuLocked=False,
+ def pause(self, afterState=vmstatus.PAUSED, guestCpuLocked=False,
pauseCode='NOERR'):
if not guestCpuLocked:
self._acquireCpuLockWithTimeout()
@@ -2476,11 +2481,11 @@
def shutdown(self, timeout, message):
try:
now = time.time()
- if self.lastStatus == 'Down':
+ if self.lastStatus == vmstatus.DOWN:
return
if self.guestAgent and self.guestAgent.isResponsive():
self._guestEventTime = now
- self._guestEvent = 'Powering down'
+ self._guestEvent = vmstatus.POWERING_DOWN
self.log.debug('guestAgent shutdown called')
self.guestAgent.desktopShutdown(timeout, message)
agent_timeout = (int(timeout) +
@@ -2489,7 +2494,7 @@
timer.start()
elif utils.tobool(self.conf.get('acpiEnable', 'true')):
self._guestEventTime = now
- self._guestEvent = 'Powering down'
+ self._guestEvent = vmstatus.POWERING_DOWN
self._acpiShutdown()
# No tools, no ACPI
else:
@@ -2508,7 +2513,7 @@
def _timedShutdown(self):
self.log.debug('_timedShutdown Called')
try:
- if self.lastStatus == 'Down':
+ if self.lastStatus == vmstatus.DOWN:
return
if not utils.tobool(self.conf.get('acpiEnable', 'true')):
self.destroy()
@@ -2567,7 +2572,7 @@
def setDownStatus(self, code, reason):
try:
- self.lastStatus = 'Down'
+ self.lastStatus = vmstatus.DOWN
with self._confLock:
self.conf['exitCode'] = code
if 'restoreState' in self.conf:
@@ -2607,16 +2612,16 @@
GUEST_WAIT_TIMEOUT = 60
now = time.time()
if now - self._guestEventTime < 5 * GUEST_WAIT_TIMEOUT and \
- self._guestEvent == 'Powering down':
+ self._guestEvent == vmstatus.POWERING_DOWN:
return self._guestEvent
if self.guestAgent and self.guestAgent.isResponsive() and \
self.guestAgent.getStatus():
return self.guestAgent.getStatus()
if now - self._guestEventTime < GUEST_WAIT_TIMEOUT:
return self._guestEvent
- return 'Up'
+ return vmstatus.UP
- if self.lastStatus == 'Down':
+ if self.lastStatus == vmstatus.DOWN:
stats = {}
stats['exitCode'] = self.conf['exitCode']
stats['status'] = self.lastStatus
@@ -2666,16 +2671,17 @@
self.log.error("Error setting vm disk stats",
exc_info=True)
- statuses = ('Saving State', 'Restoring state', 'Migration Source',
- 'Migration Destination', 'Paused')
+ statuses = (vmstatus.SAVING_STATE, vmstatus.RESTORING_STATE,
+ vmstatus.MIGRATION_SOURCE, vmstatus.MIGRATION_DESTINATION,
+ vmstatus.PAUSED)
if self.lastStatus in statuses:
stats['status'] = self.lastStatus
elif self.isMigrating():
if self._migrationSourceThread._mode == 'file':
- stats['status'] = 'Saving State'
+ stats['status'] = vmstatus.SAVING_STATE
else:
- stats['status'] = 'Migration Source'
- elif self.lastStatus == 'Up':
+ stats['status'] = vmstatus.MIGRATION_SOURCE
+ elif self.lastStatus == vmstatus.UP:
stats['status'] = _getGuestStatus()
else:
stats['status'] = self.lastStatus
@@ -2716,7 +2722,7 @@
return errCode['transientErr']
# while we were blocking, another migrationSourceThread could have
# taken self Down
- if self._lastStatus == 'Down':
+ if self._lastStatus == vmstatus.DOWN:
return errCode['noVM']
self._migrationSourceThread = \
self.MigrationSourceThreadClass(self, **params)
@@ -2905,8 +2911,8 @@
self._guestCpuRunning = (self._dom.info()[0] ==
libvirt.VIR_DOMAIN_RUNNING)
- if self.lastStatus not in ('Migration Destination',
- 'Restoring state'):
+ if self.lastStatus not in (vmstatus.MIGRATION_DESTINATION,
+ vmstatus.RESTORING_STATE):
self._initTimePauseCode = self._readPauseCode(0)
if 'recover' not in self.conf and self._initTimePauseCode:
self.conf['pauseCode'] = self._initTimePauseCode
@@ -4349,7 +4355,7 @@
return {'status': doneCode}
self.log.info('Release VM resources')
- self.lastStatus = 'Powering down'
+ self.lastStatus = vmstatus.POWERING_DOWN
try:
# Terminate the VM's creation thread.
self._incomingMigrationFinished.set()
@@ -4871,13 +4877,13 @@
eventToString(event), detail, opaque)
if event == libvirt.VIR_DOMAIN_EVENT_STOPPED:
if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and
- self.lastStatus == 'Migration Source'):
+ self.lastStatus == vmstatus.MIGRATION_SOURCE):
hooks.after_vm_migrate_source(self._lastXMLDesc, self.conf)
for dev in self._customDevices():
hooks.after_device_migrate_source(
dev._deviceXML, self.conf, dev.custom)
elif (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_SAVED and
- self.lastStatus == 'Saving State'):
+ self.lastStatus == vmstatus.SAVING_STATE):
hooks.after_vm_hibernate(self._lastXMLDesc, self.conf)
else:
if detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN:
@@ -4913,7 +4919,7 @@
else:
hooks.after_vm_cont(domxml, self.conf)
elif (detail == libvirt.VIR_DOMAIN_EVENT_RESUMED_MIGRATED and
- self.lastStatus == 'Migration Destination'):
+ self.lastStatus == vmstatus.MIGRATION_DESTINATION):
self._incomingMigrationFinished.set()
def _updateDevicesDomxmlCache(self, xml):
diff --git a/vdsm/vmstatus.py b/vdsm/vmstatus.py
new file mode 100644
index 0000000..ffab32c
--- /dev/null
+++ b/vdsm/vmstatus.py
@@ -0,0 +1,31 @@
+#
+# 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
+#
+
+UP = 'Up'
+DOWN = 'Down'
+MIGRATION_SOURCE = 'Migration Source'
+MIGRATION_DESTINATION = 'Migration Destination'
+PAUSED = 'Paused'
+POWERING_DOWN = 'Powering down'
+POWERING_UP = 'Powering up'
+REBOOT_IN_PROGRESS = 'RebootInProgress'
+RESTORING_STATE = 'Restoring state'
+SAVING_STATE = 'Saving State'
+WAIT_FOR_LAUNCH = 'WaitForLaunch'
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index c534c2d..32f67e8 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -1769,6 +1769,8 @@
#
# @Powering down: A shutdown command has been sent to the VM
#
+# @Powering up: The VM is booting
+#
# @RebootInProgress: The VM is currently rebooting
#
# @Restoring state: The VM is waking from hibernation
--
To view, visit http://gerrit.ovirt.org/21790
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I95e6945c2ee9d443e22586f04dc0f9646cc5cbb3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: build: Forbid bare exepct
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: build: Forbid bare exepct
......................................................................
build: Forbid bare exepct
Using bare except is bad practice and is never required. We should
disallow this in new code. This patch ensure that your build will break
if your patch added a bare except.
Change-Id: I5b7f33b6eb1c90610b3a5d053ba65ce3fc6b74fa
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M Makefile.am
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/22456/1
diff --git a/Makefile.am b/Makefile.am
index 9b1a3c9..d25d395 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,6 +79,10 @@
'lv' from line .*"
check-local:
+ if git show | grep 'except:'; then \
+ echo "error: empty except: is not allowed!"; \
+ exit 1; \
+ fi
find . -path './.git' -prune -type f -o \
-name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \
grep -w -v $(SKIP_PYFLAKES_ERR) | \
--
To view, visit http://gerrit.ovirt.org/22456
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b7f33b6eb1c90610b3a5d053ba65ce3fc6b74fa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: Run pinger in separate process
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: Run pinger in separate process
......................................................................
Run pinger in separate process
Running pinger in a separate process should be less fragile, as the
pinger thread cannot be delayed because of locking issues. Hopefully
this will eliminate the conectivity failures we see on CI.
Change-Id: I92719ef4a2673ed874fa47a9acbc1e7028bb7197
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
A tests/functional/ping.py
M tests/functional/utils.py
2 files changed, 14 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/22293/1
diff --git a/tests/functional/ping.py b/tests/functional/ping.py
new file mode 100644
index 0000000..70f9195
--- /dev/null
+++ b/tests/functional/ping.py
@@ -0,0 +1,8 @@
+import time
+from vdsm import vdscli
+
+client = vdscli.connect()
+
+while True:
+ client.ping()
+ time.sleep(1)
diff --git a/tests/functional/utils.py b/tests/functional/utils.py
index 79327f6..e884a79 100644
--- a/tests/functional/utils.py
+++ b/tests/functional/utils.py
@@ -19,13 +19,14 @@
from collections import namedtuple
from contextlib import contextmanager
from functools import wraps
-import time
-import threading
+import os
from vdsm.config import config
+from vdsm import constants
from vdsm import ipwrapper
from vdsm import netinfo
from vdsm import vdscli
+from vdsm import utils
from vdsm.netconfpersistence import RunningConfig
import supervdsm
@@ -174,19 +175,12 @@
@contextmanager
def pinger(self):
"""Keeps pinging vdsm for operations that need it"""
- def ping():
- while not done:
- self.vdscli.ping()
- time.sleep(1)
+ path = os.path.join(os.path.dirname(__file__), 'ping.py')
+ pinger = utils.execCmd([constants.EXT_PYTHON, path], sync=False)
try:
- done = False
- pinger_thread = threading.Thread(target=ping)
- pinger_thread.start()
yield
- except Exception:
- raise
finally:
- done = True
+ pinger.kill()
def networkQos(self, networkName):
network = self.netinfo.networks[networkName]
--
To view, visit http://gerrit.ovirt.org/22293
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92719ef4a2673ed874fa47a9acbc1e7028bb7197
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: lvm: Invalidate lvm cache after extend
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: lvm: Invalidate lvm cache after extend
......................................................................
lvm: Invalidate lvm cache after extend
After extending a vg, lvm filter is updated with the new pv, but cached
pv are never updated. This cause commands that use short filter to fail,
and then they are run again without the short filter.
This patch adds a grace period where cache is invalidated if we find
that the short filter is stale and long filter is good. The first
failing command using short filter invoked after vg was extended will
invalidate the cache.
Change-Id: I96e628174143fc887e649fe67f2f1171fc176cca
Relates-To: https://bugzilla.redhat.com/1022976
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/lvm.py
2 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/21192/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index a508051..c9afb4f 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -2005,7 +2005,7 @@
:rtype: dict
"""
visibility = self.scanDevicesVisibility(guids)
- lvm.invalidateFilter()
+ lvm.prepareForExtend()
for guid in guids:
if visibility[guid]:
visibility[guid] = (os.stat('/dev/mapper/' + guid).st_mode &
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index f730adc..e9e8b35 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -30,6 +30,7 @@
import re
import pwd
import grp
+import time
import logging
from collections import namedtuple
import pprint as pp
@@ -291,6 +292,13 @@
self.invalidateFilter()
self.flush()
+ def prepareForExtend(self):
+ self._lastExtended = time.time()
+ self.invalidateFilter()
+
+ def wasExtendedRecently(self):
+ return time.time() - self._lastExtended < 300.0
+
def __init__(self):
self._filterStale = True
self._extraCfg = None
@@ -303,20 +311,28 @@
self._pvs = {}
self._vgs = {}
self._lvs = {}
+ self._lastExtended = 0.0
def cmd(self, cmd, devices=tuple()):
+ # First try using short filter if devices were specified
finalCmd = self._addExtraCfg(cmd, devices)
rc, out, err = misc.execCmd(finalCmd, sudo=True)
if rc != 0:
# Filter might be stale
self.invalidateFilter()
+ # Try again with long filter
newCmd = self._addExtraCfg(cmd)
# Before blindly trying again make sure
# that the commands are not identical, because
# the devlist is sorted there is no fear
# of two identical filters looking differently
if newCmd != finalCmd:
- return misc.execCmd(newCmd, sudo=True)
+ rc, out, err = misc.execCmd(newCmd, sudo=True)
+ if rc == 0 and devices and self.wasExtendedRecently():
+ # Looks like the cache is stale. It would be nice to
+ # invalidate only the pvs, but I'm not sure it works, so
+ # lets invalidate the whole thing.
+ self.flush()
return rc, out, err
@@ -1313,8 +1329,8 @@
return [lv for lv in getLV(vgName) if tag in lv.tags]
-def invalidateFilter():
- _lvminfo.invalidateFilter()
+def prepareForExtend():
+ _lvminfo.prepareForExtend()
# Fix me: unify with addTag
--
To view, visit http://gerrit.ovirt.org/21192
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96e628174143fc887e649fe67f2f1171fc176cca
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
10 years, 3 months