Merge pull request 'clan-vm-manager: Added clan icon to trayicon' (#855) from Qubasa-main into main
This commit is contained in:
@@ -18,17 +18,23 @@ log = logging.getLogger(__name__)
|
||||
|
||||
class VMAttr:
|
||||
def __init__(self, state_dir: Path) -> None:
|
||||
# These sockets here are just symlinks to the real sockets which
|
||||
# are created by the run.py file. The reason being that we run into
|
||||
# file path length issues on Linux. If no qemu process is running
|
||||
# the symlink will be dangling.
|
||||
self._qmp_socket: Path = state_dir / "qmp.sock"
|
||||
self._qga_socket: Path = state_dir / "qga.sock"
|
||||
self._qmp: QEMUMonitorProtocol | None = None
|
||||
|
||||
@contextmanager
|
||||
def qmp(self) -> Generator[QEMUMonitorProtocol, None, None]:
|
||||
def qmp_ctx(self) -> Generator[QEMUMonitorProtocol, None, None]:
|
||||
if self._qmp is None:
|
||||
log.debug(f"qmp_socket: {self._qmp_socket}")
|
||||
rpath = self._qmp_socket.resolve()
|
||||
if not rpath.exists():
|
||||
raise ClanError(f"qmp socket {rpath} does not exist")
|
||||
raise ClanError(
|
||||
f"qmp socket {rpath} does not exist. Is the VM running?"
|
||||
)
|
||||
self._qmp = QEMUMonitorProtocol(str(rpath))
|
||||
self._qmp.connect()
|
||||
try:
|
||||
|
||||
@@ -37,7 +37,7 @@ def facts_to_nixos_config(facts: dict[str, dict[str, bytes]]) -> dict:
|
||||
|
||||
# TODO move this to the Machines class
|
||||
def build_vm(
|
||||
machine: Machine, vm: VmConfig, tmpdir: Path, nix_options: list[str]
|
||||
machine: Machine, vm: VmConfig, tmpdir: Path, nix_options: list[str] = []
|
||||
) -> dict[str, str]:
|
||||
secrets_dir = get_secrets(machine, tmpdir)
|
||||
|
||||
|
||||
@@ -43,7 +43,9 @@ def wait_vm_up(state_dir: Path) -> None:
|
||||
timeout: float = 300
|
||||
while True:
|
||||
if timeout <= 0:
|
||||
raise TimeoutError(f"qga socket {socket_file} not found")
|
||||
raise TimeoutError(
|
||||
f"qga socket {socket_file} not found. Is the VM running?"
|
||||
)
|
||||
if socket_file.exists():
|
||||
break
|
||||
sleep(0.1)
|
||||
@@ -56,7 +58,9 @@ def wait_vm_down(state_dir: Path) -> None:
|
||||
timeout: float = 300
|
||||
while socket_file.exists():
|
||||
if timeout <= 0:
|
||||
raise TimeoutError(f"qga socket {socket_file} still exists")
|
||||
raise TimeoutError(
|
||||
f"qga socket {socket_file} still exists. Is the VM down?"
|
||||
)
|
||||
sleep(0.1)
|
||||
timeout -= 0.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user