mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 08:53:56 -05:00
vfio reformatting and such
This commit is contained in:
parent
6847448a39
commit
a029177bde
2 changed files with 79 additions and 85 deletions
|
|
@ -46,12 +46,6 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.kernelPatches = lib.singleton {
|
|
||||||
name = "fix_amd_mem_access";
|
|
||||||
patch = null;
|
|
||||||
extraStructuredConfig.HSA_AMD_SVM = lib.kernel.yes;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"L /etc/X11/xorg.conf.d/99-custom.conf - - - - /etc/Xorg/2_mon.conf"
|
"L /etc/X11/xorg.conf.d/99-custom.conf - - - - /etc/Xorg/2_mon.conf"
|
||||||
|
|
||||||
|
|
@ -70,45 +64,13 @@ in
|
||||||
"vfio_iommu_type1.allow_unsafe_interrupts=1"
|
"vfio_iommu_type1.allow_unsafe_interrupts=1"
|
||||||
"kvm.ignore_msrs=1"
|
"kvm.ignore_msrs=1"
|
||||||
];
|
];
|
||||||
};
|
kernelPatches = lib.singleton {
|
||||||
virtualisation = {
|
name = "fix_amd_mem_access";
|
||||||
libvirtd = {
|
patch = null;
|
||||||
enable = true;
|
extraStructuredConfig.HSA_AMD_SVM = lib.kernel.yes;
|
||||||
qemu = {
|
|
||||||
# Patch to disable hooking the mouse via evdev at VM startup
|
|
||||||
package = pkgs.qemu_kvm.overrideAttrs (old: {
|
|
||||||
patches = old.patches ++ [
|
|
||||||
(builtins.toFile "qemu.diff" ''
|
|
||||||
diff --git a/ui/input-linux.c b/ui/input-linux.c
|
|
||||||
index e572a2e..a9d76ba 100644
|
|
||||||
--- a/ui/input-linux.c
|
|
||||||
+++ b/ui/input-linux.c
|
|
||||||
@@ -397,12 +397,6 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_set_fd_handler(il->fd, input_linux_event, NULL, il);
|
|
||||||
- if (il->keycount) {
|
|
||||||
- /* delay grab until all keys are released */
|
|
||||||
- il->grab_request = true;
|
|
||||||
- } else {
|
|
||||||
- input_linux_toggle_grab(il);
|
|
||||||
- }
|
|
||||||
QTAILQ_INSERT_TAIL(&inputs, il, next);
|
|
||||||
il->initialized = true;
|
|
||||||
return;
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
});
|
|
||||||
runAsRoot = true;
|
|
||||||
ovmf.enable = true;
|
|
||||||
verbatimConfig = ''
|
|
||||||
user = "gerg"
|
|
||||||
group = "users"
|
|
||||||
namespaces = []
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = [
|
systemPackages = [
|
||||||
pkgs.dmidecode
|
pkgs.dmidecode
|
||||||
|
|
@ -122,26 +84,60 @@ in
|
||||||
|
|
||||||
programs.virt-manager.enable = true;
|
programs.virt-manager.enable = true;
|
||||||
|
|
||||||
virtualisation.libvirtd.hooks.qemu = {
|
virtualisation.libvirtd = {
|
||||||
"AAA" = lib.getExe (
|
enable = true;
|
||||||
pkgs.writeShellApplication {
|
qemu = {
|
||||||
name = "qemu-hook";
|
# Patch to disable hooking the mouse via evdev at VM startup
|
||||||
|
package = pkgs.qemu_kvm.overrideAttrs (old: {
|
||||||
|
patches = old.patches ++ [
|
||||||
|
(builtins.toFile "qemu.diff" ''
|
||||||
|
diff --git a/ui/input-linux.c b/ui/input-linux.c
|
||||||
|
index e572a2e..a9d76ba 100644
|
||||||
|
--- a/ui/input-linux.c
|
||||||
|
+++ b/ui/input-linux.c
|
||||||
|
@@ -397,12 +397,6 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
||||||
|
}
|
||||||
|
|
||||||
runtimeInputs = [
|
qemu_set_fd_handler(il->fd, input_linux_event, NULL, il);
|
||||||
pkgs.libvirt
|
- if (il->keycount) {
|
||||||
pkgs.systemd
|
- /* delay grab until all keys are released */
|
||||||
pkgs.kmod
|
- il->grab_request = true;
|
||||||
|
- } else {
|
||||||
|
- input_linux_toggle_grab(il);
|
||||||
|
- }
|
||||||
|
QTAILQ_INSERT_TAIL(&inputs, il, next);
|
||||||
|
il->initialized = true;
|
||||||
|
return;
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
|
});
|
||||||
|
runAsRoot = true;
|
||||||
|
ovmf.enable = true;
|
||||||
|
verbatimConfig = ''
|
||||||
|
user = "gerg"
|
||||||
|
group = "users"
|
||||||
|
namespaces = []
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
hooks.qemu = {
|
||||||
|
# Ordering is based on the name
|
||||||
|
"AAA" = lib.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "qemu-hook";
|
||||||
|
|
||||||
text = ''
|
runtimeInputs = [
|
||||||
GUEST_NAME="$1"
|
pkgs.libvirt
|
||||||
OPERATION="$2"
|
pkgs.systemd
|
||||||
|
pkgs.kmod
|
||||||
|
];
|
||||||
|
|
||||||
if [ "$GUEST_NAME" != "Windows" ]; then
|
text = ''
|
||||||
exit 0
|
GUEST_NAME="$1"
|
||||||
fi
|
OPERATION="$2"
|
||||||
|
|
||||||
if [ "$OPERATION" == "prepare" ]; then
|
if [ "$GUEST_NAME" != "Windows" ]; then
|
||||||
|
exit 0
|
||||||
|
else if [ "$OPERATION" == "prepare" ]; then
|
||||||
# Stop display-manager
|
# Stop display-manager
|
||||||
systemctl stop display-manager.service
|
systemctl stop display-manager.service
|
||||||
|
|
||||||
|
|
@ -161,37 +157,35 @@ in
|
||||||
ln -fs /etc/Xorg/1_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
ln -fs /etc/Xorg/1_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
||||||
touch /etc/Xorg/ONE_MONITOR
|
touch /etc/Xorg/ONE_MONITOR
|
||||||
systemctl start display-manager.service
|
systemctl start display-manager.service
|
||||||
fi
|
else if [ "$OPERATION" == "release" ]; then
|
||||||
|
# Dual gpu/monitor stuff
|
||||||
|
systemctl stop display-manager.service
|
||||||
|
|
||||||
if [ "$OPERATION" == "release" ]; then
|
# Allow all CPUs
|
||||||
|
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
||||||
|
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
||||||
|
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
||||||
|
|
||||||
# Dual gpu/monitor stuff
|
# Re-attach GPU
|
||||||
systemctl stop display-manager.service
|
virsh nodedev-reattach pci_0000_01_00_0
|
||||||
|
virsh nodedev-reattach pci_0000_01_00_1
|
||||||
|
|
||||||
# Allow all CPUs
|
# Re-bind Driver
|
||||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
|
||||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
|
||||||
|
|
||||||
# Re-attach GPU
|
# Dual gpu/monitor stuff
|
||||||
virsh nodedev-reattach pci_0000_01_00_0
|
ln -fs /etc/Xorg/2_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
||||||
virsh nodedev-reattach pci_0000_01_00_1
|
rm /etc/Xorg/ONE_MONITOR
|
||||||
|
|
||||||
# Re-bind Driver
|
# Restart display-manager
|
||||||
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
systemctl start display-manager.service
|
||||||
|
else
|
||||||
# Dual gpu/monitor stuff
|
exit 0
|
||||||
ln -fs /etc/Xorg/2_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
fi
|
||||||
rm /etc/Xorg/ONE_MONITOR
|
'';
|
||||||
|
}
|
||||||
# Restart display-manager
|
);
|
||||||
systemctl start display-manager.service
|
};
|
||||||
fi
|
|
||||||
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit _file;
|
inherit _file;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
forceImportAll = true;
|
forceImportAll = true;
|
||||||
};
|
};
|
||||||
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
|
||||||
#disable hibernate and set cache max
|
#set ARC max
|
||||||
kernelParams = [ "zfs.zfs_arc_max=17179869184" ];
|
kernelParams = [ "zfs.zfs_arc_max=17179869184" ];
|
||||||
initrd = {
|
initrd = {
|
||||||
#module for multiple swap devices
|
#module for multiple swap devices
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue