Atrate
August 29, 2025, 9:03pm
1
Hello everyone!
Posting another one of my scripts that I use to make Qubes snappier and more usable interactively
This one makes makes use of the credit2-weight feature to automatically set credit2 scheduler weight (scheduling priority) for VMs.
Enjoy! And thanks to @noskb and @anon40243023 for providing the idea for the Admin Events approach.
Automatically set Xen credit2 scheduling parameters for Qubes
6 Likes
solene
September 23, 2025, 8:37pm
2
This works quite well, thanks!
I have proposition for more universal script, that modifies xen scheduler weight of any xen scheduler:
#!/usr/bin/env python3
# auto-xen-weight.py script to automatically modify default
# Xen Scheduler weight for any qube with `xen-sched-weight`
# feature for any Xen Scheduler
import asyncio
import subprocess
import qubesadmin
import qubesadmin.events
feat_sched = "xen-sched-weight"
sched_check = [ 'xl', 'info', 'xen_scheduler' ]
def capture_os_cmd(cmd):
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
output, _ = proc.communicate()
return output.decode().strip()
def _sched_weight(sched, name, weight):
cmd = ['xl', 'sched-'+sched, '-d', name, '-w', weight]
subprocess.run(cmd).check_returncode()
def sched_by_feat(vm, event, **kwargs):
vm = app.domains[str(vm)]
sched = capture_os_cmd(sched_check)
if feat_sched in list(vm.features):
try:
weight = int(vm.features[feat_sched])
_sched_weight(sched, vm.name, str(weight))
print(f'Set {vm.name}\'s {sched} weight to {weight}')
except:
pass
sched = capture_os_cmd(sched_check)
_sched_weight(sched, "Domain-0", "2048")
app = qubesadmin.Qubes()
dispatcher = qubesadmin.events.EventsDispatcher(app)
dispatcher.add_handler('domain-start', sched_by_feat)
asyncio.run(dispatcher.listen_for_events())
PS: @Atrate look at your github - ther’s more to that but I don’t want to spam it here on forum
1 Like
Atrate
July 21, 2026, 10:21pm
4
I forgot to announce it in this thread, but the script now (since 3 weeks ago) also handles -dm domains automatically.
I’m also working on a fix to a weird bug (race condition?) that caused domains sometimes not to be adjusted correctly. I’ve deployed the fix locally and I’m testing it, will update the repo and this thread once it’s confirmed that it works.
1 Like
Atrate
July 22, 2026, 7:20pm
5
Update: I’ve fixed a bug that caused some domains not to get their priorities adjusted correctly, some of the time. The update is live on Github.