Change in vdsm[master]: virt: dev: bootstrap from_xml method
by fromani@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>
8 years, 12 months
Change in vdsm[master]: tests: basic scaffolding tests gor getUnderlying*
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: tests: basic scaffolding tests gor getUnderlying*
......................................................................
tests: basic scaffolding tests gor getUnderlying*
We want to refactor and cleanup Vm.getUnderlying*
and move this code where really belongs, vmdevices classes.
We have good intentions and a plan which is mostly code moving and
includes adding more unit tests and good coverage, but we are
also dealing with a big chunk of code which is very poorly covered
by tests.
To bootstrap the process and to have a decent hope which nothing
obvious breaks, add unit test to exercise the basic flow.
This test *is* fragile and the code *has* many flows and quirks,
so this must be intended as temporary scaffolding to provide
only very minimal safety.
Change-Id: I7609d346d7cef41286674e4b1443856ab088bc4c
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M Makefile.am
M tests/Makefile.am
M tests/deviceTests.py
3 files changed, 55 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/38976/1
diff --git a/Makefile.am b/Makefile.am
index 34885a1..0520da5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -75,6 +75,7 @@
config.py \
constants.py \
crossImportsTests.py \
+ deviceTestsData.py \
vdsm.py \
$(NULL)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 39bad01..29910a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -32,6 +32,7 @@
configNetworkTests.py \
cpuProfileTests.py \
deviceTests.py \
+ deviceTestsData.py \
domainDescriptorTests.py \
executorTests.py \
fileSDTests.py \
diff --git a/tests/deviceTests.py b/tests/deviceTests.py
index 2e69b40..c05ef14 100644
--- a/tests/deviceTests.py
+++ b/tests/deviceTests.py
@@ -20,12 +20,15 @@
from vdsm import libvirtconnection
from virt import vmdevices
-from virt.vmdevices import hwclass
+from virt.vmdevices import hwclass, hwtree
from virt.domain_descriptor import DomainDescriptor
from monkeypatch import MonkeyPatchScope
from testlib import permutations, expandPermutations
+from testlib import VdsmTestCase as TestCaseBase
from testlib import XMLTestCase
import vmfakelib as fake
+
+import deviceTestsData as testdata
@expandPermutations
@@ -460,3 +463,52 @@
if graph.device == 'spice':
self.assertXMLEqual(graph.getSpiceVmcChannelsXML().toxml(),
spiceChannelXML)
+
+
+class VmDeviceUpdateTests(TestCaseBase):
+
+ def test_get_underlying_update_config_alias_address(self):
+ with fake.VM(testdata.VM_CONF_BASE) as testvm:
+ testvm._dom = fake.Domain(xml=testdata.DOMAIN_XML_LIVE)
+
+ self._setupDevices(testvm)
+
+ self._assertDeviceConfUpdated(testvm.conf['devices'],
+ testdata.VM_CONF_LIVE['devices'])
+
+ def _setupDevices(self, testvm):
+ devices = testvm.buildConfDevices()
+ testvm._updateDevices(devices)
+ testvm._devices = hwtree.build(devices, testvm.conf, testvm.log)
+
+ testvm._updateDomainDescriptor()
+ testvm._getUnderlyingVmDevicesInfo()
+
+ def _assertDeviceConfUpdated(self, built_devices, expected_devices):
+ for built_dev in built_devices:
+ # drives require more care, not yet in scope
+ if built_dev['type'] == hwclass.DISK:
+ continue
+
+ found = False
+ if 'alias' in built_dev:
+ for expected_dev in expected_devices:
+ # we deal with list of dicts, we must
+ # match by alias. We implicitely validate
+ # the alias being correct, this way.
+ if 'alias' in expected_dev and (
+ expected_dev['alias'] == built_dev['alias']):
+ if ('address' in built_dev and
+ 'address' in expected_dev):
+ self.assertEqual(built_dev['address'],
+ expected_dev['address'])
+ else:
+ # cope with video device oddity.
+ # TODO: is this correct?
+ self.assertEqual(built_dev, expected_dev)
+ found = True
+
+ # graphics device needs special care, and we can deal with that.
+ if not found and built_dev['type'] != hwclass.GRAPHICS:
+ raise AssertionError(
+ 'device %s built but not expected' % str(built_dev))
--
To view, visit https://gerrit.ovirt.org/38976
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7609d346d7cef41286674e4b1443856ab088bc4c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
8 years, 12 months
Change in vdsm[master]: hook: diskunmap: To include UNMAP support for disk and lun d...
by apahim@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>
9 years
Change in vdsm[master]: virt: drop domain_event_to_string function
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: drop domain_event_to_string function
......................................................................
virt: drop domain_event_to_string function
The domain_event_to_string function doesn't do validation,
so drop it and just use direct dictionary access.
In the (only) calling site, we use get() to be more
robust and forward compatible.
Change-Id: I767f3e49e7b34d72aada23228d5e8689ea8991af
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/libvirt_helpers.py
M vdsm/virt/vm.py
2 files changed, 13 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/40432/1
diff --git a/vdsm/virt/libvirt_helpers.py b/vdsm/virt/libvirt_helpers.py
index d89a62f..89a84c7 100644
--- a/vdsm/virt/libvirt_helpers.py
+++ b/vdsm/virt/libvirt_helpers.py
@@ -31,20 +31,17 @@
# These strings are representing libvirt virDomainEventType values
# http://libvirt.org/html/libvirt-libvirt.html#virDomainEventType
-_DOMAIN_EVENT_STRINGS = (
- "Defined",
- "Undefined",
- "Started",
- "Suspended",
- "Resumed",
- "Stopped",
- "Shutdown",
- "PM-Suspended"
-)
-
-
-def domain_event_to_string(event):
- return _DOMAIN_EVENT_STRINGS[event]
+DOMAIN_EVENT_TO_STRING = {
+ libvirt.VIR_DOMAIN_EVENT_DEFINED: "Defined",
+ libvirt.VIR_DOMAIN_EVENT_UNDEFINED: "Undefined",
+ libvirt.VIR_DOMAIN_EVENT_STARTED: "Started",
+ libvirt.VIR_DOMAIN_EVENT_SUSPENDED: "Suspended",
+ libvirt.VIR_DOMAIN_EVENT_RESUMED: "Resumed",
+ libvirt.VIR_DOMAIN_EVENT_STOPPED: "Stopped",
+ libvirt.VIR_DOMAIN_EVENT_SHUTDOWN: "Shutdown",
+ libvirt.VIR_DOMAIN_EVENT_PMSUSPENDED: "PM-Suspended",
+ libvirt.VIR_DOMAIN_EVENT_CRASHED: "Crashed",
+}
class TimeoutError(libvirt.libvirtError):
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index b2b400d..7685ba8 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4063,7 +4063,8 @@
def _onLibvirtLifecycleEvent(self, event, detail, opaque):
self.log.debug('event %s detail %s opaque %s',
- libvirt_helpers.domain_event_to_string(event),
+ libvirt_helpers.DOMAIN_EVENT_TO_STRING.get(
+ event, "Unknown"),
detail, opaque)
if event == libvirt.VIR_DOMAIN_EVENT_STOPPED:
if (detail == libvirt.VIR_DOMAIN_EVENT_STOPPED_MIGRATED and
--
To view, visit https://gerrit.ovirt.org/40432
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I767f3e49e7b34d72aada23228d5e8689ea8991af
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years
Change in vdsm[master]: virt: move TimeoutError into utils
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: virt: move TimeoutError into utils
......................................................................
virt: move TimeoutError into utils
the TimeoutError exception is used across the virt package.
Let's move into a new errors module, to clean up things
and avoid nasty hidden imports (as we did in sampling.py).
This patch only moves code around.
Change-Id: I35ceeb12bc96bea12281ce9c9a1481342dd3afa9
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M debian/vdsm.install
M vdsm.spec.in
M vdsm/virt/Makefile.am
A vdsm/virt/errors.py
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
6 files changed, 35 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/39332/1
diff --git a/debian/vdsm.install b/debian/vdsm.install
index 919398b..2127627 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -149,6 +149,7 @@
./usr/share/vdsm/vdsmapi-schema.json
./usr/share/vdsm/virt/__init__.py
./usr/share/vdsm/virt/domain_descriptor.py
+./usr/share/vdsm/virt/errors.py
./usr/share/vdsm/virt/guestagent.py
./usr/share/vdsm/virt/migration.py
./usr/share/vdsm/virt/periodic.py
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 4d6a276..c66ec8b 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1070,6 +1070,7 @@
%{_datadir}/%{vdsm_name}/vdsm-store-net-config
%{_datadir}/%{vdsm_name}/virt/__init__.py*
%{_datadir}/%{vdsm_name}/virt/domain_descriptor.py*
+%{_datadir}/%{vdsm_name}/virt/errors.py*
%{_datadir}/%{vdsm_name}/virt/guestagent.py*
%{_datadir}/%{vdsm_name}/virt/migration.py*
%{_datadir}/%{vdsm_name}/virt/periodic.py*
diff --git a/vdsm/virt/Makefile.am b/vdsm/virt/Makefile.am
index 376f973..8f4dbdd 100644
--- a/vdsm/virt/Makefile.am
+++ b/vdsm/virt/Makefile.am
@@ -26,6 +26,7 @@
dist_vdsm_virt_PYTHON = \
__init__.py \
domain_descriptor.py \
+ errors.py \
guestagent.py \
migration.py \
periodic.py \
diff --git a/vdsm/virt/errors.py b/vdsm/virt/errors.py
new file mode 100644
index 0000000..f1cb604
--- /dev/null
+++ b/vdsm/virt/errors.py
@@ -0,0 +1,29 @@
+#
+# Copyright 2015 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
+#
+
+"""
+error and exceptions for the virt package
+"""
+
+import libvirt
+
+
+class TimeoutError(libvirt.libvirtError):
+ pass
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 94f4387..c8a42ef 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -36,6 +36,7 @@
from vdsm import utils
from vdsm.config import config
+from .errors import TimeoutError
from .utils import ExpiringCache
import caps
@@ -518,7 +519,6 @@
return hs
def run(self):
- import vm
try:
# wait a bit before starting to sample
time.sleep(self._sampleInterval)
@@ -535,7 +535,7 @@
if len(self._samples) > self.AVERAGING_WINDOW:
self._samples.pop(0)
- except vm.TimeoutError:
+ except TimeoutError:
self._log.exception("Timeout while sampling stats")
self._stopEvent.wait(self._sampleInterval)
except:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index ef6652c..460d45a 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -71,6 +71,7 @@
from .vmtune import io_tune_values_to_dom, io_tune_dom_to_values
from . import vmxml
+from .errors import TimeoutError
from .utils import isVdsmImage
from vmpowerdown import VmShutdown, VmReboot
@@ -170,10 +171,6 @@
VolumeChainEntry = namedtuple('VolumeChainEntry',
['uuid', 'path', 'allocation'])
-
-
-class TimeoutError(libvirt.libvirtError):
- pass
class NotifyingVirDomain:
--
To view, visit https://gerrit.ovirt.org/39332
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ceeb12bc96bea12281ce9c9a1481342dd3afa9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years
Change in vdsm[ovirt-3.3]: vm: Continue to sample after errors
by Nir Soffer
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>
9 years
Change in vdsm[ovirt-3.3]: vm: Fix attribute error when accessing drive in sampling method
by Nir Soffer
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>
9 years
Change in vdsm[master]: vm: Gather disk replication private methods
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: vm: Gather disk replication private methods
......................................................................
vm: Gather disk replication private methods
Move disk replication private methods together, bellow the public
methods without any code change.
Change-Id: I075636735ad9f2a53c2ed81ea20925a7bfda376d
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 30 insertions(+), 30 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/40221/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 2896c30..caefa62 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2996,36 +2996,6 @@
(snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
== libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
- def _setDiskReplica(self, drive, replica):
- """
- This utility method is used to set the disk replication information
- both in the live object used by vdsm and the vm configuration
- dictionary that is stored on disk (so that the information is not
- lost across restarts).
- """
- if drive.isDiskReplicationInProgress():
- raise RuntimeError("Disk '%s' already has an ongoing "
- "replication" % drive.name)
-
- disk = self._findConfDisk(drive.name)
- with self._confLock:
- disk['diskReplicate'] = replica
- self.saveState()
-
- drive.diskReplicate = replica
-
- def _delDiskReplica(self, drive):
- """
- This utility method is the inverse of _setDiskReplica, look at the
- _setDiskReplica description for more information.
- """
- del drive.diskReplicate
-
- disk = self._findConfDisk(drive.name)
- with self._confLock:
- del disk['diskReplicate']
- self.saveState()
-
def diskReplicateStart(self, srcDisk, dstDisk):
try:
drive = self._findDriveByUUIDs(srcDisk)
@@ -3194,6 +3164,36 @@
self._dom.blockRebase(drive.name, base, flags=flags)
+ def _setDiskReplica(self, drive, replica):
+ """
+ This utility method is used to set the disk replication information
+ both in the live object used by vdsm and the vm configuration
+ dictionary that is stored on disk (so that the information is not
+ lost across restarts).
+ """
+ if drive.isDiskReplicationInProgress():
+ raise RuntimeError("Disk '%s' already has an ongoing "
+ "replication" % drive.name)
+
+ disk = self._findConfDisk(drive.name)
+ with self._confLock:
+ disk['diskReplicate'] = replica
+ self.saveState()
+
+ drive.diskReplicate = replica
+
+ def _delDiskReplica(self, drive):
+ """
+ This utility method is the inverse of _setDiskReplica, look at the
+ _setDiskReplica description for more information.
+ """
+ del drive.diskReplicate
+
+ disk = self._findConfDisk(drive.name)
+ with self._confLock:
+ del disk['diskReplicate']
+ self.saveState()
+
def _diskSizeExtendCow(self, drive, newSizeBytes):
# Apparently this is what libvirt would do anyway, except that
# it would fail on NFS when root_squash is enabled, see BZ#963881
--
To view, visit https://gerrit.ovirt.org/40221
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I075636735ad9f2a53c2ed81ea20925a7bfda376d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years
Change in vdsm[master]: vm: Delete Drive.diskReplicate before saving config
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: vm: Delete Drive.diskReplicate before saving config
......................................................................
vm: Delete Drive.diskReplicate before saving config
When drive replication is finished, either by pivoting to the
destination volume or keeping the source volume, Drive.diskReplicate
must be deleted, to ensure that high watermark monitoring is correct.
The current code could fail to delete diskReplicate if the disk was not
found in Vm.conf, or saving state failed. This could lead to incorrect
extend requests for non-existent volume.
Change-Id: I3112f94a4877e28057497749938aa8c3d7771d30
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/40220/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5b82bdf..2896c30 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3019,12 +3019,12 @@
This utility method is the inverse of _setDiskReplica, look at the
_setDiskReplica description for more information.
"""
+ del drive.diskReplicate
+
disk = self._findConfDisk(drive.name)
with self._confLock:
del disk['diskReplicate']
self.saveState()
-
- del drive.diskReplicate
def diskReplicateStart(self, srcDisk, dstDisk):
try:
--
To view, visit https://gerrit.ovirt.org/40220
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3112f94a4877e28057497749938aa8c3d7771d30
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years
Change in vdsm[master]: Moving conf init things together
by Vinzenz Feenstra
Vinzenz Feenstra has uploaded a new change for review.
Change subject: Moving conf init things together
......................................................................
Moving conf init things together
Change-Id: I41ac420cd0da5a3118ce5b3c4c3643b292ec2e86
Signed-off-by: Vinzenz Feenstra <vfeenstr(a)redhat.com>
---
M vdsm/rpc/Bridge.py
M vdsm/virt/vm.py
2 files changed, 2 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/29320/1
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index 539c70c..12ed98e 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -286,6 +286,7 @@
"""
return [v['vmId'] for v in ret['vmList']]
+
def Host_queryVms_Ret(ret):
"""
The result contains two data structures which must be merged
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 2c5c910..098a3d5 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1814,8 +1814,7 @@
"""
self._dom = None
self.recovering = recover
- self.conf = {'pid': '0'}
- self.conf['_blockJobs'] = {}
+ self.conf = {'pid': '0', '_blockJobs': {}, 'clientIp': ''}
self.conf.update(params)
self._initLegacyConf() # restore placeholders for BC sake
self.cif = cif
@@ -1825,7 +1824,6 @@
str(self.conf['vmId']) + '.recovery'
self.user_destroy = False
self._monitorResponse = 0
- self.conf['clientIp'] = ''
self.memCommitted = 0
self._confLock = threading.Lock()
self._jobsLock = threading.Lock()
--
To view, visit http://gerrit.ovirt.org/29320
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41ac420cd0da5a3118ce5b3c4c3643b292ec2e86
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <vfeenstr(a)redhat.com>
9 years