diff --git a/base.conf.tmpl b/base.conf.tmpl index ae01a69..e5ab02d 100644 --- a/base.conf.tmpl +++ b/base.conf.tmpl @@ -1,4 +1,3 @@ --name qemu-vm,debug-threads=on -boot order=dc -machine type=q35,accel=kvm,kernel_irqchip=on -smp $NUM_THREADS,sockets=1,cores=$NUM_PROCESSORS,threads=$NUM_THREADS_PER_CORE diff --git a/config.conf b/config.conf index 1966def..a710819 100755 --- a/config.conf +++ b/config.conf @@ -1,3 +1,5 @@ #!/usr/bin/env bash +export PIDFILE=/run/qemu_ex.pid +export MONITOR=/tmp/qemu_ex.sock export NUM_PROCESSORS=4 diff --git a/hardware.conf.tmpl b/hardware.conf.tmpl index 8b08e0f..3922358 100644 --- a/hardware.conf.tmpl +++ b/hardware.conf.tmpl @@ -1,7 +1,3 @@ --device usb-host,hostbus=1,hostport=6.1 --device usb-host,hostbus=1,hostport=6.2 --device usb-host,hostbus=1,hostport=6.3 --device usb-host,hostbus=1,hostport=6.4 -device vfio-pci,host=$GPU_ID,multifunction=on,id=gpu,romfile=$GPU_ROM -device vfio-pci,host=$AUDIO_ID,id=audio -object input-linux,id=kbd11,evdev=/dev/input/by-id/usb-Wooting_WootingTwo_WOOT_001_A01B1852W021H00067-event-if04 diff --git a/start b/start index a5c81e1..0f6bd13 100755 --- a/start +++ b/start @@ -130,16 +130,50 @@ read -ra default_arguments -d '' < "$o_default_path" || true read -ra hardware_arguments -d '' < "$o_hardware_path" || true read -ra specific_arguments -d '' < "$o_specific_path" || true -# append or true to reverse network changes -$DEBUG $SUDO nice --adjustment=-20 taskset --cpu-list "$(./cpus compute_vm "$NUM_PROCESSORS")" \ - qemu-system-x86_64 \ - -name "$VMNAME,process=VMNAME" \ +# preven host from using vm cpus + +$SUDO qemu-system-x86_64 \ + -name "$VMNAME,process=VMNAME,debug-threads=on" \ + -daemonize -pidfile "$PIDFILE" \ + -monitor unix:"$MONITOR",server,nowait \ -drive if=pflash,format=raw,readonly=on,file="$EFI_FIRMWARE" \ -drive if=pflash,format=raw,file="$EFI_VARS" \ "${base_arguments[@]}" \ "${default_arguments[@]}" \ "${hardware_arguments[@]}" \ "${specific_arguments[@]}" || true +$SUDO cat "$PIDFILE" +$SUDO qemu-affinity \ + -k $(./cpus decompress_seq "$(./cpus compute_vm $NUM_PROCESSORS)") \ + -i *:$(./cpus compute_vm $NUM_PROCESSORS) \ + -- $($SUDO cat "$PIDFILE") + + +host_cpus="$(./cpus compute_host $NUM_PROCESSORS)" +# $SUDO systemctl set-property --runtime -- user.slice AllowedCPUs="$host_cpus" +# $SUDO systemctl set-property --runtime -- system.slice AllowedCPUs="$host_cpus" +# $SUDO systemctl set-property --runtime -- init.slice AllowedCPUs="$host_cpus" + +# undo_file=/tmp/vfio-isolate.undo.bin +# vfio-isolate \ +# -u "$undo_file" \ +# drop-caches \ +# cpuset-modify --cpus C$host_cpus /system.slice \ +# cpuset-modify --cpus C$host_cpus /user.slice + +while [ -f "$PIDFILE" ]; do + sleep 1 +done + +host_cpus="$(./cpus compute_all)" +# vfio-isolate \ +# restore "$undo_file" +# $SUDO systemctl set-property --runtime -- user.slice AllowedCPUs="$host_cpus" +# $SUDO systemctl set-property --runtime -- system.slice AllowedCPUs="$host_cpus" +# $SUDO systemctl set-property --runtime -- init.slice AllowedCPUs="$host_cpus" + +# to power down the machine +# echo system_powerdown | socat - UNIX-CONNECT:"$MONITOR" NET_CONF_FILE="$NET_CONF_FILE" $SUDO --preserve-env=NET_CONF_FILE \ ./net delete