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 <[email protected]> --- 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 <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
