Federico Simoncelli has uploaded a new change for review.
Change subject: lib: add support for utillinux commands
......................................................................
lib: add support for utillinux commands
Change-Id: I2ea7dd19fadc600b8fe78fb436ae430d35f52165
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M lib/vdsm/Makefile.am
A lib/vdsm/utillinux.py
M tests/Makefile.am
A tests/utillinuxTests.py
M vdsm.spec.in
5 files changed, 132 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/35629/1
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index b862e71..4e0868a 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -33,6 +33,7 @@
profile.py \
qemuimg.py \
sslutils.py \
+ utillinux.py \
utils.py \
vdscli.py \
virtsparsify.py \
diff --git a/lib/vdsm/utillinux.py b/lib/vdsm/utillinux.py
new file mode 100644
index 0000000..7fb42cf
--- /dev/null
+++ b/lib/vdsm/utillinux.py
@@ -0,0 +1,47 @@
+#
+# Copyright 2014 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
+#
+
+import os
+import re
+import signal
+
+from . import utils
+
+_blkdiscard = utils.CommandPath("blkdiscard",
+ "/sbin/blkdiscard",) # Fedora, EL6
+
+
+def blkdiscard(device, offset=None, length=None, secure=False):
+ cmd = [_blkdiscard.cmd]
+
+ if offset:
+ cmd.extend(("-o", str(offset)))
+
+ if length:
+ cmd.extend(("-l", str(length)))
+
+ if secure:
+ cmd.append("-s")
+
+ cmd.append(device)
+ rc, out, err = utils.execCmd(cmd, deathSignal=signal.SIGKILL)
+
+ if rc != 0:
+ raise QImgError(rc, out, err)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b365921..5aa9fc3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -79,6 +79,7 @@
testlibTests.py \
toolTests.py \
transportWrapperTests.py \
+ utillinuxTests.py \
utilsTests.py \
vdsClientTests.py \
vmApiTests.py \
diff --git a/tests/utillinuxTests.py b/tests/utillinuxTests.py
new file mode 100644
index 0000000..dbbb50e
--- /dev/null
+++ b/tests/utillinuxTests.py
@@ -0,0 +1,82 @@
+#
+# Copyright 2014 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
+#
+
+from testlib import VdsmTestCase as TestCaseBase
+import monkeypatch
+from vdsm import utillinux
+from vdsm import utils
+
+BLKDISCARD = utillinux._blkdiscard.cmd
+
+
+class FakeCmd(object):
+
+ def __init__(self, module, name, *calls):
+ self.patch = monkeypatch.Patch([(module, name, self)])
+ self.calls = list(calls)
+
+ def __call__(self, cmd, **kw):
+ call = self.calls.pop(0)
+ return call(cmd, **kw)
+
+ def __enter__(self):
+ self.patch.apply()
+
+ def __exit__(self, t=None, v=None, tb=None):
+ self.patch.revert()
+
+
+class BlkDiscardTests(TestCaseBase):
+
+ def test_no_options(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device')
+
+ def test_offset(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-o', '1024', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', offset=1024)
+
+ def test_length(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-l', '2048', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', length=2048)
+
+ def test_offset_and_length(self):
+ def discard(cmd, **kw):
+ expected = [BLKDISCARD, '-o', '1024', '-l', '2048', 'device']
+ self.assertEqual(cmd, expected)
+ return 0, '', ''
+
+ with FakeCmd(utils, 'execCmd', discard):
+ utillinux.blkdiscard('device', offset=1024, length=2048)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index d15f5c2..befe0e0 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1252,6 +1252,7 @@
%{python_sitelib}/%{vdsm_name}/qemuimg.py*
%{python_sitelib}/%{vdsm_name}/netconfpersistence.py*
%{python_sitelib}/%{vdsm_name}/sslutils.py*
+%{python_sitelib}/%{vdsm_name}/utillinux.py*
%{python_sitelib}/%{vdsm_name}/utils.py*
%{python_sitelib}/%{vdsm_name}/vdscli.py*
%{python_sitelib}/%{vdsm_name}/virtsparsify.py*
--
To view, visit http://gerrit.ovirt.org/35629
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ea7dd19fadc600b8fe78fb436ae430d35f52165
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
Nir Soffer has uploaded a new change for review.
Change subject: lvm: Decrease number of retries before failing
......................................................................
lvm: Decrease number of retries before failing
Previously we configured lvm to stop accessing a device during an lvm
opoeration after 3 errors. This can cause lvm to block 3 times when
trying to access inaccessible device. With current iscsi settings, each
block can be 120 seconds, total 360 seconds. We have seen lvm block for
couple of minutes in such cases.
The retries seems uneeded when working with multiple paths, as multipath
already retry all available paths after SCSI errors on one path. However
when working with single path, multipath should fail after one try.
According to lvm developer this may decrease the time lvm is blocked
when devices are not accesible.
(Not tested yet)
Change-Id: I5d11abaaff45ce86e88c6589264e162318ac1f1d
Relates-To: https://bugzilla.redhat.com/880738
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/lvm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/32356/1
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 86edf55..f760f7b 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -106,7 +106,7 @@
preferred_names = ["^/dev/mapper/"]
ignore_suspended_devices=1
write_cache_state=0
-disable_after_error_count=3
+disable_after_error_count=1
obtain_device_list_from_udev=0
%s
}
--
To view, visit http://gerrit.ovirt.org/32356
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d11abaaff45ce86e88c6589264e162318ac1f1d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Nir Soffer has uploaded a new change for review.
Change subject: clusterlock: Remove uneeded workaround
......................................................................
clusterlock: Remove uneeded workaround
Sanlock version XXXX had a off-by-one bug when calling get_hosts with a
host id, returning info for the next host. This bug is fixed in version
XXX. Now we can use the hostId parameter, making the call more efficient
and simpligying clusterlock code.
Change-Id: Ide75e749fbc2916540c2b526b78fedc247b5c6f9
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm.spec.in
M vdsm/storage/clusterlock.py
2 files changed, 5 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/31162/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 5ba6fc6..fc39eb9 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -167,7 +167,7 @@
Requires: iscsi-initiator-utils >= 6.2.0.873-21
%endif
-Requires: sanlock >= 2.8, sanlock-python
+Requires: sanlock >= XXX, sanlock-python
%if 0%{?rhel}
Requires: python-ethtool >= 0.6-3
diff --git a/vdsm/storage/clusterlock.py b/vdsm/storage/clusterlock.py
index 24a5d81..17cdd53 100644
--- a/vdsm/storage/clusterlock.py
+++ b/vdsm/storage/clusterlock.py
@@ -265,26 +265,15 @@
return False
def getHostStatus(self, hostId):
- # Note: get_hosts has off-by-one bug when asking for particular host
- # id, so get all hosts info and filter.
- # See https://bugzilla.redhat.com/1111210
try:
- hosts = sanlock.get_hosts(self._sdUUID)
+ hosts = sanlock.get_hosts(self._sdUUID, hostId)
except sanlock.SanlockException as e:
self.log.debug("Unable to get host %d status in lockspace %s: %s",
hostId, self._sdUUID, e)
return HOST_STATUS_UNAVAILABLE
-
- for info in hosts:
- if info['host_id'] == hostId:
- status = info['flags']
- return self.STATUS_NAME[status]
-
- # get_hosts with host_id=0 returns only hosts with timestamp != 0,
- # which means that no host is using this host id now. If there a
- # timestamp, sanlock will return HOST_UNKNOWN and then HOST_LIVE or
- # HOST_FAIL.
- return HOST_STATUS_FREE
+ else:
+ status = hosts[0]['flags']
+ return self.STATUS_NAME[status]
# The hostId parameter is maintained here only for compatibility with
# ClusterLock. We could consider to remove it in the future but keeping it
--
To view, visit http://gerrit.ovirt.org/31162
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide75e749fbc2916540c2b526b78fedc247b5c6f9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Liron Aravot has uploaded a new change for review.
Change subject: hsm: prepareForShutdown - operations order
......................................................................
hsm: prepareForShutdown - operations order
Currently cleanupMasterMount() is executed before
taskMgr.prepareForShutdown() and before the domain monitor is stopped,
that causes to errors during the tasks abortion (becasue of failure to
access the path) and to erros when stopping the domain monitoring
thread on that domain.
The solution introduced in that patch is to change the order of the
operations - so that the cleanupMasterMount() will be executed only
after the other operations are executed.
Change-Id: I9edd84317b08a17db80e265053edaf69582c2a51
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1161934
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/36162/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index c8aaf93..8f71d71 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3433,7 +3433,6 @@
# stop spm tasks if spm etc.)
try:
self._connectionMonitor.stopMonitoring()
- sp.StoragePool.cleanupMasterMount()
self.__releaseLocks()
for spUUID in self.pools:
@@ -3454,6 +3453,7 @@
exc_info=True)
self.taskMng.prepareForShutdown()
+ sp.StoragePool.cleanupMasterMount()
except:
pass
--
To view, visit http://gerrit.ovirt.org/36162
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9edd84317b08a17db80e265053edaf69582c2a51
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <laravot(a)redhat.com>
Candace Sheremeta has uploaded a new change for review.
Change subject: vdsm: added functionality to teardownImage when disk has been deleted
......................................................................
vdsm: added functionality to teardownImage when disk has been deleted
added code to teardownImage in hsm.py so that teardownImage reports
"Volume does not exist" for a previously deleted disk, where it
previously simply reported "OK" - teardownImage now checks to see
if volume exists before attempting to delete it
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1184718
Change-Id: Ia929dfdc78ccaa736033e41a77bce861d5a27769
Signed-off-by: Candace Sheremeta <cshereme(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/38241/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 8c75277..45e6634 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3271,6 +3271,13 @@
vars.task.getSharedLock(STORAGE, sdUUID)
dom = sdCache.produce(sdUUID)
+ allVols = dom.getAllVolumes()
+ # Filter volumes related to this image
+ imgVolumes = sd.getVolsOfImage(allVols, imgUUID).keys()
+
+ if volUUID not in imgVolumes:
+ raise se.VolumeDoesNotExist(volUUID)
+
dom.deactivateImage(imgUUID)
@public
--
To view, visit https://gerrit.ovirt.org/38241
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia929dfdc78ccaa736033e41a77bce861d5a27769
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Candace Sheremeta <cshereme(a)redhat.com>
Francesco Romani has uploaded a new change for review.
Change subject: janitorial: vm: remove _reportError
......................................................................
janitorial: vm: remove _reportError
Vm._reportError was an early attempt to build what
we have now with response.error().
With the new code in place there is no more reason
to use it, so this patch removes it.
Change-Id: Ie23167c0289bdb0326dcfe48903cd1bae905e9b5
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 15 insertions(+), 27 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/38269/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index cd392c7..4be63ce 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -42,7 +42,7 @@
from vdsm import utils
from vdsm.compat import pickle
from vdsm.config import config
-from vdsm.define import ERROR, NORMAL, doneCode, errCode
+from vdsm.define import ERROR, NORMAL, doneCode
from vdsm.netinfo import DUMMY_BRIDGE
from storage import outOfProcess as oop
from storage import sd
@@ -2650,15 +2650,15 @@
if not params:
self.log.error("updateVmPolicy got an empty policy.")
- return self._reportError(key='MissParam',
- msg="updateVmPolicy got an empty policy.")
+ return response.error('MissParam',
+ 'updateVmPolicy got an empty policy.')
#
# Get the current QoS block
metadata_modified = False
qos = self._getVmPolicy()
if qos is None:
- return self._reportError(key='updateVmPolicyErr')
+ return response.error('updateVmPolicyErr')
#
# Process provided properties, remove property after it is processed
@@ -2712,8 +2712,7 @@
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return response.error('noVM')
else:
- return self._reportError(key='updateVmPolicyErr',
- msg=e.message)
+ return response.error('updateVmPolicyErr', e.message)
return {'status': doneCode}
@@ -2771,9 +2770,9 @@
found_device = self._findDeviceByNameOrPath(device_name,
device_path)
if found_device is None:
- return self._reportError(
- key='updateIoTuneErr',
- msg="Device {} not found".format(device_name))
+ return response.error(
+ 'updateIoTuneErr',
+ "Device {} not found".format(device_name))
# Merge the update with current values
dom = found_device.getXML()
@@ -2799,8 +2798,7 @@
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return response.error('noVM')
else:
- return self._reportError(key='updateIoTuneErr',
- msg=e.message)
+ return response.error('updateIoTuneErr', e.message)
# Update both the ioTune arguments and device xml DOM
# so we are still up-to-date
@@ -3956,7 +3954,7 @@
def setBalloonTarget(self, target):
if self._dom is None:
- return self._reportError(key='balloonErr')
+ return response.error('balloonErr')
try:
target = int(target)
self._dom.setMemory(target)
@@ -3980,8 +3978,8 @@
try:
self._dom.setSchedulerParameters({'vcpu_quota': int(quota)})
except ValueError:
- return self._reportError(key='cpuTuneErr',
- msg='an integer is required for period')
+ return response.error('cpuTuneErr',
+ 'an integer is required for period')
except libvirt.libvirtError as e:
return self._reportException(key='cpuTuneErr', msg=e.message)
return {'status': doneCode}
@@ -3990,21 +3988,11 @@
try:
self._dom.setSchedulerParameters({'vcpu_period': int(period)})
except ValueError:
- return self._reportError(key='cpuTuneErr',
- msg='an integer is required for period')
+ return response.error('cpuTuneErr',
+ 'an integer is required for period')
except libvirt.libvirtError as e:
return self._reportException(key='cpuTuneErr', msg=e.message)
return {'status': doneCode}
-
- def _reportError(self, key, msg=None):
- """
- Produce an error status.
- """
- if msg is None:
- error = errCode[key]
- else:
- error = response.error(key, msg)
- return error
def _reportException(self, key, msg=None):
"""
@@ -4012,7 +4000,7 @@
This method should be called only within exception-handling context.
"""
self.log.exception("Operation failed")
- return self._reportError(key, msg)
+ return response.error(key, msg)
def _getUnderlyingDeviceAddress(self, devXml):
"""
--
To view, visit https://gerrit.ovirt.org/38269
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie23167c0289bdb0326dcfe48903cd1bae905e9b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Adam Litke has uploaded a new change for review.
Change subject: Don't prepare image with illegal volumes
......................................................................
Don't prepare image with illegal volumes
The irs verb 'prepareImage' is used only by clientIF when preparing the
host to start a VM. Currently, this operation succeeds even if one or
more of the volumes in the image is illegal. Since we should never
permit a VM to start with an illegal disk, check for this and report an
error if any illegal volumes are found.
The pivot stage of a live merge operation depends on this behavior to
ensure that a VM is not accidentally started using a stale leaf volume.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1206722
Change-Id: Ie543aeb8bdb52305419613ab6297681817124308
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/39302/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 8f07586..dc8ca77 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3225,6 +3225,11 @@
if leafUUID not in imgVolumes:
raise se.VolumeDoesNotExist(leafUUID)
+ for volUUID in imgVolumes:
+ legality = dom.produceVolume(imgUUID, volUUID).getLegality()
+ if legality == volume.ILLEGAL_VOL:
+ raise se.prepareIllegalVolumeError(volUUID)
+
imgPath = dom.activateVolumes(imgUUID, imgVolumes)
if spUUID and spUUID != sd.BLANK_UUID:
runImgPath = dom.linkBCImage(imgPath, imgUUID)
--
To view, visit https://gerrit.ovirt.org/39302
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie543aeb8bdb52305419613ab6297681817124308
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>