Guest User

Untitled

a guest
Dec 5th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.02 KB | Software | 0 0
  1. #!/bin/bash
  2. #/etc/libvirt/hooks/qemu
  3.  
  4. HCPUS=8-15,24-31
  5. MCPUS=0-7,16-23
  6. ACPUS=0-31
  7.  
  8. disable_isolation () {
  9.             systemctl set-property --runtime -- user.slice AllowedCPUs=$ACPUS
  10.             systemctl set-property --runtime -- system.slice AllowedCPUs=$ACPUS
  11.             systemctl set-property --runtime -- init.scope AllowedCPUs=$ACPUS
  12.  
  13.             taskset -pc $ACPUS 2  # kthreadd reset
  14. }
  15.  
  16. enable_isolation () {
  17.             systemctl set-property --runtime -- user.slice AllowedCPUs=$HCPUS
  18.             systemctl set-property --runtime -- system.slice AllowedCPUs=$HCPUS
  19.             systemctl set-property --runtime -- init.scope AllowedCPUs=$HCPUS
  20.  
  21.             irq-affinity mask $MCPUS
  22.  
  23.             taskset -pc $MCPUS 2  # kthreadd only on host cores
  24. }
  25.  
  26. case "$2" in
  27. "prepare")
  28.         enable_isolation
  29.         echo "prepared" >> /home/username/qemu_hook.log
  30.         ;;
  31. "started")
  32.         echo "started" >> /home/username/qemu_hook.log
  33.         ;;
  34. "release")
  35.         disable_isolation
  36.         echo "released" >> /home/username/qemu_hook.log
  37.         ;;
  38. esac
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment