forked from kimchi-project/kimchi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fix kimchi-project#1096 - Prevent mass detach based on source PCI…
… address Before this commit, Kimchi was mass detaching PCI devices when trying to detach a single dev 'hostdev0' following this criteria: - using the source address element, see all hostdevs that share the same PCI address (domain x bus x slot) as 'hostdev0'; - if more than one is found, 'hostdev0' is considered to be a multifunction device an a mass detachment of all devices found is made. This logic is flawed when considering SR-IOV devices (CX4 cards for example). Although all virtual functions share the same source PCI address, each VF should be attached and detached individually. Following the current libvirt documentation (https://libvirt.org/formatdomain.html), there is an attribute called 'multifunction' that can be used: 'Also available is the multifunction attribute, which controls turning on the multifunction bit for a particular slot/function in the PCI control register (...) multifunction defaults to 'off', but should be set to 'on' for function 0 of a slot that will have multiple functions used.' Further experimentation showed that, in multifunction devices, the device PCI address differs only in the 'function' attribute, while in the VFs for example they are different. This means that the device address is a better place to look for paired devices instead of using the source PCI address. This patch implements these changes to fix kimchi-project#1096: use the multifunction attribute to determine if a hostdev is multifuction and changed the 'get_devices_same_addr' method to use the device address instead of the source PCI address as comparison. This patch also makes changes on the work done in bug fix kimchi-project#1073. The re-attach of the recently detached devices is not necessary when the device was set to 'managed' mode. In fact, re-attaching VFs set with managed='yes' was causing libvirt instability. This patch adds this verification and avoids the re-attach in these cases. Minor simplications of vmhostdevs.py code were also made, such as use a dict instead of an array of tuples to easily retrieve elements by a key and moved the NotFound verification up in the '_detach_device' method. Unit tests included. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
- Loading branch information
Showing
2 changed files
with
249 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters