libvirt: 3.5.0 -> 3.6.0
This commit is contained in:
@@ -15,7 +15,7 @@ let
|
||||
'';
|
||||
qemuConfigFile = pkgs.writeText "qemu.conf" ''
|
||||
${optionalString cfg.qemuOvmf ''
|
||||
nvram = ["${pkgs.OVMF.fd}/FV/OVMF_CODE.fd:${pkgs.OVMF.fd}/FV/OVMF_VARS.fd"]
|
||||
nvram = ["/run/libvirt/nix-ovmf/OVMF_CODE.fd:/run/libvirt/nix-ovmf/OVMF_VARS.fd"]
|
||||
''}
|
||||
${cfg.qemuVerbatimConfig}
|
||||
'';
|
||||
@@ -102,9 +102,7 @@ in {
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = with pkgs;
|
||||
[ libvirt netcat-openbsd ]
|
||||
++ optional cfg.enableKVM qemu_kvm;
|
||||
environment.systemPackages = with pkgs; [ libvirt netcat-openbsd ];
|
||||
|
||||
boot.kernelModules = [ "tun" ];
|
||||
|
||||
@@ -129,7 +127,6 @@ in {
|
||||
dnsmasq
|
||||
ebtables
|
||||
]
|
||||
++ optional cfg.enableKVM qemu_kvm
|
||||
++ optional vswitch.enable vswitch.package;
|
||||
|
||||
preStart = ''
|
||||
@@ -155,23 +152,18 @@ in {
|
||||
# Copy generated qemu config to libvirt directory
|
||||
cp -f ${qemuConfigFile} /var/lib/libvirt/qemu.conf
|
||||
|
||||
# libvirtd puts the full path of the emulator binary in the machine
|
||||
# config file. But this path can unfortunately be garbage collected
|
||||
# while still being used by the virtual machine. So update the
|
||||
# emulator path on each startup to something valid (re-scan $PATH).
|
||||
for file in /var/lib/libvirt/qemu/*.xml /var/lib/libvirt/lxc/*.xml; do
|
||||
test -f "$file" || continue
|
||||
# get (old) emulator path from config file
|
||||
emulator=$("${pkgs.xmlstarlet}/bin/xmlstarlet" select --template --value-of "/domain/devices/emulator" "$file")
|
||||
# get a (definitely) working emulator path by re-scanning $PATH
|
||||
new_emulator=$(PATH=${pkgs.libvirt}/libexec:$PATH command -v $(basename "$emulator"))
|
||||
# write back
|
||||
"${pkgs.xmlstarlet}/bin/xmlstarlet" edit --inplace --update "/domain/devices/emulator" -v "$new_emulator" "$file"
|
||||
# stable (not GC'able as in /nix/store) paths for using in <emulator> section of xml configs
|
||||
mkdir -p /run/libvirt/nix-emulators
|
||||
ln -s --force ${pkgs.libvirt}/libexec/libvirt_lxc /run/libvirt/nix-emulators/
|
||||
${optionalString pkgs.stdenv.isAarch64 "ln -s --force ${pkgs.qemu}/bin/qemu-system-aarch64 /run/libvirt/nix-emulators/"}
|
||||
${optionalString cfg.enableKVM "ln -s --force ${pkgs.qemu_kvm}/bin/qemu-kvm /run/libvirt/nix-emulators/"}
|
||||
|
||||
# Also refresh the OVMF path. Files with no matches are ignored.
|
||||
"${pkgs.xmlstarlet}/bin/xmlstarlet" edit --inplace --update "/domain/os/loader" -v "${pkgs.OVMF.fd}/FV/OVMF_CODE.fd" "$file"
|
||||
done
|
||||
''; # */
|
||||
${optionalString cfg.qemuOvmf ''
|
||||
mkdir -p /run/libvirt/nix-ovmf
|
||||
ln -s --force ${pkgs.OVMF.fd}/FV/OVMF_CODE.fd /run/libvirt/nix-ovmf/
|
||||
ln -s --force ${pkgs.OVMF.fd}/FV/OVMF_VARS.fd /run/libvirt/nix-ovmf/
|
||||
''}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
|
||||
Reference in New Issue
Block a user