Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for SmartcardDevice
......................................................................
virt: dev: implement from_xml for SmartcardDevice
Change-Id: I395c49d1cd9af04527840a7d5aaf853d35aa122d
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/33753/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index e340ed0..a6e68ae 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4820,19 +4820,18 @@
if not x.getElementsByTagName('address'):
continue
- address = vmxml.device_address(x)
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+ dev = SmartCardDevice.from_xml(x)
for dev in self._devices[SMARTCARD_DEVICES]:
if not hasattr(dev, 'address'):
- dev.address = address
- dev.alias = alias
+ dev.address = dev.address
+ dev.alias = dev.alias
for dev in self.conf['devices']:
if dev['device'] == SMARTCARD_DEVICES and \
not dev.get('address'):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
def _getUnderlyingWatchdogDeviceInfo(self):
"""
--
To view, visit http://gerrit.ovirt.org/33753
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I395c49d1cd9af04527840a7d5aaf853d35aa122d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for WatchdogDevice
......................................................................
virt: dev: implement from_xml for WatchdogDevice
Change-Id: I8ceb0f85908c99454f0c981fa4318cc1989f0f7c
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/33752/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a63c932..e340ed0 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4845,19 +4845,18 @@
# PCI watchdog has "address" different from ISA watchdog
if x.getElementsByTagName('address'):
- address = vmxml.device_address(x)
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+ dev = WatchdogDevice.from_xml(x)
for wd in self._devices[WATCHDOG_DEVICES]:
if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
- wd.address = address
- wd.alias = alias
+ wd.address = dev.address
+ wd.alias = dev.alias
for dev in self.conf['devices']:
if ((dev['type'] == WATCHDOG_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
def _getUnderlyingVideoDeviceInfo(self):
"""
--
To view, visit http://gerrit.ovirt.org/33752
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ceb0f85908c99454f0c981fa4318cc1989f0f7c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: implement from_xml for SoundDevice
......................................................................
virt: dev: implement from_xml for SoundDevice
Change-Id: I04ffbb857557e9f438634465c3f13ca6446393e5
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 5 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/51/33751/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index d356da8..a63c932 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4892,9 +4892,7 @@
soundsxml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
getElementsByTagName('devices')[0].getElementsByTagName('sound')
for x in soundsxml:
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
- # Get sound card address
- address = vmxml.device_address(x)
+ dev = SoundDevice.from_xml(x)
# FIXME. We have an identification problem here.
# Sound device has not unique identifier, except the alias
@@ -4902,15 +4900,15 @@
# we can only assign the address according to devices order.
for sc in self._devices[SOUND_DEVICES]:
if not hasattr(sc, 'address') or not hasattr(sc, 'alias'):
- sc.alias = alias
- sc.address = address
+ sc.alias = dev.alias
+ sc.address = dev.address
break
# Update vm's conf with address
for dev in self.conf['devices']:
if ((dev['type'] == SOUND_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
break
def _getDriveIdentification(self, dom):
--
To view, visit http://gerrit.ovirt.org/33751
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I04ffbb857557e9f438634465c3f13ca6446393e5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Francesco Romani has uploaded a new change for review.
Change subject: virt: dev: bootstrap from_xml method
......................................................................
virt: dev: bootstrap from_xml method
implement from_xml method, do incapsulate device
creation from xml description.
Use it for Video Devices.
Change-Id: I745909ce65ecb30da299d2d8afb1987a91581ace
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices.py
2 files changed, 11 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/33750/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5b710a8..d356da8 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4866,9 +4866,7 @@
videosxml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
getElementsByTagName('devices')[0].getElementsByTagName('video')
for x in videosxml:
- alias = x.getElementsByTagName('alias')[0].getAttribute('name')
- # Get video card address
- address = vmxml.device_address(x)
+ dev = vmdevices.VideoDevice.from_xml(x)
# FIXME. We have an identification problem here.
# Video card device has not unique identifier, except the alias
@@ -4876,15 +4874,15 @@
# we can only assign the address according to devices order.
for vc in self._devices[VIDEO_DEVICES]:
if not hasattr(vc, 'address') or not hasattr(vc, 'alias'):
- vc.alias = alias
- vc.address = address
+ vc.alias = dev.alias
+ vc.address = dev.address
break
# Update vm's conf with address
for dev in self.conf['devices']:
if ((dev['type'] == VIDEO_DEVICES) and
(not dev.get('address') or not dev.get('alias'))):
- dev['address'] = address
- dev['alias'] = alias
+ dev['address'] = dev.address
+ dev['alias'] = dev.alias
break
def _getUnderlyingSoundDeviceInfo(self):
diff --git a/vdsm/virt/vmdevices.py b/vdsm/virt/vmdevices.py
index 7b01cc4..14278e1 100644
--- a/vdsm/virt/vmdevices.py
+++ b/vdsm/virt/vmdevices.py
@@ -44,6 +44,12 @@
if not a.startswith('__')]
return ' '.join(attrs)
+ @classmethod
+ def from_xml(cls, conf, log, dev_xml):
+ alias = dev_xml.getElementsByTagName('alias')[0].getAttribute('name')
+ address = vmxml.device_address(dev_xml)
+ return cls(conf, log, alias=alias, address=address)
+
class VideoDevice(Base):
__slots__ = ('address',)
--
To view, visit http://gerrit.ovirt.org/33750
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I745909ce65ecb30da299d2d8afb1987a91581ace
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Amador Pahim has uploaded a new change for review.
Change subject: hook: diskunmap: To include UNMAP support for disk and lun devices
......................................................................
hook: diskunmap: To include UNMAP support for disk and lun devices
This hook goes through VM definitions xml file and manipulate its
disk device if it "disk" or "lun" and if the bus is "scsi" or "ide",
adding "discard=unmap" option to "-drive" qemu command line patameter.
UNMAP support was added to qemu 1.5 and it's intendded to return the
unused/freed blocks back to the storage, optimizing the utilizationi,
specially useful for thin provisioned LUNs.
Result example:
<disk device="disk" snapshot="no" type="block">
...
<target bus="ide" dev="hda"/>
...
<driver cache="none" discard="unmap" ... />
</disk>
<disk device="lun" sgio="filtered" snapshot="no" type="block">
...
<target bus="scsi" dev="sda"/>
...
<driver cache="none" discard="unmap" ... />
</disk>
Change-Id: I36385f1af24043755b3d4b6594bbe598b0d9518d
Signed-off-by: Amador Pahim <apahim(a)redhat.com>
---
M configure.ac
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/diskunmap/Makefile.am
A vdsm_hooks/diskunmap/README
A vdsm_hooks/diskunmap/before_vm_start.py
6 files changed, 178 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/29770/1
diff --git a/configure.ac b/configure.ac
index d741c1b..ce9d800 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,7 @@
vdsm_hooks/Makefile
vdsm_hooks/checkimages/Makefile
vdsm_hooks/directlun/Makefile
+ vdsm_hooks/diskunmap/Makefile
vdsm_hooks/ethtool_options/Makefile
vdsm_hooks/extnet/Makefile
vdsm_hooks/fakevmstats/Makefile
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2b67962..2c48e3e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -366,6 +366,14 @@
VDSM hook used to perform consistency check on a qcow2 format disk image
using the QEMU disk image utility.
+%package hook-diskunmap
+Summary: Activate UNMAP for disk/lun devices
+BuildArch: noarch
+Requires: qemu-kvm >= 1.5
+
+%description hook-diskunmap
+VDSM hooks which allow to activate disk UNMAP.
+
%package hook-ethtool-options
Summary: Allow setting custom ethtool options for vdsm controlled nics
BuildArch: noarch
@@ -1282,6 +1290,10 @@
%{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy/50_directlun
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_destination/50_directlun
+%files hook-diskunmap
+%defattr(-, root, root, -)
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_diskunmap
+
%files hook-fakevmstats
%defattr(-, root, root, -)
%{_libexecdir}/%{vdsm_name}/hooks/after_get_all_vm_stats/10_fakevmstats
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index 5e4d731..20578db 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -27,6 +27,7 @@
SUBDIRS += \
checkimages \
directlun \
+ diskunmap \
extnet \
fileinject \
fakevmstats \
diff --git a/vdsm_hooks/diskunmap/Makefile.am b/vdsm_hooks/diskunmap/Makefile.am
new file mode 100644
index 0000000..f2b9a85
--- /dev/null
+++ b/vdsm_hooks/diskunmap/Makefile.am
@@ -0,0 +1,31 @@
+#
+# 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
+#
+#
+EXTRA_DIST = \
+ before_vm_start.py
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_diskunmap
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_diskunmap
+
diff --git a/vdsm_hooks/diskunmap/README b/vdsm_hooks/diskunmap/README
new file mode 100644
index 0000000..35751d6
--- /dev/null
+++ b/vdsm_hooks/diskunmap/README
@@ -0,0 +1,40 @@
+diskunmap vdsm hook:
+==================
+This hook goes through all of the VM's disks and manipulate its XML
+file acccording to the input. This can be used to enable UNMAP feature
+to discard unused blocks for better use of thin provisioned storage
+devices.
+
+Syntax:
+ diskunmap=(off|on)
+
+Where:
+ 'on' is unmap enabled and off (default) is unmap disabled.
+
+Example:
+ diskunmap=on
+
+Installation:
+ - Use the engine-config to append the proper custom property:
+ $ sudo engine-config -s UserDefinedVMProperties='diskunmap=^(off|on)$'
+ - Verify that the macbind custom property was properly added:
+ $ sudo engine-config -g UserDefinedVMProperties
+
+Usage:
+ In the VM configuration window, open the custom properites tab, select
+ diskmap and select 'on', activating disk UNMAP for all disks and LUNs.
+ Only devices using IDE or VirtIO-SCSI interface will be affected. UNMAP is
+ not available for VirtIO interface.
+
+Expected Result:
+ For every DISK or LUN device, this configuration will include
+ "discard=unmap" to disk driver xml:
+
+ <disk device="disk" snapshot="no" type="block">
+ ...
+ <driver cache="none" discard="unmap" ... />
+ </disk>
+
+ This option will be tranlated to qemu as bellow:
+
+ ... -drive file=<file>,discard=unmap,...
diff --git a/vdsm_hooks/diskunmap/before_vm_start.py b/vdsm_hooks/diskunmap/before_vm_start.py
new file mode 100644
index 0000000..2fc0b81
--- /dev/null
+++ b/vdsm_hooks/diskunmap/before_vm_start.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python2
+#
+# 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
+#
+
+
+'''
+Hook to enable disk UNMAP for disk devices.
+
+Syntax:
+ diskunmap=(off|on)
+
+Example:
+ diskunmap=on
+'''
+
+import os
+import sys
+import traceback
+from xml.dom import minidom
+
+import hooking
+
+
+def addDiscardUnmap(domxml):
+ for disk in domxml.getElementsByTagName('disk'):
+ device = disk.getAttribute('device')
+ target = disk.getElementsByTagName('target')[0]
+ bus = target.getAttribute('bus')
+ if ((device == 'disk' or device == 'lun')
+ and (bus == 'scsi' or bus == 'ide')):
+ driver = disk.getElementsByTagName('driver')[0]
+ driver.setAttribute('discard', 'unmap')
+
+
+def main():
+ if 'diskunmap' in os.environ:
+ unmapConfig = os.environ['diskunmap']
+ domxml = hooking.read_domxml()
+ if unmapConfig == 'on':
+ addDiscardUnmap(domxml)
+ hooking.write_domxml(domxml)
+
+
+def test():
+ text = '''<disk device="disk" snapshot="no" type="block">
+<address bus="0" controller="0" target="0" type="drive" unit="0"/>
+<source dev="/rhev/data-center/mnt/blockSD/
+b4cf7d74-6a07-4138-9d4f-80b14c3acefd/images/
+1580607a-b240-4199-99ac-3d2162934ba6/e5ba276f-dcba-4582-b13f-c165afa2f575"/>
+<target bus="ide" dev="hda"/>
+<serial>1580607a-b240-4199-99ac-3d2162934ba6</serial>
+<driver cache="none" error_policy="stop" io="native"
+name="qemu" type="raw"/>
+</disk>'''
+
+ xmldom = minidom.parseString(text)
+
+ disk = xmldom.getElementsByTagName('disk')[0]
+ print "\nDisk device definition before execution: \n%s"\
+ % disk.toxml(encoding='UTF-8')
+
+ addDiscardUnmap(xmldom)
+
+ print "\nDisk device after setting discard attribute: \n%s"\
+ % disk.toxml(encoding='UTF-8')
+
+
+if __name__ == '__main__':
+ try:
+ if '--test' in sys.argv:
+ test()
+ else:
+ main()
+ except:
+ hooking.exit_hook(' diskunmap hook: [unexpected error]: %s\n' %
+ traceback.format_exc())
--
To view, visit http://gerrit.ovirt.org/29770
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I36385f1af24043755b3d4b6594bbe598b0d9518d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Amador Pahim <apahim(a)redhat.com>
Nir Soffer has uploaded a new change for review.
Change subject: vm: Continue to sample after errors
......................................................................
vm: Continue to sample after errors
When vm is running, we monitor disk usage, and if the disk becomes too
full, we extend the disk. This avoid pausing of the vm after io errors.
However, when sampling vm with multiple disks, an error when sampling
one disk exit the sampling function and skip the next disks, making this
machnisim useless.
This patch logs exceptions raised when sampling one disk and continue to
sample others.
This patch is for ovirt-3.3.1 only - master patch must be different
because of recent refactoring in this area.
Change-Id: I8dbe60a4d3b216a5cd998d163407c09b12f2f28c
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 14 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/22575/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 90ab5a7..2d0cece 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -506,20 +506,24 @@
return
for vmDrive in self._vm._devices[DISK_DEVICES]:
- if not vmDrive.isExtendable():
- continue
+ try:
+ if not vmDrive.isExtendable():
+ continue
- capacity, alloc, physical = \
- self._vm._dom.blockInfo(vmDrive.path, 0)
+ capacity, alloc, physical = \
+ self._vm._dom.blockInfo(vmDrive.path, 0)
- if physical - alloc >= vmDrive.watermarkLimit:
- continue
+ if physical - alloc >= vmDrive.watermarkLimit:
+ continue
- self._log.info('%s/%s apparent: %s capacity: %s, alloc: %s, '
- 'phys: %s', vmDrive.domainID, vmDrive.volumeID,
- vmDrive.apparentsize, capacity, alloc, physical)
+ self._log.info('%s/%s apparent: %s capacity: %s, alloc: %s, '
+ 'phys: %s', vmDrive.domainID, vmDrive.volumeID,
+ vmDrive.apparentsize, capacity, alloc, physical)
- self._vm.extendDriveVolume(vmDrive)
+ self._vm.extendDriveVolume(vmDrive)
+ except Exception:
+ self._log.exception("%s/%s", vmDrive.domainID,
+ vmDrive.volumeID)
def _updateVolumes(self):
if not self._vm.isDisksStatsCollectionEnabled():
--
To view, visit http://gerrit.ovirt.org/22575
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8dbe60a4d3b216a5cd998d163407c09b12f2f28c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Nir Soffer has uploaded a new change for review.
Change subject: vm: Fix attribute error when accessing drive in sampling method
......................................................................
vm: Fix attribute error when accessing drive in sampling method
Du to race when migration is finished and monitoring, drive may not have
a format attribute when accessing it from the monitor. This patch use
getattr to log spam.
Change-Id: Ia50e8af94b9c9b54332066a3f30999ce73e7a56f
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/vm.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/18/22518/1
diff --git a/vdsm/vm.py b/vdsm/vm.py
index bb4a7ec..7e2d220 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -506,7 +506,8 @@
return
for vmDrive in self._vm._devices[DISK_DEVICES]:
- if not vmDrive.blockDev or vmDrive.format != 'cow':
+ # Note: drive may not have a format attribute during migration
+ if not vmDrive.blockDev or getattr(vmDrive, 'format', None) != 'cow':
continue
capacity, alloc, physical = \
--
To view, visit http://gerrit.ovirt.org/22518
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia50e8af94b9c9b54332066a3f30999ce73e7a56f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
Dan Kenigsberg has uploaded a new change for review.
Change subject: sampling: use constants for counter bounds
......................................................................
sampling: use constants for counter bounds
When we report cpu and network usage, we take two samples of Linux
counters, and divide their difference by the elapsed time. If a sampled
counter wraps around its upper bound, we might report an invalid
negative value. To avoid that, we take the modulu of the difference.
For example, assume that the first sample was (2**64 - 10) jiffies and
30 jiffies have passed until the second sample, the difference would be
the hugely negative value (30 - 2**64). Taking modulu 2**64 returns the
correct value of 30 jiffies.
JIFFIES_BOUND is taken from the size of clock_t and NETSTATS_BOUND -
from the size of the fields of struct net_device_stats. I am not aware
of any programmatic way to acquire this value, but they are both of 64
bit size on x86_64 and ppc64.
Taking modulu 2**32 works perfectly well, since two subsequent samples
are unlikly to be that far apart, and it has the benefit of working well
on a 32 bit host, too.
Change-Id: I706000106c3bc31edf8541c980bce1f49464ebf8
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/sampling.py
M vdsm/vm.py
2 files changed, 11 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/24194/1
diff --git a/vdsm/sampling.py b/vdsm/sampling.py
index 54b6381..a5492ce 100644
--- a/vdsm/sampling.py
+++ b/vdsm/sampling.py
@@ -42,6 +42,9 @@
if not os.path.exists(_THP_STATE_PATH):
_THP_STATE_PATH = '/sys/kernel/mm/redhat_transparent_hugepage/enabled'
+JIFFIES_BOUND = 2 ** 32
+NETSTATS_BOUND = 2 ** 32
+
class InterfaceSample:
"""
@@ -430,14 +433,14 @@
return stats
hs0, hs1 = self._samples[0], self._samples[-1]
interval = hs1.timestamp - hs0.timestamp
- jiffies = (hs1.pidcpu.user - hs0.pidcpu.user) % (2 ** 32)
+ jiffies = (hs1.pidcpu.user - hs0.pidcpu.user) % JIFFIES_BOUND
stats['cpuUserVdsmd'] = (jiffies / interval)
- jiffies = hs1.pidcpu.sys - hs0.pidcpu.sys % (2 ** 32)
+ jiffies = hs1.pidcpu.sys - hs0.pidcpu.sys % JIFFIES_BOUND
stats['cpuSysVdsmd'] = (jiffies / interval)
- jiffies = (hs1.totcpu.user - hs0.totcpu.user) % (2 ** 32)
+ jiffies = (hs1.totcpu.user - hs0.totcpu.user) % JIFFIES_BOUND
stats['cpuUser'] = jiffies / interval / self._ncpus
- jiffies = (hs1.totcpu.sys - hs0.totcpu.sys) % (2 ** 32)
+ jiffies = (hs1.totcpu.sys - hs0.totcpu.sys) % JIFFIES_BOUND
stats['cpuSys'] = jiffies / interval / self._ncpus
stats['cpuIdle'] = max(0.0,
100.0 - stats['cpuUser'] - stats['cpuSys'])
@@ -479,9 +482,9 @@
ifrate = ifrate or 1000
Mbps2Bps = (10 ** 6) / 8
thisRx = (hs1.interfaces[ifid].rx - hs0.interfaces[ifid].rx) % \
- (2 ** 32)
+ NETSTATS_BOUND
thisTx = (hs1.interfaces[ifid].tx - hs0.interfaces[ifid].tx) % \
- (2 ** 32)
+ NETSTATS_BOUND
rxRate = 100.0 * thisRx / interval / ifrate / Mbps2Bps
txRate = 100.0 * thisTx / interval / ifrate / Mbps2Bps
if txRate > 100 or rxRate > 100:
diff --git a/vdsm/vm.py b/vdsm/vm.py
index aae8bd6..07fb581 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -606,11 +606,11 @@
ifRxBytes = (100.0 *
(eInfo[nic.name][0] - sInfo[nic.name][0]) %
- 2 ** 32 /
+ sampling.NETSTATS_BOUND /
sampleInterval / ifSpeed / self.MBPS_TO_BPS)
ifTxBytes = (100.0 *
(eInfo[nic.name][4] - sInfo[nic.name][4]) %
- 2 ** 32 /
+ sampling.NETSTATS_BOUND /
sampleInterval / ifSpeed / self.MBPS_TO_BPS)
ifStats['rxRate'] = '%.1f' % ifRxBytes
--
To view, visit http://gerrit.ovirt.org/24194
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I706000106c3bc31edf8541c980bce1f49464ebf8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
Federico Simoncelli has uploaded a new change for review.
Change subject: gluster: fix volume name parsing in getVmVolumeInfo
......................................................................
gluster: fix volume name parsing in getVmVolumeInfo
It is permitted to use slashes '/' in gluster mount strings even
though they're prohibited in the volume name.
In order to recognize and strip them out we should use getRealPath
instead of getRemotePath that translates slashes into permitted
underscores.
It is now allowed to mount gluster volumes with slashes (serv:/volume)
and correctly identifying the volume name and its information.
Change-Id: Icfdbc573ec2aec31b78323253f8178425a07302c
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/glusterVolume.py
1 file changed, 3 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/36237/1
diff --git a/vdsm/storage/glusterVolume.py b/vdsm/storage/glusterVolume.py
index 647b1ec..8f701ba 100644
--- a/vdsm/storage/glusterVolume.py
+++ b/vdsm/storage/glusterVolume.py
@@ -19,10 +19,9 @@
"""
Send info to represent Gluster volume as a network block device
"""
- rpath = sdCache.produce(self.sdUUID).getRemotePath()
- rpath_list = rpath.rsplit(":", 1)
- volfileServer = rpath_list[0]
- volname = rpath_list[1]
+ rpath = sdCache.produce(self.sdUUID).getRealPath()
+ volfileServer, volname = rpath.rsplit(":", 1)
+ volname = volname.strip('/')
# Volume transport to Libvirt transport mapping
VOLUME_TRANS_MAP = {'TCP': 'tcp', 'RDMA': 'rdma'}
--
To view, visit http://gerrit.ovirt.org/36237
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfdbc573ec2aec31b78323253f8178425a07302c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>