Ok yes i understand now. So assigning 8 cores but being able to scale those back on the start of another vm. Thats a very interesting idea and i didnt know that was possible. It would certainly be very useful. I had a similar idea a while back about isolcpus capability post-boot to be able to isolate and release cpus to the host without reboot. Having spoken to limetech this is something they have been investigating but it isnt in Linux's capability set and as such would be only be possible manually manipulating some things in the user space for this but it isnt something they are currently working on.
So yes any info on how to implement what you are talking about here would be most welcome.
I finally found some time to implement this for myself using python
https://gist.github.com/patrickjahns/cfa90a39883206e18fdaccfd9d2809f0
It can either be used via command line, or imported into other scripts.
The class is provided with different profiles (defined as json) and allows for switching between them.
When switching the profile, the previous configuration is saved to a json file and can be easily restored.
Examples
1) python vcpu.py --vcpumap vcpumap.json --profile default --ignored_domains ['pandora']
2) python vcpu.py --vcpumap vcpumap.json --restore --ignored_domains ['pandora']
In example 1) the profile default is applied to all vms except the vm pandora
In example 2) the previous configuration is restored
vcpumap.json
{"profilename": {
"default": [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],
"vm1": {"all": [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]},
"vm2": {
"0": [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],
"1": [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
}
}
}
The json allows for creating profiles , each profile has a "default" configuration for all vcpus. It can also contain profiles per vm (vm1, vm2). With these you defined either a pinning for all ("all") vcpus, or per vcpu (see vm2).
This should be quite flexible and help anyone else with doing this.
My setup:
Several VMS + 1 "GamestreamingVm" (uses nvidia gamestreaming)
I use a flask application providing an url (http://ip/switchprofile/profile) to switch between defined profiles.
Whenever my shield (or moonlight) connects, a AutoHotkey script on the gaming vm detects that "nvstreamer.exe" is running and calls http://ip/switchprofile/gaming and thus loads the gaming profile. The scripts also recognizes disconnects ("nvstreamer.exe is not running") and calls http://ip/restoreprofile, to restore previous configurations