From 810b3c7469e70a46d8ca8aa2327424f5bac49143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 19 Mar 2022 00:25:58 +0100 Subject: [PATCH 1/2] Wait for fully starting user systemd session Since more and more "user" services are started via systemd instead of /etc/xdg/autostart, wait for them to finish starting too. This makes starting user applications more reliable. --- qubes-rpc/qubes.WaitForSession | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qubes-rpc/qubes.WaitForSession b/qubes-rpc/qubes.WaitForSession index 9d43a197e..9d47a1489 100755 --- a/qubes-rpc/qubes.WaitForSession +++ b/qubes-rpc/qubes.WaitForSession @@ -6,3 +6,7 @@ while ! [ -e "/var/run/qubes/qrexec-server.$USERNAME.sock" ] do sleep 0.1 done + +systemctl --machine="$USERNAME"@.host --user --wait --quiet is-system-running + +exit 0 From 49ec7d975e8cc49054d1af9a524ba2f7b17450a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 19 Mar 2022 04:15:05 +0100 Subject: [PATCH 2/2] Disable renaming Xen's eth0 to enX0 There are a couple of issues with this renaming: 1. When enabled, the interface name cannot be prediced until it actually happens. This breaks waiting for the device to appear in qubes-network-uplink.service. 2. Setting SYSTEMD_WANTS on a device that gets renamed seems to not work (is the variable bound to the old device name?). This breaks dynamic network attach (see 99-qubes-network.rules). So, disable it completely for Xen devices, at least for now. This may pose some issues (or rather - rollback fix attempt) for VMs with both physical devices and Xen netfront device(s), but this is extremely rare case that nobody complained about before. Fixes QubesOS/qubes-issues#7284 --- Makefile | 3 ++- debian/qubes-core-agent-networking.install | 1 + rpm_spec/core-agent.spec.in | 1 + vm-systemd/80-qubes-vif.link | 13 +++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 vm-systemd/80-qubes-vif.link diff --git a/Makefile b/Makefile index 758e50bf4..2569a91f7 100644 --- a/Makefile +++ b/Makefile @@ -108,12 +108,13 @@ SYSTEMD_NETWORK_SERVICES := vm-systemd/qubes-firewall.service vm-systemd/qubes-i SYSTEMD_CORE_SERVICES := $(filter-out $(SYSTEMD_NETWORK_SERVICES), $(SYSTEMD_ALL_SERVICES)) install-systemd: install-init - install -d $(DESTDIR)$(SYSLIBDIR)/systemd/system{,-preset} $(DESTDIR)$(LIBDIR)/qubes/init $(DESTDIR)$(SYSLIBDIR)/modules-load.d $(DESTDIR)/etc/systemd/system + install -d $(DESTDIR)$(SYSLIBDIR)/systemd/system{,-preset} $(DESTDIR)$(LIBDIR)/qubes/init $(DESTDIR)$(SYSLIBDIR)/modules-load.d $(DESTDIR)/etc/systemd/system $(DESTDIR)$(SYSLIBDIR)/systemd/network install -m 0644 $(SYSTEMD_CORE_SERVICES) $(DESTDIR)$(SYSLIBDIR)/systemd/system/ install -m 0644 vm-systemd/qubes-*.timer $(DESTDIR)$(SYSLIBDIR)/systemd/system/ install -m 0644 vm-systemd/75-qubes-vm.preset $(DESTDIR)$(SYSLIBDIR)/systemd/system-preset/ install -m 0644 vm-systemd/qubes-core.conf $(DESTDIR)$(SYSLIBDIR)/modules-load.d/ install -m 0644 vm-systemd/xendriverdomain.service $(DESTDIR)/etc/systemd/system/ + install -m 0644 vm-systemd/80-qubes-vif.link $(DESTDIR)$(SYSLIBDIR)/systemd/network/ install-sysvinit: install-init install -d $(DESTDIR)/etc/init.d diff --git a/debian/qubes-core-agent-networking.install b/debian/qubes-core-agent-networking.install index c26f2518a..f336a05ed 100644 --- a/debian/qubes-core-agent-networking.install +++ b/debian/qubes-core-agent-networking.install @@ -14,6 +14,7 @@ lib/systemd/system/qubes-network.service lib/systemd/system/qubes-network-uplink.service lib/systemd/system/qubes-network-uplink@.service lib/systemd/system/qubes-updates-proxy.service +lib/systemd/network/80-qubes-vif.link usr/lib/qubes/init/network-proxy-setup.sh usr/lib/qubes/init/network-proxy-stop.sh usr/lib/qubes/init/network-uplink-wait.sh diff --git a/rpm_spec/core-agent.spec.in b/rpm_spec/core-agent.spec.in index 11869ad0e..01cd64bf3 100644 --- a/rpm_spec/core-agent.spec.in +++ b/rpm_spec/core-agent.spec.in @@ -828,6 +828,7 @@ rm -f %{name}-%{version} /usr/lib/systemd/system/qubes-network-uplink.service /usr/lib/systemd/system/qubes-network-uplink@.service /usr/lib/systemd/system/qubes-updates-proxy.service +/usr/lib/systemd/network/80-qubes-vif.link /usr/lib/qubes/init/network-proxy-setup.sh /usr/lib/qubes/init/network-proxy-stop.sh /usr/lib/qubes/init/network-uplink-wait.sh diff --git a/vm-systemd/80-qubes-vif.link b/vm-systemd/80-qubes-vif.link new file mode 100644 index 000000000..f1911338c --- /dev/null +++ b/vm-systemd/80-qubes-vif.link @@ -0,0 +1,13 @@ +# Disable renaming of Xen netfront interfaces, to avoid race conditions during +# network configuration. systemd / udevd does not provide any way to +# synchronize against interface rename operation when the device is not +# detected yet. +# Furthermore, setting SYSTEMD_WANTS in udev seems to not work when interface +# is renamed. +# See https://github.com/QubesOS/qubes-issues/issues/7284 for details. + +[Match] +Driver=vif + +[Link] +NamePolicy=