Support Wi-Fi devices appearing and disappearing dynamically
At Endless, we saw a device where the Wi-Fi driver comes up after gnome-initial-setup has started. As a result, gnome-initial-setup believed there is no wireless hardware, and skipped the network page. Some excerpts from the journal:
NM discovers the device:
Aug 28 14:29:59 endless NetworkManager[476]: <info> [1566973799.1587] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/3)
Then gnome-initial-setup starts (as indicated by this debug message from a downstream change):
Aug 28 14:30:05 endless gnome-initial-setup.desktop[2085]: set live_boot to 0 from /proc/cmdline: BOOT_IMAGE=(hd0,gpt3)/boot/ostree/eos-2c1a45e7d3b0d0f1a30c473a19436421384d0d9a70515613b86823486eeb4d3c/vmlinuz-5.2.0-10-generic root=UUID=8b04cb53-2eeb-4d91-8cc4-1f111ea76413 rw splash plymouth.ignore-serial-consoles quiet loglevel=0 ostree=/ostree/boot.1/eos/2c1a45e7d3b0d0f1a30c473a19436421384d0d9a70515613b86823486eeb4d3c/0
At around this point, gnome-initial-setup enumerates all network devices – it does not respond to later changes.
Some time later, the device is renamed:
Aug 28 14:30:16 endless kernel: iwlwifi 0000:03:00.0 wlp3s0: renamed from wlan0
Aug 28 14:30:16 endless NetworkManager[476]: <info> [1566973816.7642] device (wlan0): interface index 3 renamed iface from 'wlan0' to 'wlp3s0'
and then becomes managed:
Aug 28 14:30:17 endless NetworkManager[476]: <info> [1566973817.8573] device (wlp3s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Aug 28 14:30:18 endless NetworkManager[476]: <info> [1566973818.0503] sup-iface[0x55e99f158190,wlp3s0]: supports 5 scan SSIDs
Aug 28 14:30:18 endless NetworkManager[476]: <info> [1566973818.0518] device (wlp3s0): supplicant interface state: starting -> ready
Aug 28 14:30:18 endless NetworkManager[476]: <info> [1566973818.0520] device (wlp3s0): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')
So I think the problem is essentially this FIXME:
/* FIXME deal with multiple, dynamic devices */
I expect it would also be possible to reproduce this bug by booting on a computer that doesn't have built-in Wi-Fi, then plugging in a USB Wi-Fi adapter; or by unloading the kernel module before gnome-initial-setup starts, then loading it again after it's started.
Supporting multiple Wi-Fi devices is rather harder work, but we should support Wi-Fi devices appearing and disappearing while gnome-initial-setup is running. Something like:
- Monitor NM
- If the network page is not visible, just track what Wi-Fi devices are available
- When it's about to be shown, use the first managed Wi-Fi device
- If the device we picked disappears while the Wi-Fi page is shown, try to pick another one; if there isn't another one, replace the contents of the page with some placeholder and allow the user to skip.