-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCI devices are assigned in random order => random issues with Wi-Fi connection #6587
Comments
R4.1 might not have this bug then, because Python 3.7+ (de facto CPython 3.6+) dicts do preserve insertion order. (Still worth fixing for R4.0, of course.) |
Good point. I am not sure if the deterministic order is enough. Maybe it is, maybe it isn't.
Nevertheless, it seems to be worth trying. I've adjusted devices.py in my Qubes 4.0 installation – just changed |
@v6ak I've already experimented this issue a while ago and also other people I know (possibly R4.1 too, I don't remember for sure). There is indeed some ordering to fix for PCI devices. Never had the time to do it so thank you. |
Well, it isn't enough. It seems to be also shuffled elsewhere. From what I've seen, I guess it is shuffled rather before it goes to PersistentCollection than after it goes there. So, I've created a simple script that enumerates the devices and see if it changes. If it does, I'll probably adjust |
Now, the order of the devices in sys-net is swapped (compared to the previous boot). The order of devices written by the script is still the same. However, my the script seems to be inconclusive, because qubes.devices.DeviceCollection.assignments uses set, which shuffles the result. Another finding: This would also explain why this may happen on 4.1 (as @fepitre seems to remember). While Python 3.7 (or CPython 3.6) made all dicts ordered (and lowered the difference between dict and OrderedDict), this does not apply to sets. How to fix it? a. Sort all items in |
@v6ak The second approach (using list instead of set) is the one I recommend. |
PR draft: QubesOS/qubes-core-admin#407 Maybe I should look for the other occurrences of |
Can confirm that this also happens on Qubes 4.1 |
This issue is being closed because:
If anyone believes that this issue should be reopened and reassigned to an active milestone, please leave a brief comment. |
See QubesOS/qubes-issues#6587. Attempt to fix the rest of PCI device reordering
Qubes OS version
R4.0
Affected component(s) or functionality
Assigning PCI devices to qubes.
Brief summary
PCI devices are assigned in random order. This causes the interface names to vary across reboots (e.g., wls6 vs. wls7). Network Manager uses this identifier to identify the network card, so “randomly“ (=depending on the interface name) ignores saved Wi-Fi networks.
How Reproducible
Randomly – something like 50 % chance of different order with two PCI devices.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The order of those devices is always the same.
Actual behavior
The order varies randomly.
Additional context
IIUC, qubes.devices.PersistentCollection stores the identifiers of PCI devices in a Dict. Dictionaries in Python don't guarrant the order of keys (try running
python3 -c 'print({"1":None, "2":None})'
several times…), IIUC, it has some per-process random nonce in order to prevent collision-based DoS attack. It seems that the order is propagated to the affected DomU. I can see varying order of pcidevs in/var/log/libvirt/libxl/<qube-name>.log
.In my opinion, keeping a stable order might be also useful for some other kind of persistently attachable devices, so maybe the problem should be solved there.
Solutions you've tried
The text was updated successfully, but these errors were encountered: