diff --git a/ansible/files/optimize.ps1 b/ansible/files/optimize.ps1
new file mode 100644
index 0000000..73f22da
--- /dev/null
+++ b/ansible/files/optimize.ps1
@@ -0,0 +1,118 @@
+# Ensure running as Administrator
+if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
+ [Security.Principal.WindowsBuiltInRole] "Administrator")) {
+ Write-Error "Please run this script as Administrator."
+ exit 1
+}
+
+Write-Output "Applying Windows gaming performance optimizations..."
+
+# 1. Set High Performance Power Plan
+Write-Output "Setting High Performance power plan..."
+powercfg -setactive SCHEME_MIN
+
+# 2. Disable Windows Defender real-time protection
+Write-Output "Disabling Windows Defender Real-Time Protection..."
+Set-MpPreference -DisableRealtimeMonitoring $true
+
+# Run as Administrator
+
+Write-Host "Disabling unnecessary startup applications..." -ForegroundColor Cyan
+
+# --- 1. Disable from Registry (HKCU)
+$startupRegHKCU = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"
+$disableListHKCU = @(
+ "OneDrive",
+ "EpicGamesLauncher",
+ "EADM",
+ "Microsoft.Lists",
+ "MicrosoftEdgeAutoLaunch_4F5320B4C77A9527F492603BB81F11D5"
+)
+
+foreach ($name in $disableListHKCU) {
+ if (Get-ItemProperty -Path $startupRegHKCU -Name $name -ErrorAction SilentlyContinue) {
+ Write-Host "Removing HKCU startup item: $name"
+ Remove-ItemProperty -Path $startupRegHKCU -Name $name
+ }
+}
+
+# --- 2. Disable from Registry (HKLM)
+$startupRegHKLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run"
+$disableListHKLM = @(
+ "SecurityHealth" # optional; comment this line to keep Windows Security Tray
+)
+
+foreach ($name in $disableListHKLM) {
+ if (Get-ItemProperty -Path $startupRegHKLM -Name $name -ErrorAction SilentlyContinue) {
+ Write-Host "Removing HKLM startup item: $name"
+ Remove-ItemProperty -Path $startupRegHKLM -Name $name
+ }
+}
+
+# --- 3. Disable startup folder entries
+$startupFolders = @(
+ "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup",
+ "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
+)
+
+foreach ($folder in $startupFolders) {
+ Get-ChildItem $folder -Filter *.lnk -ErrorAction SilentlyContinue | ForEach-Object {
+ Write-Host "Disabling startup shortcut: $($_.Name)"
+ Remove-Item $_.FullName -Force
+ }
+}
+
+Write-Host "`n✅ Startup applications optimized. Reboot to apply changes." -ForegroundColor Green
+
+# 4. Disable background services
+Write-Output "Disabling unnecessary background services..."
+$servicesToDisable = @(
+ "DiagTrack", # Connected User Experience and Telemetry
+ "SysMain", # Superfetch
+ "WSearch", # Windows Search
+ "XblGameSave", # Xbox services
+ "MapsBroker", # Maps background service
+ "OneSyncSvc" # OneDrive sync
+ "AdobeARMservice",
+ "ClickToRunSvc",
+ "edgeupdate",
+ "OneSyncSvc_78aa3",
+ "CDPUserSvc_78aa3",
+ "CDPSvc",
+ "webthreatdefusersvc_78aa3",
+ "WpnService",
+ "WpnUserService_78aa3",
+ "Spooler",
+ "SCardSvr",
+ "MicrosoftEdgeAutoLaunch_4F5320B4C77A9527F492603BB81F11D5",
+ "vorpX Service"
+)
+
+foreach ($svc in $servicesToDisable) {
+ try {
+ Write-Host "Disabling service: $svc" -ForegroundColor Yellow
+ Stop-Service -Name $svc -Force -ErrorAction SilentlyContinue
+ Set-Service -Name $svc -StartupType Disabled
+ } catch {
+ Write-Host "Could not disable ${svc}: $_" -ForegroundColor Red }
+}
+
+# 5. NVIDIA GPU Tweaks - Launch NVIDIA Control Panel (manual steps)
+Write-Output "`n[!] Please open NVIDIA Control Panel and set:"
+Write-Output "- Power Management: Prefer Maximum Performance"
+Write-Output "- Low Latency Mode: Ultra"
+Write-Output "- Vertical Sync: Off or Fast Sync (depending on monitor)"
+Start-Process "nvcplui.exe"
+
+# 6. Disable Xbox Game Bar and DVR
+Write-Output "Disabling Xbox Game Bar and DVR..."
+reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "AppCaptureEnabled" /t REG_DWORD /d 0 /f
+reg add "HKCU\System\GameConfigStore" /v "GameDVR_Enabled" /t REG_DWORD /d 0 /f
+reg add "HKCU\System\GameConfigStore" /v "GameDVR_FSEBehaviorMode" /t REG_DWORD /d 2 /f
+reg add "HKCU\System\GameConfigStore" /v "GameDVR_HonorUserFSEBehaviorMode" /t REG_DWORD /d 1 /f
+
+# 7. Disable Notifications
+Write-Output "Disabling Windows notifications..."
+reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\PushNotifications" /v "ToastEnabled" /t REG_DWORD /d 0 /f
+
+Write-Output "`n✅ Optimization complete. Please restart your VM for all changes to take effect."
diff --git a/ansible/files/vms/fedora-headless.xml b/ansible/files/vms/fedora-headless.xml
new file mode 100644
index 0000000..c6449ac
--- /dev/null
+++ b/ansible/files/vms/fedora-headless.xml
@@ -0,0 +1,199 @@
+
+ fedora-headless
+ 55feda16-51ae-446e-9c83-4c0eee1e5e00
+ Fedora CUDA headless
+ 33554432
+ 33554432
+
+
+
+
+
+ 2
+
+
+
+
+
+
+ hvm
+ /usr/share/edk2/ovmf/OVMF_CODE.fd
+ /var/lib/libvirt/qemu/nvram/fedora-headless_VARS.fd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+
+
+
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ansible/files/vms/old/fedora-headless.old.xml b/ansible/files/vms/old/fedora-headless.old.xml
new file mode 100644
index 0000000..a346373
--- /dev/null
+++ b/ansible/files/vms/old/fedora-headless.old.xml
@@ -0,0 +1,220 @@
+
+ fedora-headless
+ 55feda16-51ae-446e-9c83-4c0eee1e5e00
+ Fedora CUDA headless
+ 33554432
+ 33554432
+
+
+
+
+
+ 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hvm
+ /usr/share/edk2/ovmf/OVMF_CODE.fd
+ /var/lib/libvirt/qemu/nvram/fedora-headless_VARS.fd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+
+
+
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ansible/files/vms/old/windows-11-pro.old.xml b/ansible/files/vms/old/windows-11-pro.old.xml
new file mode 100644
index 0000000..ad03378
--- /dev/null
+++ b/ansible/files/vms/old/windows-11-pro.old.xml
@@ -0,0 +1,300 @@
+
+ windows-11
+ 51d5d091-67cb-4113-bd8e-817e7317e1b4
+ Microsoft Windows 11
+ 25165824
+ 25165824
+
+
+
+
+
+ 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /machine
+
+
+ hvm
+ /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd
+ /var/lib/libvirt/qemu/nvram/windows-11_VARS.fd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+
+
+
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ system_u:object_r:svirt_image_t:s0:c399,c880
+
+
+
+ +107:+107
+
+
+
diff --git a/ansible/files/vms/windows-11.xml b/ansible/files/vms/windows-11.xml
new file mode 100644
index 0000000..1948ad0
--- /dev/null
+++ b/ansible/files/vms/windows-11.xml
@@ -0,0 +1,224 @@
+
+ windows-11
+ 51d5d091-67cb-4113-bd8e-817e7317e1b4
+ Microsoft Windows 11
+ 25165824
+ 25165824
+
+
+
+
+
+ 8
+
+
+
+
+
+
+
+
+
+
+
+
+ hvm
+ /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd
+ /var/lib/libvirt/qemu/nvram/windows-11_VARS.fd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ destroy
+
+
+
+
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ansible/localhost_playbook_vm_host.yml b/ansible/localhost_playbook_vm_host.yml
new file mode 100644
index 0000000..ebf144a
--- /dev/null
+++ b/ansible/localhost_playbook_vm_host.yml
@@ -0,0 +1,142 @@
+- name: Setup GPU passthrough host (Fedora + QEMU/KVM)
+ hosts: localhost
+ become: true
+ vars:
+ host_reserved_cpu: "0-1"
+ gaming_vm_cpus: "2-9"
+ ai_vm_cpus: "10-11"
+ vfio_ids:
+ - 10de:2482 # NVIDIA Corporation GA104 [GeForce RTX 3070 Ti]
+ - 10de:228b # NVIDIA Corporation GA106 High Definition Audio Controller
+ - 10de:2504 # NVIDIA Corporation GA106 [GeForce RTX 3060 Lite Hash Rate]
+ - 10de:228e # NVIDIA Corporation GA106 High Definition Audio Controller
+ - 1b73:1100 # Fresco Logic FL1100 USB 3.0 Host Controller
+ # - 144d:a808 # Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983
+ grub_config_file: "/etc/default/grub"
+ grub_cmdline_args: >
+ rhgb quiet intel_iommu=on iommu=pt
+ isolcpus=1-5,7-11 nohz_full=1-5,7-11 rcu_nocbs=1-5,7-11
+ i915.modeset=1 i915.enable_gvt=1 i915.enable_fbc=0
+ initcall_blacklist=simpledrm_platform_driver_init
+ rd.driver.blacklist=nouveau modprobe.blacklist=nouveau
+ snd_hda_codec_hdmi.blacklist=1 rd.driver.pre=vfio-pci audit=off
+
+ win_partition: "/dev/nvme0n1p1"
+ ai_partition: "/dev/nvme0n1p2"
+ partitions:
+ - { dev: "/dev/nvme0n1p1", label: "win-nvme" }
+ - { dev: "/dev/nvme0n1p2", label: "ai-nvme" }
+
+ tasks:
+
+ - name: Install virtualization packages
+ ansible.builtin.dnf:
+ name:
+ - qemu-kvm
+ - libvirt
+ - virt-install
+ - virt-manager
+ - bridge-utils
+ - pciutils
+ state: present
+
+ - name: Enable and start libvirtd
+ ansible.builtin.systemd:
+ name: libvirtd
+ enabled: true
+ state: started
+
+ - name: Ensure GRUB_CMDLINE_LINUX is configured for vfio, isolcpus, nohz_full, rcu_nocbs
+ ansible.builtin.lineinfile:
+ path: "{{ grub_config_file }}"
+ regexp: '^GRUB_CMDLINE_LINUX='
+ line: 'GRUB_CMDLINE_LINUX="{{ grub_cmdline_args | trim }}"'
+ backrefs: true
+
+ - name: Add VFIO PCI device IDs to modprobe
+ ansible.builtin.copy:
+ dest: /etc/modprobe.d/vfio.conf
+ content: |
+ options vfio-pci ids={{ vfio_ids | join(',') }}
+ install snd_hda_codec_hdmi /bin/false
+ mode: '0644'
+
+ - name: Blacklist Nouveau and other drivers
+ ansible.builtin.copy:
+ dest: /etc/modprobe.d/ansible-blacklist.conf
+ content: |
+ blacklist noveau
+ blacklist snd_hda_codec_hdmi
+ blacklist i2c_nvidia_gpu
+ blacklist mxm_wmi
+ mode: '0644'
+
+ - name: Add vfio modules to initramfs config
+ ansible.builtin.copy:
+ dest: /etc/dracut.conf.d/vfio.conf
+ content: |
+ add_drivers+=" vfio vfio_iommu_type1 vfio_pci "
+ mode: '0644'
+
+ - name: Rebuild initramfs
+ changed_when: false
+ ansible.builtin.command: dracut -f
+
+ - name: Rebuild GRUB config
+ changed_when: false
+ ansible.builtin.command: grub2-mkconfig -o /boot/grub2/grub.cfg
+ when: ansible_facts['distribution'] == "Fedora"
+
+ - name: Enable KVM modules at boot
+ ansible.builtin.copy:
+ dest: /etc/modules-load.d/kvm.conf
+ content: |
+ kvmgt
+ mdev
+ vfio
+ vfio-pci
+ vfio_iommu_type1
+ mode: '0644'
+
+ - name: Notify user to reboot for changes
+ ansible.builtin.debug:
+ msg: |
+ Reboot your system to apply IOMMU, CPU isolation, and VFIO settings.
+ After reboot, verify using: `dmesg | grep -i vfio` and `lspci -nnk`
+
+ - name: Ensure partitions are unmounted
+ ansible.posix.mount:
+ path: "/mnt/{{ item.label }}"
+ src: "{{ item.dev }}"
+ state: absent
+ fstype: auto
+ loop: "{{ partitions }}"
+
+ - name: Set permissions for partition passthrough
+ ansible.builtin.file:
+ path: "{{ item.dev }}"
+ owner: qemu
+ group: kvm
+ mode: '0660'
+ loop: "{{ partitions }}"
+
+ - name: Create udev rules for persistent access
+ ansible.builtin.copy:
+ dest: /etc/udev/rules.d/99-qemu-nvme.rules
+ content: |
+ KERNEL=="nvme0n1", OWNER="qemu", GROUP="kvm", MODE="0660"
+ KERNEL=="nvme0n1p1", OWNER="qemu", GROUP="kvm", MODE="0660"
+ KERNEL=="nvme0n1p2", OWNER="qemu", GROUP="kvm", MODE="0660"
+ mode: '0644'
+ notify:
+ - Reload udev rules
+ - Trigger udev to apply changes
+
+ handlers:
+ - name: Reload udev rules
+ changed_when: false
+ ansible.builtin.command: udevadm control --reload-rules
+
+ - name: Trigger udev to apply changes
+ changed_when: false
+ ansible.builtin.command: udevadm trigger
diff --git a/scripts/cpu_power_monitor.py b/scripts/cpu_power_monitor.py
new file mode 100644
index 0000000..7e55978
--- /dev/null
+++ b/scripts/cpu_power_monitor.py
@@ -0,0 +1,33 @@
+import time
+import os
+
+RAPL_PATH = "/sys/class/powercap/intel-rapl:0/energy_uj"
+
+def read_energy():
+ try:
+ with open(RAPL_PATH, "r") as f:
+ return int(f.read().strip())
+ except FileNotFoundError:
+ print(f"Error: {RAPL_PATH} not found.")
+ exit(1)
+
+def calculate_power(interval=1.0):
+ print(f"Monitoring CPU package power every {interval} second(s)... (Ctrl+C to stop)")
+ while True:
+ energy_before = read_energy()
+ time.sleep(interval)
+ energy_after = read_energy()
+
+ delta_uj = energy_after - energy_before
+ power_watts = (delta_uj / 1_000_000) / interval
+
+ print(f"Power Usage: {power_watts:.2f} Watts")
+
+if __name__ == "__main__":
+ if os.geteuid() != 0:
+ print("Please run this script as root.")
+ exit(1)
+ try:
+ calculate_power(interval=1.0)
+ except KeyboardInterrupt:
+ print("\nStopped.")
\ No newline at end of file