Add Windows 11 VM configuration and setup for GPU passthrough
- Created a new XML configuration file for Windows 11 VM with enhanced resource allocation and device settings. - Added an old configuration file for reference. - Implemented an Ansible playbook to set up a GPU passthrough host on Fedora, including necessary package installations, GRUB configuration, and udev rules for persistent device access. - Introduced a Python script to monitor CPU power usage via Intel RAPL interface.
This commit is contained in:
@@ -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."
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>fedora-headless</name>
|
||||||
|
<uuid>55feda16-51ae-446e-9c83-4c0eee1e5e00</uuid>
|
||||||
|
<title>Fedora CUDA headless</title>
|
||||||
|
<memory unit='KiB'>33554432</memory>
|
||||||
|
<currentMemory unit='KiB'>33554432</currentMemory>
|
||||||
|
<memoryBacking>
|
||||||
|
<hugepages/>
|
||||||
|
<source type='memfd'/>
|
||||||
|
<access mode='shared'/>
|
||||||
|
</memoryBacking>
|
||||||
|
<vcpu placement='static'>2</vcpu>
|
||||||
|
<cputune>
|
||||||
|
<vcpupin vcpu='0' cpuset='1'/>
|
||||||
|
<vcpupin vcpu='1' cpuset='7'/>
|
||||||
|
<emulatorpin cpuset='0,6'/>
|
||||||
|
</cputune>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
|
||||||
|
<loader readonly='yes' secure='no' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
|
||||||
|
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/fedora-headless_VARS.fd</nvram>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
<bootmenu enable='no'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<smm state='on'/>
|
||||||
|
</features>
|
||||||
|
<cpu mode='host-passthrough' check='none' migratable='on'>
|
||||||
|
<topology sockets='1' dies='1' cores='1' threads='2'/>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='localtime'>
|
||||||
|
<timer name='rtc' tickpolicy='catchup'/>
|
||||||
|
<timer name='pit' tickpolicy='delay'/>
|
||||||
|
<timer name='hpet' present='no'/>
|
||||||
|
<timer name='kvmclock' present='yes'/>
|
||||||
|
</clock>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<pm>
|
||||||
|
<suspend-to-mem enabled='no'/>
|
||||||
|
<suspend-to-disk enabled='no'/>
|
||||||
|
</pm>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='writeback'/>
|
||||||
|
<source file='/var/lib/libvirt/images/fedora-headless.snap-2025-05-27'/>
|
||||||
|
<backingStore type='file'>
|
||||||
|
<format type='qcow2'/>
|
||||||
|
<source file='/var/lib/libvirt/images/fedora-headless.qcow2'/>
|
||||||
|
<backingStore/>
|
||||||
|
</backingStore>
|
||||||
|
<target dev='sda' bus='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source dev='/dev/nvme0n1'/>
|
||||||
|
<target dev='sdb' bus='virtio'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='1' port='0x8'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pcie-to-pci-bridge'>
|
||||||
|
<model name='pcie-pci-bridge'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='3' port='0x9'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='4' port='0xa'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='5' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='5' port='0xb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='6' port='0xc'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='7' port='0xd'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='8' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='8' port='0xe'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='9' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='9' port='0xf'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='10' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='10' port='0x10'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='11' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='11' port='0x11'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='12' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='12' port='0x12'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='13' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='13' port='0x13'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='14' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='14' port='0x14'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='15' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='15' port='0x15'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='16' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='16' port='0x16'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ccid' index='0'>
|
||||||
|
<address type='usb' bus='0' port='1'/>
|
||||||
|
</controller>
|
||||||
|
<filesystem type='mount' accessmode='passthrough'>
|
||||||
|
<driver type='virtiofs'/>
|
||||||
|
<source dir='/media'/>
|
||||||
|
<target dir='Media'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
|
||||||
|
</filesystem>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:ae:f3:d0'/>
|
||||||
|
<source bridge='bridge0'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<serial type='pty'>
|
||||||
|
<target type='isa-serial' port='0'>
|
||||||
|
<model name='isa-serial'/>
|
||||||
|
</target>
|
||||||
|
</serial>
|
||||||
|
<console type='pty'>
|
||||||
|
<target type='serial' port='0'/>
|
||||||
|
</console>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<tpm model='tpm-tis'>
|
||||||
|
<backend type='emulator' version='2.0'/>
|
||||||
|
</tpm>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
||||||
|
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>fedora-headless</name>
|
||||||
|
<uuid>55feda16-51ae-446e-9c83-4c0eee1e5e00</uuid>
|
||||||
|
<title>Fedora CUDA headless</title>
|
||||||
|
<memory unit='KiB'>33554432</memory>
|
||||||
|
<currentMemory unit='KiB'>33554432</currentMemory>
|
||||||
|
<memoryBacking>
|
||||||
|
<hugepages/>
|
||||||
|
<source type='memfd'/>
|
||||||
|
<access mode='shared'/>
|
||||||
|
</memoryBacking>
|
||||||
|
<vcpu placement='static'>10</vcpu>
|
||||||
|
<cputune>
|
||||||
|
<vcpupin vcpu='0' cpuset='1'/>
|
||||||
|
<vcpupin vcpu='1' cpuset='7'/>
|
||||||
|
<vcpupin vcpu='2' cpuset='2'/>
|
||||||
|
<vcpupin vcpu='3' cpuset='8'/>
|
||||||
|
<vcpupin vcpu='4' cpuset='3'/>
|
||||||
|
<vcpupin vcpu='5' cpuset='9'/>
|
||||||
|
<vcpupin vcpu='6' cpuset='4'/>
|
||||||
|
<vcpupin vcpu='7' cpuset='10'/>
|
||||||
|
<vcpupin vcpu='8' cpuset='5'/>
|
||||||
|
<vcpupin vcpu='9' cpuset='11'/>
|
||||||
|
<emulatorpin cpuset='0,6'/>
|
||||||
|
</cputune>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
|
||||||
|
<loader readonly='yes' secure='no' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.fd</loader>
|
||||||
|
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/fedora-headless_VARS.fd</nvram>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
<bootmenu enable='no'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<smm state='on'/>
|
||||||
|
</features>
|
||||||
|
<cpu mode='host-passthrough' check='none' migratable='on'>
|
||||||
|
<topology sockets='1' dies='1' cores='5' threads='2'/>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='localtime'>
|
||||||
|
<timer name='rtc' tickpolicy='catchup'/>
|
||||||
|
<timer name='pit' tickpolicy='delay'/>
|
||||||
|
<timer name='hpet' present='no'/>
|
||||||
|
<timer name='kvmclock' present='yes'/>
|
||||||
|
</clock>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<pm>
|
||||||
|
<suspend-to-mem enabled='no'/>
|
||||||
|
<suspend-to-disk enabled='no'/>
|
||||||
|
</pm>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='writeback'/>
|
||||||
|
<source file='/var/lib/libvirt/images/fedora-headless.snap-2025-05-27'/>
|
||||||
|
<backingStore type='file'>
|
||||||
|
<format type='qcow2'/>
|
||||||
|
<source file='/var/lib/libvirt/images/fedora-headless.qcow2'/>
|
||||||
|
<backingStore/>
|
||||||
|
</backingStore>
|
||||||
|
<target dev='sda' bus='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='1' port='0x8'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pcie-to-pci-bridge'>
|
||||||
|
<model name='pcie-pci-bridge'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='3' port='0x9'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='4' port='0xa'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='5' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='5' port='0xb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='6' port='0xc'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='7' port='0xd'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='8' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='8' port='0xe'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='9' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='9' port='0xf'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='10' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='10' port='0x10'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='11' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='11' port='0x11'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='12' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='12' port='0x12'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='13' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='13' port='0x13'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='14' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='14' port='0x14'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='15' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='15' port='0x15'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='16' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='16' port='0x16'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ccid' index='0'>
|
||||||
|
<address type='usb' bus='0' port='1'/>
|
||||||
|
</controller>
|
||||||
|
<filesystem type='mount' accessmode='passthrough'>
|
||||||
|
<driver type='virtiofs'/>
|
||||||
|
<source dir='/media'/>
|
||||||
|
<target dir='Media'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
|
||||||
|
</filesystem>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:ae:f3:d0'/>
|
||||||
|
<source bridge='bridge0'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<serial type='pty'>
|
||||||
|
<target type='isa-serial' port='0'>
|
||||||
|
<model name='isa-serial'/>
|
||||||
|
</target>
|
||||||
|
</serial>
|
||||||
|
<console type='pty'>
|
||||||
|
<target type='serial' port='0'/>
|
||||||
|
</console>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<tpm model='tpm-tis'>
|
||||||
|
<backend type='emulator' version='2.0'/>
|
||||||
|
</tpm>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0a' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0c' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0f' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x10' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
||||||
|
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
<domain type='kvm' id='1'>
|
||||||
|
<name>windows-11</name>
|
||||||
|
<uuid>51d5d091-67cb-4113-bd8e-817e7317e1b4</uuid>
|
||||||
|
<title>Microsoft Windows 11</title>
|
||||||
|
<memory unit='KiB'>25165824</memory>
|
||||||
|
<currentMemory unit='KiB'>25165824</currentMemory>
|
||||||
|
<memoryBacking>
|
||||||
|
<hugepages/>
|
||||||
|
<source type='memfd'/>
|
||||||
|
<access mode='shared'/>
|
||||||
|
</memoryBacking>
|
||||||
|
<vcpu placement='static'>10</vcpu>
|
||||||
|
<cputune>
|
||||||
|
<vcpupin vcpu='0' cpuset='1'/>
|
||||||
|
<vcpupin vcpu='1' cpuset='7'/>
|
||||||
|
<vcpupin vcpu='2' cpuset='2'/>
|
||||||
|
<vcpupin vcpu='3' cpuset='8'/>
|
||||||
|
<vcpupin vcpu='4' cpuset='3'/>
|
||||||
|
<vcpupin vcpu='5' cpuset='9'/>
|
||||||
|
<vcpupin vcpu='6' cpuset='4'/>
|
||||||
|
<vcpupin vcpu='7' cpuset='10'/>
|
||||||
|
<vcpupin vcpu='8' cpuset='5'/>
|
||||||
|
<vcpupin vcpu='9' cpuset='11'/>
|
||||||
|
<emulatorpin cpuset='0,6'/>
|
||||||
|
</cputune>
|
||||||
|
<resource>
|
||||||
|
<partition>/machine</partition>
|
||||||
|
</resource>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
|
||||||
|
<loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
|
||||||
|
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/windows-11_VARS.fd</nvram>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
<bootmenu enable='no'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<hyperv mode='custom'>
|
||||||
|
<relaxed state='on'/>
|
||||||
|
<vapic state='on'/>
|
||||||
|
<spinlocks state='on' retries='8191'/>
|
||||||
|
<vendor_id state='on' value='whatever'/>
|
||||||
|
</hyperv>
|
||||||
|
<kvm>
|
||||||
|
<hidden state='on'/>
|
||||||
|
</kvm>
|
||||||
|
<smm state='on'/>
|
||||||
|
</features>
|
||||||
|
<cpu mode='host-passthrough' check='none' migratable='on'>
|
||||||
|
<topology sockets='1' dies='1' cores='5' threads='2'/>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='localtime'>
|
||||||
|
<timer name='rtc' tickpolicy='catchup'/>
|
||||||
|
<timer name='pit' tickpolicy='delay'/>
|
||||||
|
<timer name='hpet' present='no'/>
|
||||||
|
<timer name='kvmclock' present='yes'/>
|
||||||
|
<timer name='hypervclock' present='yes'/>
|
||||||
|
</clock>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<pm>
|
||||||
|
<suspend-to-mem enabled='no'/>
|
||||||
|
<suspend-to-disk enabled='no'/>
|
||||||
|
</pm>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='writeback'/>
|
||||||
|
<source file='/var/lib/libvirt/images/windows-11.qcow2' index='2'/>
|
||||||
|
<backingStore/>
|
||||||
|
<target dev='sda' bus='virtio'/>
|
||||||
|
<alias name='virtio-disk0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu'/>
|
||||||
|
<target dev='hdc' bus='sata'/>
|
||||||
|
<readonly/>
|
||||||
|
<alias name='sata0-0-2'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
|
||||||
|
<alias name='usb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<alias name='ide'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'>
|
||||||
|
<alias name='pcie.0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='1' port='0x8'/>
|
||||||
|
<alias name='pci.1'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pcie-to-pci-bridge'>
|
||||||
|
<model name='pcie-pci-bridge'/>
|
||||||
|
<alias name='pci.2'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='3' port='0x9'/>
|
||||||
|
<alias name='pci.3'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='4' port='0xa'/>
|
||||||
|
<alias name='pci.4'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='5' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='5' port='0xb'/>
|
||||||
|
<alias name='pci.5'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='6' port='0xc'/>
|
||||||
|
<alias name='pci.6'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='7' port='0xd'/>
|
||||||
|
<alias name='pci.7'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='8' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='8' port='0xe'/>
|
||||||
|
<alias name='pci.8'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='9' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='9' port='0xf'/>
|
||||||
|
<alias name='pci.9'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='10' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='10' port='0x10'/>
|
||||||
|
<alias name='pci.10'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='11' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='11' port='0x11'/>
|
||||||
|
<alias name='pci.11'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='12' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='12' port='0x12'/>
|
||||||
|
<alias name='pci.12'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='13' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='13' port='0x13'/>
|
||||||
|
<alias name='pci.13'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='14' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='14' port='0x14'/>
|
||||||
|
<alias name='pci.14'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='15' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='15' port='0x15'/>
|
||||||
|
<alias name='pci.15'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='16' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='16' port='0x16'/>
|
||||||
|
<alias name='pci.16'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<alias name='virtio-serial0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ccid' index='0'>
|
||||||
|
<alias name='ccid0'/>
|
||||||
|
<address type='usb' bus='0' port='1'/>
|
||||||
|
</controller>
|
||||||
|
<filesystem type='mount' accessmode='passthrough'>
|
||||||
|
<driver type='virtiofs'/>
|
||||||
|
<binary path='/usr/libexec/virtiofsd'/>
|
||||||
|
<source dir='/media'/>
|
||||||
|
<target dir='Media'/>
|
||||||
|
<alias name='fs0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
|
||||||
|
</filesystem>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:cd:dd:2d'/>
|
||||||
|
<source bridge='bridge0'/>
|
||||||
|
<target dev='vnet0'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<alias name='net0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0e' slot='0x00' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<input type='tablet' bus='usb'>
|
||||||
|
<alias name='input0'/>
|
||||||
|
<address type='usb' bus='0' port='2'/>
|
||||||
|
</input>
|
||||||
|
<input type='mouse' bus='ps2'>
|
||||||
|
<alias name='input1'/>
|
||||||
|
</input>
|
||||||
|
<input type='keyboard' bus='ps2'>
|
||||||
|
<alias name='input2'/>
|
||||||
|
</input>
|
||||||
|
<tpm model='tpm-tis'>
|
||||||
|
<backend type='emulator' version='2.0'/>
|
||||||
|
<alias name='tpm0'/>
|
||||||
|
</tpm>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev1'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev2'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x10' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev3'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0b' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev4'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0f' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='usb' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<vendor id='0x1462'/>
|
||||||
|
<product id='0x7c75'/>
|
||||||
|
<address bus='1' device='3'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev5'/>
|
||||||
|
<address type='usb' bus='0' port='3'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<driver name='vfio'/>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<alias name='hostdev6'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0c' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<alias name='balloon0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
<seclabel type='dynamic' model='selinux' relabel='yes'>
|
||||||
|
<label>system_u:system_r:svirt_t:s0:c399,c880</label>
|
||||||
|
<imagelabel>system_u:object_r:svirt_image_t:s0:c399,c880</imagelabel>
|
||||||
|
</seclabel>
|
||||||
|
<seclabel type='dynamic' model='dac' relabel='yes'>
|
||||||
|
<label>+107:+107</label>
|
||||||
|
<imagelabel>+107:+107</imagelabel>
|
||||||
|
</seclabel>
|
||||||
|
</domain>
|
||||||
|
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
<domain type='kvm'>
|
||||||
|
<name>windows-11</name>
|
||||||
|
<uuid>51d5d091-67cb-4113-bd8e-817e7317e1b4</uuid>
|
||||||
|
<title>Microsoft Windows 11</title>
|
||||||
|
<memory unit='KiB'>25165824</memory>
|
||||||
|
<currentMemory unit='KiB'>25165824</currentMemory>
|
||||||
|
<memoryBacking>
|
||||||
|
<hugepages/>
|
||||||
|
<source type='memfd'/>
|
||||||
|
<access mode='shared'/>
|
||||||
|
</memoryBacking>
|
||||||
|
<vcpu placement='static'>8</vcpu>
|
||||||
|
<cputune>
|
||||||
|
<vcpupin vcpu='0' cpuset='2'/>
|
||||||
|
<vcpupin vcpu='1' cpuset='8'/>
|
||||||
|
<vcpupin vcpu='2' cpuset='3'/>
|
||||||
|
<vcpupin vcpu='3' cpuset='9'/>
|
||||||
|
<vcpupin vcpu='4' cpuset='4'/>
|
||||||
|
<vcpupin vcpu='5' cpuset='10'/>
|
||||||
|
<vcpupin vcpu='6' cpuset='5'/>
|
||||||
|
<vcpupin vcpu='7' cpuset='11'/>
|
||||||
|
<emulatorpin cpuset='0,6'/>
|
||||||
|
</cputune>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
|
||||||
|
<loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
|
||||||
|
<nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/windows-11_VARS.fd</nvram>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
<bootmenu enable='no'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<hyperv mode='custom'>
|
||||||
|
<relaxed state='on'/>
|
||||||
|
<vapic state='on'/>
|
||||||
|
<spinlocks state='on' retries='8191'/>
|
||||||
|
<vendor_id state='on' value='whatever'/>
|
||||||
|
</hyperv>
|
||||||
|
<kvm>
|
||||||
|
<hidden state='on'/>
|
||||||
|
</kvm>
|
||||||
|
<smm state='on'/>
|
||||||
|
</features>
|
||||||
|
<cpu mode='host-passthrough' check='none' migratable='on'>
|
||||||
|
<topology sockets='1' dies='1' cores='4' threads='2'/>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='localtime'>
|
||||||
|
<timer name='rtc' tickpolicy='catchup'/>
|
||||||
|
<timer name='pit' tickpolicy='delay'/>
|
||||||
|
<timer name='hpet' present='no'/>
|
||||||
|
<timer name='kvmclock' present='yes'/>
|
||||||
|
<timer name='hypervclock' present='yes'/>
|
||||||
|
</clock>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<pm>
|
||||||
|
<suspend-to-mem enabled='no'/>
|
||||||
|
<suspend-to-disk enabled='no'/>
|
||||||
|
</pm>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='disk'>
|
||||||
|
<driver name='qemu' type='qcow2' cache='writeback'/>
|
||||||
|
<source file='/var/lib/libvirt/images/windows-11.qcow2'/>
|
||||||
|
<backingStore/>
|
||||||
|
<target dev='sda' bus='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<source dev='/dev/nvme0n1'/>
|
||||||
|
<target dev='sdb' bus='virtio'/>
|
||||||
|
</disk>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw'/>
|
||||||
|
<target dev='hdc' bus='sata'/>
|
||||||
|
<readonly/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='1' port='0x8'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pcie-to-pci-bridge'>
|
||||||
|
<model name='pcie-pci-bridge'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='3' port='0x9'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='4' port='0xa'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='5' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='5' port='0xb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='6' port='0xc'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='7' port='0xd'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='8' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='8' port='0xe'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='9' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='9' port='0xf'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='10' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='10' port='0x10'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='11' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='11' port='0x11'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='12' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='12' port='0x12'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='13' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='13' port='0x13'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='14' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='14' port='0x14'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='15' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='15' port='0x15'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='16' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='16' port='0x16'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ccid' index='0'>
|
||||||
|
<address type='usb' bus='0' port='1'/>
|
||||||
|
</controller>
|
||||||
|
<filesystem type='mount' accessmode='passthrough'>
|
||||||
|
<driver type='virtiofs'/>
|
||||||
|
<source dir='/media'/>
|
||||||
|
<target dir='Media'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
|
||||||
|
</filesystem>
|
||||||
|
<interface type='bridge'>
|
||||||
|
<mac address='52:54:00:cd:dd:2d'/>
|
||||||
|
<source bridge='bridge0'/>
|
||||||
|
<model type='virtio'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0e' slot='0x00' function='0x0'/>
|
||||||
|
</interface>
|
||||||
|
<input type='tablet' bus='usb'>
|
||||||
|
<address type='usb' bus='0' port='2'/>
|
||||||
|
</input>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<tpm model='tpm-tis'>
|
||||||
|
<backend type='emulator' version='2.0'/>
|
||||||
|
</tpm>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='off'>
|
||||||
|
<source>
|
||||||
|
<address uuid='5abeb24f-d6f4-4666-b495-303f15b05723'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x10' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0b' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
|
<source>
|
||||||
|
<address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
|
||||||
|
</source>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x0f' slot='0x00' function='0x0'/>
|
||||||
|
</hostdev>
|
||||||
|
<memballoon model='virtio'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
|
||||||
|
</memballoon>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -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.")
|
||||||
Reference in New Issue
Block a user