libvirtd

libvirtd, qemu-kvm, swtpm, virt-install and guestfs-tools for server usage (no GUI support).

For desktop usage, see the libvirtd-desktop sysext instead.

See the Virtual Machine Manager Flatpak.

How to use

  • Install the sysext
  • Create the qemu user and libvirt group:
    $ sudo systemd-sysusers /usr/lib/sysusers.d/libvirt-qemu.conf
    $ sudo systemd-sysusers /usr/lib/sysusers.d/libvirt.conf
    
  • Copy the some default config:
    $ sudo cp -a /usr/etc/mdevctl.d /etc/
    
  • Optional: Copy the default libvirtd config (note that it won’t be updated automatically):
    $ sudo cp -a /usr/etc/libvirt /etc/
    
  • Optional: Setup auth via polkit (example):
    $ sudo cat /etc/polkit-1/rules.d/50-libvirt.rules
    polkit.addRule(function(action, subject) {
        if (action.id == "org.libvirt.unix.manage" &&
            subject.isInGroup("wheel")) {
                return polkit.Result.YES;
        }
    });
    
  • Set the correct permissions and SELinux contexts:
    sudo chown -R qemu:qemu /var/lib/libvirt/qemu
    sudo restorecon -Rv /var/lib/libvirt
    sudo chown root:root /var/log/libvirt/qemu
    sudo restorecon -Rv /var/log/libvirt
    
  • Trigger the systemd tmpfile drop-in and refresh the linker cache:
    $ sudo systemd-tmpfiles --create
    $ ldconfig
    
  • Restart libvirtd (via virtqemud, virtnetworkd & virtstoraged):
    $ sudo systemctl restart virtqemud.socket virtnetworkd.socket virtstoraged.socket
    
    • (Optional) To allow cockpit to manage VMs via the cockpit flatpak you need to restart the dbus service:
      $ sudo systemctl reload dbus
      $ sudo systemctl restart libvirt-dbus.service
      $ sudo systemctl restart virtnodedevd.socket
      $ sudo systemctl restart virtstoraged.socket
      

      Autostart VMs

If you have VMs that need to start on boot, you need to have virtqemud.service started. This sysext only start the sockets, which will trigger the services only when needed, e.g. when issueing a virsh command.

To add a upholds on virtqemud:

cat <<EOF > /etc/systemd/system/multi-user.target.d/20-qemu-enable-service.conf
[Unit]
Upholds=virtqemud.service 
EOF

Compatibility

This sysext is compatible with Fedora CoreOS only.

Versions available

See the libvirtd versions.

Usage instructions

First time setup

Run those commands if you have not yet installed any sysext on your system:

sudo install -d -m 0755 -o 0 -g 0 "/var/lib/extensions" "/var/lib/extensions.d"
sudo restorecon -RFv "/var/lib/extensions" "/var/lib/extensions.d"
sudo systemctl enable --now systemd-sysext.service
Installation

Define a helper function:

install_sysext() {
  SYSEXT="${1}"
  URL="https://extensions.fcos.fr/fedora"
  sudo install -d -m 0755 -o 0 -g 0 "/etc/sysupdate.${SYSEXT}.d"
  sudo restorecon -RFv "/etc/sysupdate.${SYSEXT}.d"
  curl --silent --fail --location "${URL}/${SYSEXT}.conf" \
    | sudo tee "/etc/sysupdate.${SYSEXT}.d/${SYSEXT}.conf"
  sudo /usr/lib/systemd/systemd-sysupdate update --component "${SYSEXT}"
}

Install the sysext:

install_sysext libvirtd

Reboot your system or refresh the merged sysexts:

sudo systemctl restart systemd-sysext.service
systemd-sysext status

Note that this will merge all installed sysexts unconditionally.

Updates

Update this sysext using:

sudo /usr/lib/systemd/systemd-sysupdate update --component libvirtd

If you want to use the new version immediately, make sure to refresh the merged sysexts:

sudo systemctl restart systemd-sysext.service
systemd-sysext status

To update all sysexts on a system:

for c in $(/usr/lib/systemd/systemd-sysupdate components --json=short | jq --raw-output '.components[]'); do
    sudo /usr/lib/systemd/systemd-sysupdate update --component "${c}"
done
Uninstall

Define a helper function:

uninstall_sysext() {
  SYSEXT="${1}"
  sudo rm -i "/var/lib/extensions/${SYSEXT}.raw"
  sudo rm -i "/var/lib/extensions.d/${SYSEXT}-"*".raw"
  sudo rm -i "/etc/sysupdate.${SYSEXT}.d/${SYSEXT}.conf"
  sudo rmdir "/etc/sysupdate.${SYSEXT}.d/"
}

Uninstall the sysext:

uninstall_sysext libvirtd

Reboot your system or refresh the merged sysexts:

sudo systemctl restart systemd-sysext.service
systemd-sysext status