def __init__(self, log, **kwargs): super(UsbDevice, self).__init__(log, **kwargs) device_params = get_device_params(self.device) self.hostAddress = device_params.get('address') self.numa_node = None self.name = self.device self.is_hostdevice = True
def __init__(self, conf, log, **kwargs): super(ScsiDevice, self).__init__(conf, log, **kwargs) device_params = get_device_params(self.device) self.hostAddress = device_params.get('address') self.name = self.device self.bus_address, self.adapter = scsi_address_to_adapter( self.hostAddress)
def __init__(self, conf, log, **kwargs): super(PciDevice, self).__init__(conf, log, **kwargs) self._deviceParams = get_device_params(self.device) self.hostAddress = self._deviceParams.get('address') self.numa_node = self._deviceParams.get('numa_node', None) self.name = self.device self.is_hostdevice = True
def __init__(self, log, **kwargs): super(PciDevice, self).__init__(log, **kwargs) self._deviceParams = get_device_params(self.device) self.hostAddress = self._deviceParams.get('address') self.numa_node = self._deviceParams.get('numa_node', None) self.name = self.device self.is_hostdevice = True
def __init__(self, conf, log, **kwargs): super(UsbDevice, self).__init__(conf, log, **kwargs) device_params = get_device_params(self.device) self.hostAddress = device_params.get('address') self.numa_node = None self.name = self.device self.is_hostdevice = True
def __init__(self, log, **kwargs): super(ScsiDevice, self).__init__(log, **kwargs) device_params = get_device_params(self.device) self.hostAddress = device_params.get('address') self.numa_node = None self.name = self.device self.bus_address, self.adapter = scsi_address_to_adapter( self.hostAddress) self.is_hostdevice = True
def __new__(cls, log, **kwargs): try: device_params = get_device_params(kwargs['device']) except libvirt.libvirtError: # TODO: MdevDevice is somewhat generic "UnknownDevice" really, but # at this point we don't expect any other device to fail. # In future, we should be more careful whether device is mdev or # some really unknown device. return MdevDevice(log, **kwargs) device = cls._DEVICE_MAPPING[device_params['capability']](log, **kwargs) return device
def __new__(cls, log, **kwargs): try: device_params = get_device_params(kwargs['device']) except libvirt.libvirtError: # TODO: MdevDevice is somewhat generic "UnknownDevice" really, but # at this point we don't expect any other device to fail. # In future, we should be more careful whether device is mdev or # some really unknown device. return MdevDevice(log, **kwargs) device = cls._DEVICE_MAPPING[ device_params['capability']](log, **kwargs) return device
def from_xml_tree(cls, log, dev, meta): params = { 'device': dev.tag, 'type': core.find_device_type(dev), } core.update_device_params(params, dev) _update_hostdev_params(params, dev) dev_type = params.get('type') dev_name = _get_device_name(dev, dev_type) params['device'] = dev_name device_params = get_device_params(dev_name) device_class = cls._DEVICE_MAPPING[device_params['capability']] return device_class(log, **params)
def teardown(self): if self.is_hostdevice: self.log.info('Reattaching device %s to host.' % self.hostdev) try: # TODO: avoid reattach when Engine can tell free VFs otherwise reattach_detachable(self.hostdev) except NoIOMMUSupportException: self.log.exception( 'Could not reattach device %s back to host ' 'due to missing IOMMU support.', self.hostdev) device_params = get_device_params(self.hostdev) supervdsm.getProxy().rmAppropriateIommuGroup( device_params['iommu_group'])
def teardown(self): if self.is_hostdevice: self.log.info('Reattaching device %s to host.' % self.hostdev) try: # TODO: avoid reattach when Engine can tell free VFs otherwise reattach_detachable(self.hostdev) except NoIOMMUSupportException: self.log.exception('Could not reattach device %s back to host ' 'due to missing IOMMU support.', self.hostdev) device_params = get_device_params(self.hostdev) supervdsm.getProxy().rmAppropriateIommuGroup( device_params['iommu_group'])
def __init__(self, log, **kwargs): # pyLint can't tell that the Device.__init__() will # set a nicModel attribute, so modify the kwarg list # prior to device init. for attr, value in kwargs.items(): if attr == 'nicModel' and value == 'pv': kwargs[attr] = 'virtio' elif attr == 'network' and value == '': kwargs[attr] = net_api.DUMMY_BRIDGE super(Interface, self).__init__(log, **kwargs) if not hasattr(self, 'filterParameters'): self.filterParameters = [] if not hasattr(self, 'vm_custom'): self.vm_custom = {} self.sndbufParam = False self.is_hostdevice = self.device == hwclass.HOSTDEV self.vlanId = self.specParams.get('vlanid') self._customize() if self.is_hostdevice: self._device_params = get_device_params(self.hostdev) self.numa_node = self._device_params.get('numa_node', None) self._is_vhostuser = False
def getXML(self): """ Create domxml for network interface. <interface type="bridge"> <mac address="aa:bb:dd:dd:aa:bb"/> <model type="virtio"/> <source bridge="engine"/> [<driver name="vhost/qemu" queues="int"/>] [<filterref filter='filter name'> [<parameter name='parameter name' value='parameter value'>] </filterref>] [<tune><sndbuf>0</sndbuf></tune>] [<link state='up|down'/>] [<bandwidth> [<inbound average="int" [burst="int"] [peak="int"]/>] [<outbound average="int" [burst="int"] [peak="int"]/>] </bandwidth>] </interface> -- or -- a slightly different SR-IOV network interface <interface type='hostdev' managed='no'> <driver name='vfio'/> <source> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </source> <mac address='52:54:00:6d:90:02'/> <vlan> <tag id=100/> </vlan> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> <boot order='1'/> </interface> """ iface = self.createXmlElem('interface', self.device, ['address']) iface.appendChildWithArgs('mac', address=self.macAddr) if hasattr(self, 'nicModel'): iface.appendChildWithArgs('model', type=self.nicModel) if self.is_hostdevice: # SR-IOV network interface iface.setAttrs(managed='no') host_address = get_device_params(self.hostdev)['address'] source = iface.appendChildWithArgs('source') source.appendChildWithArgs('address', type='pci', **host_address) if self.vlanId is not None: vlan = iface.appendChildWithArgs('vlan') vlan.appendChildWithArgs('tag', id=str(self.vlanId)) else: ovs_bridge = supervdsm.getProxy().ovs_bridge(self.network) if ovs_bridge: self._source_ovs_bridge(iface, ovs_bridge) else: iface.appendChildWithArgs('source', bridge=self.network) if hasattr(self, 'filter'): filter = iface.appendChildWithArgs('filterref', filter=self.filter) self._set_parameters_filter(filter) if hasattr(self, 'linkActive'): iface.appendChildWithArgs('link', state='up' if utils.tobool(self.linkActive) else 'down') if hasattr(self, 'bootOrder'): iface.appendChildWithArgs('boot', order=self.bootOrder) if self.driver: iface.appendChildWithArgs('driver', **self.driver) elif self.is_hostdevice: iface.appendChildWithArgs('driver', name='vfio') if self.sndbufParam: tune = iface.appendChildWithArgs('tune') tune.appendChildWithArgs('sndbuf', text=self.sndbufParam) if 'inbound' in self.specParams or 'outbound' in self.specParams: iface.appendChild(self.paramsToBandwidthXML(self.specParams)) return iface
def __init__(self, conf, log, **kwargs): super(HostDevice, self).__init__(conf, log, **kwargs) self._deviceParams = get_device_params(self.device) self.hostAddress = self._deviceParams.get('address') self.name = self.device
def getXML(self): """ Create domxml for network interface. <interface type="bridge"> <mac address="aa:bb:dd:dd:aa:bb"/> <model type="virtio"/> <source bridge="engine"/> [<driver name="vhost/qemu" queues="int"/>] [<filterref filter='filter name'> [<parameter name='parameter name' value='parameter value'>] </filterref>] [<tune><sndbuf>0</sndbuf></tune>] [<link state='up|down'/>] [<bandwidth> [<inbound average="int" [burst="int"] [peak="int"]/>] [<outbound average="int" [burst="int"] [peak="int"]/>] </bandwidth>] </interface> -- or -- a slightly different SR-IOV network interface <interface type='hostdev' managed='no'> <driver name='vfio'/> <source> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </source> <mac address='52:54:00:6d:90:02'/> <vlan> <tag id=100/> </vlan> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> <boot order='1'/> </interface> """ iface = self.createXmlElem('interface', self.device, ['address']) iface.appendChildWithArgs('mac', address=self.macAddr) if hasattr(self, 'nicModel'): iface.appendChildWithArgs('model', type=self.nicModel) if self.is_hostdevice: # SR-IOV network interface iface.setAttrs(managed='no') host_address = get_device_params(self.hostdev)['address'] source = iface.appendChildWithArgs('source') source.appendChildWithArgs('address', type='pci', **host_address) if self.vlanId is not None: vlan = iface.appendChildWithArgs('vlan') vlan.appendChildWithArgs('tag', id=str(self.vlanId)) else: ovs_bridge = supervdsm.getProxy().ovs_bridge(self.network) if ovs_bridge: self._source_ovs_bridge(iface, ovs_bridge) else: iface.appendChildWithArgs('source', bridge=self.network) if hasattr(self, 'filter'): filter = iface.appendChildWithArgs('filterref', filter=self.filter) self._set_parameters_filter(filter) if hasattr(self, 'linkActive'): iface.appendChildWithArgs( 'link', state='up' if utils.tobool(self.linkActive) else 'down') if hasattr(self, 'bootOrder'): iface.appendChildWithArgs('boot', order=self.bootOrder) if self.driver: iface.appendChildWithArgs('driver', **self.driver) elif self.is_hostdevice: iface.appendChildWithArgs('driver', name='vfio') if self.sndbufParam: tune = iface.appendChildWithArgs('tune') tune.appendChildWithArgs('sndbuf', text=self.sndbufParam) if 'inbound' in self.specParams or 'outbound' in self.specParams: iface.appendChild(self.paramsToBandwidthXML(self.specParams)) return iface
def __new__(cls, conf, log, **kwargs): device_params = get_device_params(kwargs['device']) device = cls._DEVICE_MAPPING[ device_params['capability']](conf, log, **kwargs) return device
def __new__(cls, conf, log, **kwargs): device_params = get_device_params(kwargs['device']) device = cls._DEVICE_MAPPING[device_params['capability']](conf, log, **kwargs) return device