vms: init graceful shutdown for GUI

- add python modules for qemu protocols: QMP (hardware interactions) and QGA (guest service interaction)
- refactor state directory: remove name from path (already contains url)
- add impure vm test for basic qmp interaction
- simplify existing vm persistance test (factor out shared code)
- integrate graceful shutdown into GUI

the GUI integration still needs to be improved later:
- add fallback in case system doesn't react to powerdown button
- shutdown GUI switch fails if VM hasn't been started yet, and then remains in a wrong position
This commit is contained in:
DavHau
2024-02-09 19:46:32 +07:00
parent 20235ee09b
commit a438a27c69
12 changed files with 186 additions and 93 deletions

View File

@@ -159,8 +159,7 @@ def get_vm_create_info(
f'{clan_dir}#clanInternals.machines."{system}"."{machine.name}".config.system.clan.vm.create',
*nix_options,
],
machine_gcroot(clan_name=vm.clan_name, flake_url=str(vm.flake_url))
/ f"vm-{machine.name}",
machine_gcroot(flake_url=str(vm.flake_url)) / f"vm-{machine.name}",
)
proc = run(
cmd, log=Log.BOTH, error_msg=f"Could not build vm config for {machine.name}"
@@ -298,7 +297,7 @@ def run_vm(
secrets_dir = get_secrets(machine, tmpdir)
state_dir = vm_state_dir(vm.clan_name, str(vm.flake_url), machine.name)
state_dir = vm_state_dir(str(vm.flake_url), machine.name)
state_dir.mkdir(parents=True, exist_ok=True)
# specify socket files for qmp and qga