Francesco Romani has uploaded a new change for review. Change subject: vm: devices: drop support for ancient Engines ......................................................................
vm: devices: drop support for ancient Engines Since version 4.0 Engine is supposed to send proper devices config, and to always use Graphics Device proper. So, we can drop support in VDSM for very old (<3.6) Engines, simplifying the VDSM code quite a bit. Change-Id: I6b9acd500670a2ace449cc50ac99bf94f58f165b Breaks-Compatibility: 3.x Signed-off-by: Francesco Romani <[email protected]> --- M vdsm/virt/vm.py 1 file changed, 12 insertions(+), 162 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/73/49173/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index f07f55e..3974bb0 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -455,31 +455,19 @@ # The new/old type parameter will be distinguished # by existence/absence of the 'devices' key - try: - # while this code is running, Vm is queryable for status(), - # thus we must fix devices in an atomic way, hence the deep copy - with self._confLock: - devConf = utils.picklecopy(self.conf['devices']) - except KeyError: - # (very) old Engines do not send device configuration - devices[hwclass.DISK] = self.getConfDrives() - devices[hwclass.NIC] = self.getConfNetworkInterfaces() - devices[hwclass.SOUND] = self.getConfSound() - devices[hwclass.VIDEO] = self.getConfVideo() - devices[hwclass.GRAPHICS] = self.getConfGraphics() - devices[hwclass.CONTROLLER] = self.getConfController() - else: - for dev in devConf: - try: - devices[dev['type']].append(dev) - except KeyError: - if 'type' not in dev or dev['type'] != 'channel': - self.log.warn("Unknown type found, device: '%s' " - "found", dev) - devices[hwclass.GENERAL].append(dev) + # while this code is running, Vm is queryable for status(), + # thus we must fix devices in an atomic way, hence the deep copy + with self._confLock: + devConf = utils.picklecopy(self.conf['devices']) - if not devices[hwclass.GRAPHICS]: - devices[hwclass.GRAPHICS] = self.getConfGraphics() + for dev in devConf: + try: + devices[dev['type']].append(dev) + except KeyError: + if 'type' not in dev or dev['type'] != 'channel': + self.log.warn("Unknown type found, device: '%s' " + "found", dev) + devices[hwclass.GENERAL].append(dev) self._checkDeviceLimits(devices) @@ -530,134 +518,6 @@ else: raise ValueError("only a single graphic device " "per type is supported") - - def getConfController(self): - """ - Normalize controller device. - """ - controllers = [] - # For now we create by default only 'virtio-serial' controller - 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' - else: - devType = None - - if devType: - # this method is called only in the ancient Engines compatibility - # path. But ancient Engines do not support headless VMs, as they - # will not stop sending display data all of sudden. - 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): - """ - Normalize graphics device provided by conf. - """ - - # this method needs to cope both with ancient Engines and with - # recent Engines unaware of graphic devices. - if 'display' not in self.conf: - return [] - - return [{ - 'type': hwclass.GRAPHICS, - 'device': ( - 'spice' - if self.conf['display'] in ('qxl', 'qxlnc') - else 'vnc'), - 'specParams': vmdevices.graphics.makeSpecParams(self.conf)}] - - def getConfSound(self): - """ - Normalize sound device provided by conf. - """ - scards = [] - if self.conf.get('soundDevice'): - scards.append({'type': hwclass.SOUND, - 'device': self.conf.get('soundDevice')}) - - return scards - - def getConfNetworkInterfaces(self): - """ - Normalize networks interfaces provided by conf. - """ - nics = [] - macs = self.conf.get('macAddr', '').split(',') - models = self.conf.get('nicModel', '').split(',') - bridges = self.conf.get('bridge', DEFAULT_BRIDGE).split(',') - if macs == ['']: - macs = [] - if models == ['']: - models = [] - if bridges == ['']: - bridges = [] - if len(models) < len(macs) or len(models) < len(bridges): - raise ValueError('Bad nic specification') - if models and not (macs or bridges): - raise ValueError('Bad nic specification') - if not macs or not models or not bridges: - return '' - macs = macs + [macs[-1]] * (len(models) - len(macs)) - bridges = bridges + [bridges[-1]] * (len(models) - len(bridges)) - - for mac, model, bridge in zip(macs, models, bridges): - if model == 'pv': - model = 'virtio' - nics.append({'type': hwclass.NIC, - 'macAddr': mac, - 'nicModel': model, 'network': bridge, - 'device': 'bridge'}) - return nics - - def getConfDrives(self): - """ - Normalize drives provided by conf. - """ - # FIXME - # Will be better to change the self.conf but this implies an API change - # Remove this when the API parameters will be consistent. - confDrives = self.conf.get('drives', []) - if not confDrives: - confDrives.extend(self.__legacyDrives()) - confDrives.extend(self.__removableDrives()) - - for drv in confDrives: - drv['type'] = hwclass.DISK - drv['format'] = drv.get('format') or 'raw' - drv['propagateErrors'] = drv.get('propagateErrors') or 'off' - drv['readonly'] = False - drv['shared'] = False - # FIXME: For BC we have now two identical keys: iface = if - # Till the day that conf will not returned as a status anymore. - drv['iface'] = drv.get('iface') or \ - drv.get( - 'if', - vmdevices.storage.DEFAULT_INTERFACE_FOR_ARCH[self.arch]) - - return confDrives def updateDriveIndex(self, drv): if not drv['iface'] in self._usedIndices: @@ -1825,11 +1685,6 @@ # So, to get proper device objects during VM recovery flow # we must to have updated conf before VM run self.saveState() - else: - # we need to fix the graphics device configuration in the - # case VDSM is upgraded from 3.4 to 3.5 on the host without - # rebooting it. Evident on, but not limited to, the HE case. - self._fixLegacyGraphicsConf() self._devices = self.devMapFromDevSpecMap(dev_spec_map) @@ -4983,11 +4838,6 @@ newChain = [x for x in device['volumeChain'] if x['volumeID'] in volumes] device['volumeChain'] = drive.volumeChain = newChain - - def _fixLegacyGraphicsConf(self): - with self._confLock: - if not vmdevices.graphics.getFirstGraphics(self.conf): - self.conf['devices'].extend(self.getConfGraphics()) def _fixLegacyRngConf(self): def _is_legacy_rng_device_conf(dev): -- To view, visit https://gerrit.ovirt.org/49173 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b9acd500670a2ace449cc50ac99bf94f58f165b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> Gerrit-Reviewer: Arik Hadas <[email protected]> Gerrit-Reviewer: Jakub Niedermertl <[email protected]> Gerrit-Reviewer: Marek Libra <[email protected]> Gerrit-Reviewer: Martin Betak <[email protected]> Gerrit-Reviewer: Martin Polednik <[email protected]> Gerrit-Reviewer: Michal Skrivanek <[email protected]> Gerrit-Reviewer: Milan Zamazal <[email protected]> Gerrit-Reviewer: Shahar Havivi <[email protected]> Gerrit-Reviewer: Shmuel Leib Melamud <[email protected]> Gerrit-Reviewer: Tomas Jelinek <[email protected]> Gerrit-Reviewer: Vinzenz Feenstra <[email protected]> Gerrit-Reviewer: gerrit-hooks <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
