Commit Graph

7 Commits (6bc0475e8916b360e1f39f28f1eedcd0148298e9)

Author SHA1 Message Date
Dustin 3270011fee r/vmhost: Work around libvirt SELinux policy bug
With the transition to modular _libvirt_ daemons, the SELinux policy is
a bit more granular.  Unfortunately, the new policy has a funny [bug]: it
assumes directories named `storage` under `/run/libvirt` must be for
_virtstoraged_ and labels them as such, which prevents _virtnetworkd_
from managing a virtual network named `storage`.

To work around this, we need to give `/run/libvirt/network` a special
label so that its children do not match the file transition pattern for
_virtstoraged_ and thus keep their `virtnetworkd_var_run_t` label.

[bug]: https://bugzilla.redhat.com/show_bug.cgi?id=2362040
2025-07-28 18:23:24 -05:00
Dustin 2ee86f6344 r/vmhost: Retry vm-autostart if libvirt is down
If the _libvirt_ daemon has not fully started by the time `vm-autostart`
runs, we want it to fail and try again shortly.  To allow this, we first
attempt to connect to the _libvirt_ socket, and if that fails, stop
immediately and try again in a second.  This way, the first few VMs
don't get skipped with the assumption that they're missing, just because
the daemon wasn't ready yet.
2025-07-28 18:20:50 -05:00
Dustin 4df047cf76 r/vmhost: Disable DynamicUsers for vm-autostart
_libvirt_ has gone full Polkit, which doesn't work with systemd dynamic
users.  So, we have to run `vm-autostart` as root (with no special
OS-level privileges) in order for Polkit to authorize the connection to
the daemon socket.
2025-07-28 18:18:35 -05:00
Dustin 5376253c9a r/vmhost: Ensure vm-autostart waits for NFS mount
If _vm-autostart.service_ starts before `/var/lib/libvirt/images` has
been mounted, starting (some) virtual machines may fail.
2024-08-23 09:33:29 -05:00
Dustin d5de7131a0 r/vmhost: Remove system call filters from unit
The `vm-autostart` script fails with `bad system call` errors when
trying to start libvirt domains.  Removing the system call filters works
around this.  Ideally, we should figure out exactly which system call is
being rejected and allow it, but that's rather difficult to do and
probably not really worth the effort in this case.
2024-01-21 15:53:44 -06:00
Dustin 0cd58564c9 r/vmhost: Add autostart script
*libvirt*'s native autostart functionality does not work well for
machines that migrate between hosts.  Machines lose their auto-start
flag when they are migrated, and the flag is not restored if they are
migrated back.  This makes the feature pretty useless for us.

To work around this limitation, I've added a script that is run during
boot that will start the machines listed in `/etc/vm-autostart`, if they
exist.  That file can also insert a delay between starting two machines,
which may be useful to allow services to fully start on one machine
before starting another that may depend on them.
2022-08-20 21:15:31 -05:00
Dustin 7e585445b9 roles/vmhost: Enable KSM
This commit adds a systemd unit to enable the Kernel Same-page Merging
daemon on VM hosts. This allows much greater virtual machine density,
especially when many VMs are running the same guest OS.
2019-03-22 09:29:56 -05:00