Change in vdsm[master]: vmdevices: bootstrap sound module and isolate it's functiona...
mpolednik at redhat.com
mpolednik at redhat.com
Wed Apr 22 12:37:28 UTC 2015
Martin Polednik has uploaded a new change for review.
Change subject: vmdevices: bootstrap sound module and isolate it's functionality
......................................................................
vmdevices: bootstrap sound module and isolate it's functionality
In a continuous effort to reduce size and broadness of vm.py, this
patch takes device-specific parsing method and encapsulates it in
the device module. Additional helper methods are converted to module
functions.
Change-Id: Ie51a24965015b1eff63e5cfedd63fb4cda968a89
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M debian/vdsm.install
M tests/deviceTests.py
M vdsm.spec.in
M vdsm/virt/migration.py
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/Makefile.am
M vdsm/virt/vmdevices/__init__.py
M vdsm/virt/vmdevices/core.py
8 files changed, 18 insertions(+), 56 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/40138/1
diff --git a/debian/vdsm.install b/debian/vdsm.install
index d18a328..1fc8db1 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -169,4 +169,5 @@
./usr/share/vdsm/virt/vmdevices/network.py
./usr/share/vdsm/virt/vmdevices/sound.py
./usr/share/vdsm/virt/vmdevices/storage.py
+./usr/share/vdsm/virt/vmdevices/video.py
./var/lib/polkit-1/localauthority/10-vendor.d/10-vdsm-libvirt-access.pkla
diff --git a/tests/deviceTests.py b/tests/deviceTests.py
index dd70aaa..f31421b 100644
--- a/tests/deviceTests.py
+++ b/tests/deviceTests.py
@@ -161,21 +161,21 @@
for conf in self.confDisplaySpice:
conf.update(self.conf)
with fake.VM(conf) as testvm:
- self.assertTrue(testvm.hasSpice)
+ self.assertTrue(vmdevices.video.conf_has_spice(testvm.conf))
for conf in self.confDisplayVnc:
conf.update(self.conf)
with fake.VM(conf) as testvm:
- self.assertFalse(testvm.hasSpice)
+ self.assertFalse(vmdevices.video.conf_has_spice(testvm.conf))
def testHasSpice(self):
for dev in self.confDeviceGraphicsSpice:
with fake.VM(self.conf, dev) as testvm:
- self.assertTrue(testvm.hasSpice)
+ self.assertTrue(vmdevices.video.conf_has_spice(testvm.conf))
for dev in self.confDeviceGraphicsVnc:
with fake.VM(self.conf, dev) as testvm:
- self.assertFalse(testvm.hasSpice)
+ self.assertFalse(vmdevices.video.conf_has_spice(testvm.conf))
@permutations([['vnc', 'spice'], ['spice', 'vnc']])
def testGraphicsDeviceMultiple(self, primary, secondary):
@@ -263,7 +263,7 @@
dev = {'device': 'vga', 'specParams': {'vram': '32768',
'heads': '2'}}
- video = vmdevices.core.Video(self.conf, self.log, **dev)
+ video = vmdevices.video.Video(self.conf, self.log, **dev)
self.assertXMLEqual(video.getXML().toxml(), videoXML)
def testInterfaceXML(self):
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 8a899fb..4e72cfe 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1111,6 +1111,7 @@
%{_datadir}/%{vdsm_name}/virt/vmdevices/network.py*
%{_datadir}/%{vdsm_name}/virt/vmdevices/sound.py*
%{_datadir}/%{vdsm_name}/virt/vmdevices/storage.py*
+%{_datadir}/%{vdsm_name}/virt/vmdevices/video.py*
%{_datadir}/%{vdsm_name}/tool
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/vdsm.conf
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index f76fac2..76753e8 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -31,6 +31,7 @@
from vdsm.config import config
from vdsm.define import NORMAL, errCode, Mbytes
+from . import vmdevices
from . import vmexitreason
from . import vmstatus
@@ -340,7 +341,8 @@
(time.time() - startTime) + destCreationTime)
def _perform_migration(self, duri, muri):
- if self._vm.hasSpice and self._vm.conf.get('clientIp'):
+ if vmdevices.video.conf_has_spice(self._vm.conf) \
+ and self._vm.conf.get('clientIp'):
SPICE_MIGRATION_HANDOVER_TIME = 120
self._vm._reviveTicket(SPICE_MIGRATION_HANDOVER_TIME)
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 831a29a..e862fdf 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -643,7 +643,7 @@
DeviceMapping = ((hwclass.DISK, vmdevices.storage.Drive),
(hwclass.NIC, vmdevices.network.Interface),
(hwclass.SOUND, vmdevices.sound.Sound),
- (hwclass.VIDEO, vmdevices.core.Video),
+ (hwclass.VIDEO, vmdevices.video.Video),
(hwclass.GRAPHICS, vmdevices.graphics.Graphics),
(hwclass.CONTROLLER, vmdevices.core.Controller),
(hwclass.GENERAL, vmdevices.core.Generic),
@@ -823,7 +823,9 @@
devices[hwclass.NIC] = self.getConfNetworkInterfaces()
devices[hwclass.SOUND] = \
vmdevices.sound.mapping_from_legacy_conf(self.conf)
- devices[hwclass.VIDEO] = self.getConfVideo()
+ devices[hwclass.VIDEO] = \
+ vmdevices.video.mapping_from_legacy_conf(self.conf,
+ self.arch)
devices[hwclass.GRAPHICS] = self.getConfGraphics()
devices[hwclass.CONTROLLER] = self.getConfController()
else:
@@ -897,30 +899,6 @@
controllers.append({'type': hwclass.CONTROLLER,
'device': 'virtio-serial'})
return controllers
-
- def getConfVideo(self):
- """
- Normalize video device provided by conf.
- """
-
- DEFAULT_VIDEOS = {caps.Architecture.X86_64: 'cirrus',
- caps.Architecture.PPC64: 'vga',
- caps.Architecture.PPC64LE: 'vga'}
-
- vcards = []
- if self.conf.get('display') == 'vnc':
- devType = DEFAULT_VIDEOS[self.arch]
- elif self.hasSpice:
- devType = 'qxl'
-
- monitors = int(self.conf.get('spiceMonitors', '1'))
- vram = '65536' if (monitors <= 2) else '32768'
- for idx in range(monitors):
- vcards.append({'type': hwclass.VIDEO,
- 'specParams': {'vram': vram},
- 'device': devType})
-
- return vcards
def getConfGraphics(self):
"""
@@ -3682,7 +3660,7 @@
def _reviveTicket(self, newlife):
"""
Revive an existing ticket, if it has expired or about to expire.
- Needs to be called only if Vm.hasSpice == True
+ Needs to be called only if vmdevices.video.conf_has_spice == True
"""
graphics = self._findGraphicsDeviceXMLByType('spice') # cannot fail
validto = max(time.strptime(graphics.getAttribute('passwdValidTo'),
@@ -3728,13 +3706,6 @@
# we do not support and do not expect other values
self.log.warning('unexpected action %i on device %s error %s',
action, blockDevAlias, err)
-
- @property
- def hasSpice(self):
- return (self.conf.get('display') == 'qxl' or
- any(dev['device'] == 'spice'
- for dev in self.conf.get('devices', [])
- if dev['type'] == hwclass.GRAPHICS))
@property
def name(self):
diff --git a/vdsm/virt/vmdevices/Makefile.am b/vdsm/virt/vmdevices/Makefile.am
index 576394a..3bebe65 100644
--- a/vdsm/virt/vmdevices/Makefile.am
+++ b/vdsm/virt/vmdevices/Makefile.am
@@ -28,4 +28,5 @@
network.py \
sound.py \
storage.py \
+ video.py \
$(NULL)
diff --git a/vdsm/virt/vmdevices/__init__.py b/vdsm/virt/vmdevices/__init__.py
index 72f2bd9..778ad2c 100644
--- a/vdsm/virt/vmdevices/__init__.py
+++ b/vdsm/virt/vmdevices/__init__.py
@@ -25,6 +25,7 @@
from . import network
from . import sound
from . import storage
+from . import video
# Silence pyflakes
-core, graphics, hostdevice, hwclass, network, sound, storage
+core, graphics, hostdevice, hwclass, network, sound, storage, video
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index 90d66b3..264fe1d 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -183,21 +183,6 @@
return tpm
-class Video(Base):
- def getXML(self):
- """
- Create domxml for video device
- """
- video = self.createXmlElem('video', None, ['address'])
- sourceAttrs = {'vram': self.specParams.get('vram', '32768'),
- 'heads': self.specParams.get('heads', '1')}
- if 'ram' in self.specParams:
- sourceAttrs['ram'] = self.specParams['ram']
-
- video.appendChildWithArgs('model', type=self.device, **sourceAttrs)
- return video
-
-
class Watchdog(Base):
__slots__ = ('address',)
--
To view, visit https://gerrit.ovirt.org/40138
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie51a24965015b1eff63e5cfedd63fb4cda968a89
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
More information about the vdsm-patches
mailing list