Change in vdsm[master]: vdsm: initial split of vm devices
mpoledni at redhat.com
mpoledni at redhat.com
Thu Jun 26 11:03:14 UTC 2014
Martin Polednik has uploaded a new change for review.
Change subject: vdsm: initial split of vm devices
......................................................................
vdsm: initial split of vm devices
initial boostrapping of VmDevice and GeneralDevice from devices.py
Change-Id: I63b602851c17697259e86dfad3a9063447c57e50
Signed-off-by: Martin Polednik <mpoledni at redhat.com>
---
M debian/vdsm.install
M vdsm.spec.in
A vdsm/virt/devices.py
M vdsm/virt/vm.py
4 files changed, 53 insertions(+), 48 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/29250/1
diff --git a/debian/vdsm.install b/debian/vdsm.install
index aaa1ecc..96b0779 100644
--- a/debian/vdsm.install
+++ b/debian/vdsm.install
@@ -150,4 +150,5 @@
./usr/share/vdsm/virt/vmpowerdown.py
./usr/share/vdsm/virt/vmstatus.py
./usr/share/vdsm/virt/xmldom.py
+./usr/share/vdsm/virt/devices.py
./var/lib/polkit-1/localauthority/10-vendor.d/10-vdsm-libvirt-access.pkla
diff --git a/vdsm.spec.in b/vdsm.spec.in
index ac5e1c2..8e54be2 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -937,6 +937,7 @@
%{_datadir}/%{vdsm_name}/virt/vmpowerdown.py*
%{_datadir}/%{vdsm_name}/virt/sampling.py*
%{_datadir}/%{vdsm_name}/virt/xmldom.py*
+%{_datadir}/%{vdsm_name}/virt/devices.py*
%{_datadir}/%{vdsm_name}/tool
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/vdsm.conf
diff --git a/vdsm/virt/devices.py b/vdsm/virt/devices.py
new file mode 100644
index 0000000..d484136
--- /dev/null
+++ b/vdsm/virt/devices.py
@@ -0,0 +1,34 @@
+# local package imports
+from . import xmldom
+
+
+class VmDevice(xmldom.XMLDevice):
+ __slots__ = ('deviceType', 'device', 'alias', 'specParams', 'deviceId',
+ 'conf', 'log', '_deviceXML', 'type', 'custom')
+
+ def __init__(self, conf, log, **kwargs):
+ self.conf = conf
+ self.log = log
+ self.specParams = {}
+ self.custom = kwargs.pop('custom', {})
+ for attr, value in kwargs.iteritems():
+ try:
+ setattr(self, attr, value)
+ except AttributeError: # skip read-only properties
+ self.log.debug('Ignoring param (%s, %s) in %s', attr, value,
+ self.__class__.__name__)
+ self._deviceXML = None
+
+ def __str__(self):
+ attrs = [':'.join((a, str(getattr(self, a, None)))) for a in dir(self)
+ if not a.startswith('__')]
+ return ' '.join(attrs)
+
+
+class GeneralDevice(VmDevice):
+
+ def getXML(self):
+ """
+ Create domxml for general device
+ """
+ return self.createXmlElem(self.type, self.device, ['address'])
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index d44d96d..a0f4edf 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -63,6 +63,7 @@
from . import vmexitreason
from . import vmstatus
from . import xmldom
+from . import devices
from vmpowerdown import VmShutdown, VmReboot
@@ -612,39 +613,7 @@
return f
-class VmDevice(xmldom.XMLDevice):
- __slots__ = ('deviceType', 'device', 'alias', 'specParams', 'deviceId',
- 'conf', 'log', '_deviceXML', 'type', 'custom')
-
- def __init__(self, conf, log, **kwargs):
- self.conf = conf
- self.log = log
- self.specParams = {}
- self.custom = kwargs.pop('custom', {})
- for attr, value in kwargs.iteritems():
- try:
- setattr(self, attr, value)
- except AttributeError: # skip read-only properties
- self.log.debug('Ignoring param (%s, %s) in %s', attr, value,
- self.__class__.__name__)
- self._deviceXML = None
-
- def __str__(self):
- attrs = [':'.join((a, str(getattr(self, a, None)))) for a in dir(self)
- if not a.startswith('__')]
- return ' '.join(attrs)
-
-
-class GeneralDevice(VmDevice):
-
- def getXML(self):
- """
- Create domxml for general device
- """
- return self.createXmlElem(self.type, self.device, ['address'])
-
-
-class ControllerDevice(VmDevice):
+class ControllerDevice(devices.VmDevice):
__slots__ = ('address', 'model', 'index', 'master')
def getXML(self):
@@ -659,7 +628,7 @@
return ctrl
-class VideoDevice(VmDevice):
+class VideoDevice(devices.VmDevice):
__slots__ = ('address',)
def getXML(self):
@@ -676,7 +645,7 @@
return video
-class SoundDevice(VmDevice):
+class SoundDevice(devices.VmDevice):
__slots__ = ('address', 'alias')
def getXML(self):
@@ -688,7 +657,7 @@
return sound
-class NetworkInterfaceDevice(VmDevice):
+class NetworkInterfaceDevice(devices.VmDevice):
__slots__ = ('nicModel', 'macAddr', 'network', 'bootOrder', 'address',
'linkActive', 'portMirroring', 'filter',
'sndbufParam', 'driver', 'name')
@@ -702,7 +671,7 @@
kwargs[attr] = 'virtio'
elif attr == 'network' and value == '':
kwargs[attr] = DUMMY_BRIDGE
- VmDevice.__init__(self, conf, log, **kwargs)
+ devices.VmDevice.__init__(self, conf, log, **kwargs)
self.sndbufParam = False
self._customize()
@@ -801,7 +770,7 @@
return bandwidth
-class Drive(VmDevice):
+class Drive(devices.VmDevice):
__slots__ = ('iface', 'path', 'readonly', 'bootOrder', 'domainID',
'poolID', 'imageID', 'UUID', 'volumeID', 'format',
'propagateErrors', 'address', 'apparentsize', 'volumeInfo',
@@ -816,7 +785,7 @@
def __init__(self, conf, log, **kwargs):
if not kwargs.get('serial'):
self.serial = kwargs.get('imageID'[-20:]) or ''
- VmDevice.__init__(self, conf, log, **kwargs)
+ devices.VmDevice.__init__(self, conf, log, **kwargs)
# Keep sizes as int
self.reqsize = int(kwargs.get('reqsize', '0')) # Backward compatible
self.truesize = int(kwargs.get('truesize', '0'))
@@ -1107,7 +1076,7 @@
return diskelem
-class GraphicsDevice(VmDevice):
+class GraphicsDevice(devices.VmDevice):
__slots__ = ('device', 'port', 'tlsPort')
LIBVIRT_PORT_AUTOSELECT = '-1'
@@ -1212,7 +1181,7 @@
return graphics
-class BalloonDevice(VmDevice):
+class BalloonDevice(devices.VmDevice):
__slots__ = ('address',)
def getXML(self):
@@ -1229,7 +1198,7 @@
return m
-class WatchdogDevice(VmDevice):
+class WatchdogDevice(devices.VmDevice):
__slots__ = ('address',)
def __init__(self, *args, **kwargs):
@@ -1253,7 +1222,7 @@
return m
-class SmartCardDevice(VmDevice):
+class SmartCardDevice(devices.VmDevice):
__slots__ = ('address',)
def getXML(self):
@@ -1272,7 +1241,7 @@
return card
-class TpmDevice(VmDevice):
+class TpmDevice(devices.VmDevice):
__slots__ = ()
def getXML(self):
@@ -1294,7 +1263,7 @@
return tpm
-class RedirDevice(VmDevice):
+class RedirDevice(devices.VmDevice):
__slots__ = ('address',)
def getXML(self):
@@ -1308,7 +1277,7 @@
return self.createXmlElem('redirdev', self.device, ['bus', 'address'])
-class RngDevice(VmDevice):
+class RngDevice(devices.VmDevice):
def getXML(self):
"""
<rng model='virtio'>
@@ -1334,7 +1303,7 @@
return rng
-class ConsoleDevice(VmDevice):
+class ConsoleDevice(devices.VmDevice):
__slots__ = ()
def getXML(self):
@@ -1379,7 +1348,7 @@
(VIDEO_DEVICES, VideoDevice),
(GRAPHICS_DEVICES, GraphicsDevice),
(CONTROLLER_DEVICES, ControllerDevice),
- (GENERAL_DEVICES, GeneralDevice),
+ (GENERAL_DEVICES, devices.GeneralDevice),
(BALLOON_DEVICES, BalloonDevice),
(WATCHDOG_DEVICES, WatchdogDevice),
(CONSOLE_DEVICES, ConsoleDevice),
--
To view, visit http://gerrit.ovirt.org/29250
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63b602851c17697259e86dfad3a9063447c57e50
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoledni at redhat.com>
More information about the vdsm-patches
mailing list