Laszlo Ersek
2022-Jun-09 13:10 UTC
[Libguestfs] [v2v PATCH 4/4] convert_linux: install the QEMU guest agent with a firstboot script
On 06/07/22 14:59, Richard W.M. Jones wrote:> virt-p2v uses: > > nm-online -t 30 > > Apparently systemd-networkd (which I've never knowingly used) has > another command: > > /usr/lib/systemd/systemd-networkd-wait-online > > which ought to do the same thing. (It defaults to 120 second timeout.) > Can we not do something like: > > nm-online -t 30 ||: > /usr/lib/systemd/systemd-networkd-wait-online ||: > > as a best effort? Seems a lot better idea than sleeping.After some investigation: - NetworkManager and systemd-networkd-wait-online seem mutually exclusive, and switching from the former to the latter (which is obviously only possible on a systemd-based system) takes (mostly) one "systemctl disable" and another "systemctl enable" command: https://fedoraproject.org/wiki/Cloud/Network-Requirements#Switching_from_NetworkManager_to_systemd-networkd - When one of { NetworkManager, systemd-networkd-wait-online } is *disabled* (not running), and we invoke the "wait online" utility for that (disabled) service, the utility will wait (uselessly) for the timeout, and then report failure / timeout. I've tested this with "systemd-networkd-wait-online" on my F35 workstation (where NetworkManager is enabled -- the default), and with "nm-online" in a RHEL9 guest, where I could disable NetworkManager without risks. - This useless waiting (for NetworkManager that's not running) can be disabled with the "-x" switch for nm-online, but I found no corresponding switch for "systemd-networkd-wait-online". What works is "systemctl is-active systemd-networkd", which is reasonable, because "systemd-networkd" already depends on systemd. Additionally the default timeout for nm-online seems to be 30 seconds already. So ultimately I believe we should do: nm-online -x -q || ( systemctl -q is-active systemd-networkd && /usr/lib/systemd/systemd-networkd-wait-online -q --timeout=30 ) If the final exit status is nonzero, I think that's not a problem for the firstboot script. The whole command seems to make sense also when nm-online, systemctl, or both, are missing (a missing command results in exit status 127). Thanks Laszlo
Laszlo Ersek
2022-Jun-09 13:53 UTC
[Libguestfs] [v2v PATCH 4/4] convert_linux: install the QEMU guest agent with a firstboot script
On 06/09/22 15:10, Laszlo Ersek wrote:> nm-online -x -q || > ( > systemctl -q is-active systemd-networkd && > /usr/lib/systemd/systemd-networkd-wait-online -q --timeout=30 > ) > > If the final exit status is nonzero, I think that's not a problem for > the firstboot script. > > The whole command seems to make sense also when nm-online, systemctl, or > both, are missing (a missing command results in exit status 127).Unfortunately, this does not work. Even though the command succeeds very quickly (implying network is available), the DNF throws a CURL error that it cannot access the repo (DNS resolution failure). So basically "nm-online" lies. Compare: https://bugzilla.redhat.com/show_bug.cgi?id=1482476#c4> My current workaround is to use "/usr/bin/sleep 60" instead of the > "/usr/bin/nm-online -s -q --timeout=30" command in the service unit > file.:/ NB, when I log in at the root prompt of the just-firstbooted-guest (on tty1), and run "nm-online -x -q", it succeeds alright, and I can even ssh into the guest... (more precisely, I get an ssh password prompt; I can't actually log in as root via ssh due to the default sshd config not permitting that). We can't rely on "nm-online" if it doesn't do its advertized job! Laszlo