maqet 0.0.1.3__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. maqet/__init__.py +50 -6
  2. maqet/__main__.py +96 -0
  3. maqet/__version__.py +3 -0
  4. maqet/api/__init__.py +35 -0
  5. maqet/api/decorators.py +184 -0
  6. maqet/api/metadata.py +147 -0
  7. maqet/api/registry.py +182 -0
  8. maqet/cli.py +71 -0
  9. maqet/config/__init__.py +26 -0
  10. maqet/config/merger.py +237 -0
  11. maqet/config/parser.py +198 -0
  12. maqet/config/validators.py +519 -0
  13. maqet/config_handlers.py +684 -0
  14. maqet/constants.py +200 -0
  15. maqet/exceptions.py +226 -0
  16. maqet/formatters.py +294 -0
  17. maqet/generators/__init__.py +12 -0
  18. maqet/generators/base_generator.py +101 -0
  19. maqet/generators/cli_generator.py +635 -0
  20. maqet/generators/python_generator.py +247 -0
  21. maqet/generators/rest_generator.py +58 -0
  22. maqet/handlers/__init__.py +12 -0
  23. maqet/handlers/base.py +108 -0
  24. maqet/handlers/init.py +147 -0
  25. maqet/handlers/stage.py +196 -0
  26. maqet/ipc/__init__.py +29 -0
  27. maqet/ipc/retry.py +265 -0
  28. maqet/ipc/runner_client.py +285 -0
  29. maqet/ipc/unix_socket_server.py +239 -0
  30. maqet/logger.py +160 -55
  31. maqet/machine.py +884 -0
  32. maqet/managers/__init__.py +7 -0
  33. maqet/managers/qmp_manager.py +333 -0
  34. maqet/managers/snapshot_coordinator.py +327 -0
  35. maqet/managers/vm_manager.py +683 -0
  36. maqet/maqet.py +1120 -0
  37. maqet/os_interactions.py +46 -0
  38. maqet/process_spawner.py +395 -0
  39. maqet/qemu_args.py +76 -0
  40. maqet/qmp/__init__.py +10 -0
  41. maqet/qmp/commands.py +92 -0
  42. maqet/qmp/keyboard.py +311 -0
  43. maqet/qmp/qmp.py +17 -0
  44. maqet/snapshot.py +473 -0
  45. maqet/state.py +958 -0
  46. maqet/storage.py +702 -162
  47. maqet/validation/__init__.py +9 -0
  48. maqet/validation/config_validator.py +170 -0
  49. maqet/vm_runner.py +523 -0
  50. maqet-0.0.5.dist-info/METADATA +237 -0
  51. maqet-0.0.5.dist-info/RECORD +55 -0
  52. {maqet-0.0.1.3.dist-info → maqet-0.0.5.dist-info}/WHEEL +1 -1
  53. maqet-0.0.5.dist-info/entry_points.txt +2 -0
  54. maqet-0.0.5.dist-info/licenses/LICENSE +21 -0
  55. {maqet-0.0.1.3.dist-info → maqet-0.0.5.dist-info}/top_level.txt +0 -1
  56. maqet/core.py +0 -395
  57. maqet/functions.py +0 -104
  58. maqet-0.0.1.3.dist-info/METADATA +0 -104
  59. maqet-0.0.1.3.dist-info/RECORD +0 -33
  60. qemu/machine/__init__.py +0 -36
  61. qemu/machine/console_socket.py +0 -142
  62. qemu/machine/machine.py +0 -954
  63. qemu/machine/py.typed +0 -0
  64. qemu/machine/qtest.py +0 -191
  65. qemu/qmp/__init__.py +0 -59
  66. qemu/qmp/error.py +0 -50
  67. qemu/qmp/events.py +0 -717
  68. qemu/qmp/legacy.py +0 -319
  69. qemu/qmp/message.py +0 -209
  70. qemu/qmp/models.py +0 -146
  71. qemu/qmp/protocol.py +0 -1057
  72. qemu/qmp/py.typed +0 -0
  73. qemu/qmp/qmp_client.py +0 -655
  74. qemu/qmp/qmp_shell.py +0 -618
  75. qemu/qmp/qmp_tui.py +0 -655
  76. qemu/qmp/util.py +0 -219
  77. qemu/utils/__init__.py +0 -162
  78. qemu/utils/accel.py +0 -84
  79. qemu/utils/py.typed +0 -0
  80. qemu/utils/qemu_ga_client.py +0 -323
  81. qemu/utils/qom.py +0 -273
  82. qemu/utils/qom_common.py +0 -175
  83. qemu/utils/qom_fuse.py +0 -207
@@ -1,142 +0,0 @@
1
- """
2
- QEMU Console Socket Module:
3
-
4
- This python module implements a ConsoleSocket object,
5
- which can drain a socket and optionally dump the bytes to file.
6
- """
7
- # Copyright 2020 Linaro
8
- #
9
- # Authors:
10
- # Robert Foley <robert.foley@linaro.org>
11
- #
12
- # This code is licensed under the GPL version 2 or later. See
13
- # the COPYING file in the top-level directory.
14
- #
15
-
16
- from collections import deque
17
- import socket
18
- import threading
19
- import time
20
- from typing import Deque, Optional
21
-
22
-
23
- class ConsoleSocket(socket.socket):
24
- """
25
- ConsoleSocket represents a socket attached to a char device.
26
-
27
- :param address: An AF_UNIX path or address.
28
- :param sock_fd: Optionally, an existing socket file descriptor.
29
- One of address or sock_fd must be specified.
30
- :param file: Optionally, a filename to log to.
31
- :param drain: Optionally, drains the socket and places the bytes
32
- into an in memory buffer for later processing.
33
- """
34
- def __init__(self,
35
- address: Optional[str] = None,
36
- sock_fd: Optional[int] = None,
37
- file: Optional[str] = None,
38
- drain: bool = False):
39
- if address is None and sock_fd is None:
40
- raise ValueError("one of 'address' or 'sock_fd' must be specified")
41
- if address is not None and sock_fd is not None:
42
- raise ValueError("can't specify both 'address' and 'sock_fd'")
43
-
44
- self._recv_timeout_sec = 300.0
45
- self._sleep_time = 0.5
46
- self._buffer: Deque[int] = deque()
47
- if address is not None:
48
- socket.socket.__init__(self, socket.AF_UNIX, socket.SOCK_STREAM)
49
- self.connect(address)
50
- else:
51
- assert sock_fd is not None
52
- socket.socket.__init__(self, fileno=sock_fd)
53
- self._logfile = None
54
- if file:
55
- # pylint: disable=consider-using-with
56
- self._logfile = open(file, "bw")
57
- self._open = True
58
- self._drain_thread = None
59
- if drain:
60
- self._drain_thread = self._thread_start()
61
-
62
- def __repr__(self) -> str:
63
- tmp = super().__repr__()
64
- tmp = tmp.rstrip(">")
65
- tmp = "%s, logfile=%s, drain_thread=%s>" % (tmp, self._logfile,
66
- self._drain_thread)
67
- return tmp
68
-
69
- def _drain_fn(self) -> None:
70
- """Drains the socket and runs while the socket is open."""
71
- while self._open:
72
- try:
73
- self._drain_socket()
74
- except socket.timeout:
75
- # The socket is expected to timeout since we set a
76
- # short timeout to allow the thread to exit when
77
- # self._open is set to False.
78
- time.sleep(self._sleep_time)
79
-
80
- def _thread_start(self) -> threading.Thread:
81
- """Kick off a thread to drain the socket."""
82
- # Configure socket to not block and timeout.
83
- # This allows our drain thread to not block
84
- # on receive and exit smoothly.
85
- socket.socket.setblocking(self, False)
86
- socket.socket.settimeout(self, 1)
87
- drain_thread = threading.Thread(target=self._drain_fn)
88
- drain_thread.daemon = True
89
- drain_thread.start()
90
- return drain_thread
91
-
92
- def close(self) -> None:
93
- """Close the base object and wait for the thread to terminate"""
94
- if self._open:
95
- self._open = False
96
- if self._drain_thread is not None:
97
- thread, self._drain_thread = self._drain_thread, None
98
- thread.join()
99
- socket.socket.close(self)
100
- if self._logfile:
101
- self._logfile.close()
102
- self._logfile = None
103
-
104
- def _drain_socket(self) -> None:
105
- """process arriving characters into in memory _buffer"""
106
- data = socket.socket.recv(self, 1)
107
- if self._logfile:
108
- self._logfile.write(data)
109
- self._logfile.flush()
110
- self._buffer.extend(data)
111
-
112
- def recv(self, bufsize: int = 1, flags: int = 0) -> bytes:
113
- """Return chars from in memory buffer.
114
- Maintains the same API as socket.socket.recv.
115
- """
116
- if self._drain_thread is None:
117
- # Not buffering the socket, pass thru to socket.
118
- return socket.socket.recv(self, bufsize, flags)
119
- assert not flags, "Cannot pass flags to recv() in drained mode"
120
- start_time = time.time()
121
- while len(self._buffer) < bufsize:
122
- time.sleep(self._sleep_time)
123
- elapsed_sec = time.time() - start_time
124
- if elapsed_sec > self._recv_timeout_sec:
125
- raise socket.timeout
126
- return bytes((self._buffer.popleft() for i in range(bufsize)))
127
-
128
- def setblocking(self, value: bool) -> None:
129
- """When not draining we pass thru to the socket,
130
- since when draining we control socket blocking.
131
- """
132
- if self._drain_thread is None:
133
- socket.socket.setblocking(self, value)
134
-
135
- def settimeout(self, value: Optional[float]) -> None:
136
- """When not draining we pass thru to the socket,
137
- since when draining we control the timeout.
138
- """
139
- if value is not None:
140
- self._recv_timeout_sec = value
141
- if self._drain_thread is None:
142
- socket.socket.settimeout(self, value)