Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions linux/aux-tools/preload-dispvm
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,34 @@ def get_max(qube):


async def main():
domains = qubesadmin.Qubes().domains
app = qubesadmin.Qubes()
domains = app.domains
default_dispvm = getattr(app, "default_dispvm", None)
appvms = [
qube
for qube in domains
if get_max(qube) > 0
and qube.klass == "AppVM"
and getattr(qube, "template_for_dispvms", False)
and (
(
qube.klass == "AppVM"
and getattr(qube, "template_for_dispvms", False)
)
or (qube.name == "dom0" and default_dispvm)
)
]
method = "admin.vm.CreateDisposable"
loop = asyncio.get_running_loop()
tasks = []
if "dom0" in appvms and default_dispvm in appvms:
appvms.remove(default_dispvm)
with concurrent.futures.ThreadPoolExecutor() as executor:
for qube in appvms:
maximum = get_max(qube)
print(f"{qube}:{maximum}")
msg = f"{qube}:{maximum}"
if qube.name == "dom0":
qube = default_dispvm
msg = "global:" + msg
print(msg)
exec_args = qube.qubesd_call, qube.name, method, "preload-autostart"
future = loop.run_in_executor(executor, *exec_args)
tasks.append(future)
Expand Down
9 changes: 9 additions & 0 deletions qubes/tests/integ/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ def test_017_preload_autostart(self):
asyncio.wait_for(proc.communicate(), timeout=10)
)
self.assertEqual(self.disp_base.get_feat_preload(), [])

self.disp_base.features["preload-dispvm-max"] = str(preload_max)
self.loop.run_until_complete(self.wait_preload(preload_max))
old_preload = self.disp_base.get_feat_preload()
Expand All @@ -610,6 +611,14 @@ def test_017_preload_autostart(self):
set(old_preload).isdisjoint(preload_dispvm),
f"old_preload={old_preload} preload_dispvm={preload_dispvm}",
)

self.adminvm.features["preload-dispvm-max"] = "0"
self.loop.run_until_complete(self.wait_preload(preload_max))
proc = self.loop.run_until_complete(
asyncio.create_subprocess_exec("/usr/lib/qubes/preload-dispvm")
)
self.loop.run_until_complete(asyncio.wait_for(proc.wait(), timeout=30))
self.assertEqual(self.disp_base.get_feat_preload(), [])
logger.info("end")

def test_018_preload_global(self):
Expand Down