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.
- maqet/__init__.py +50 -6
- maqet/__main__.py +96 -0
- maqet/__version__.py +3 -0
- maqet/api/__init__.py +35 -0
- maqet/api/decorators.py +184 -0
- maqet/api/metadata.py +147 -0
- maqet/api/registry.py +182 -0
- maqet/cli.py +71 -0
- maqet/config/__init__.py +26 -0
- maqet/config/merger.py +237 -0
- maqet/config/parser.py +198 -0
- maqet/config/validators.py +519 -0
- maqet/config_handlers.py +684 -0
- maqet/constants.py +200 -0
- maqet/exceptions.py +226 -0
- maqet/formatters.py +294 -0
- maqet/generators/__init__.py +12 -0
- maqet/generators/base_generator.py +101 -0
- maqet/generators/cli_generator.py +635 -0
- maqet/generators/python_generator.py +247 -0
- maqet/generators/rest_generator.py +58 -0
- maqet/handlers/__init__.py +12 -0
- maqet/handlers/base.py +108 -0
- maqet/handlers/init.py +147 -0
- maqet/handlers/stage.py +196 -0
- maqet/ipc/__init__.py +29 -0
- maqet/ipc/retry.py +265 -0
- maqet/ipc/runner_client.py +285 -0
- maqet/ipc/unix_socket_server.py +239 -0
- maqet/logger.py +160 -55
- maqet/machine.py +884 -0
- maqet/managers/__init__.py +7 -0
- maqet/managers/qmp_manager.py +333 -0
- maqet/managers/snapshot_coordinator.py +327 -0
- maqet/managers/vm_manager.py +683 -0
- maqet/maqet.py +1120 -0
- maqet/os_interactions.py +46 -0
- maqet/process_spawner.py +395 -0
- maqet/qemu_args.py +76 -0
- maqet/qmp/__init__.py +10 -0
- maqet/qmp/commands.py +92 -0
- maqet/qmp/keyboard.py +311 -0
- maqet/qmp/qmp.py +17 -0
- maqet/snapshot.py +473 -0
- maqet/state.py +958 -0
- maqet/storage.py +702 -162
- maqet/validation/__init__.py +9 -0
- maqet/validation/config_validator.py +170 -0
- maqet/vm_runner.py +523 -0
- maqet-0.0.5.dist-info/METADATA +237 -0
- maqet-0.0.5.dist-info/RECORD +55 -0
- {maqet-0.0.1.3.dist-info → maqet-0.0.5.dist-info}/WHEEL +1 -1
- maqet-0.0.5.dist-info/entry_points.txt +2 -0
- maqet-0.0.5.dist-info/licenses/LICENSE +21 -0
- {maqet-0.0.1.3.dist-info → maqet-0.0.5.dist-info}/top_level.txt +0 -1
- maqet/core.py +0 -395
- maqet/functions.py +0 -104
- maqet-0.0.1.3.dist-info/METADATA +0 -104
- maqet-0.0.1.3.dist-info/RECORD +0 -33
- qemu/machine/__init__.py +0 -36
- qemu/machine/console_socket.py +0 -142
- qemu/machine/machine.py +0 -954
- qemu/machine/py.typed +0 -0
- qemu/machine/qtest.py +0 -191
- qemu/qmp/__init__.py +0 -59
- qemu/qmp/error.py +0 -50
- qemu/qmp/events.py +0 -717
- qemu/qmp/legacy.py +0 -319
- qemu/qmp/message.py +0 -209
- qemu/qmp/models.py +0 -146
- qemu/qmp/protocol.py +0 -1057
- qemu/qmp/py.typed +0 -0
- qemu/qmp/qmp_client.py +0 -655
- qemu/qmp/qmp_shell.py +0 -618
- qemu/qmp/qmp_tui.py +0 -655
- qemu/qmp/util.py +0 -219
- qemu/utils/__init__.py +0 -162
- qemu/utils/accel.py +0 -84
- qemu/utils/py.typed +0 -0
- qemu/utils/qemu_ga_client.py +0 -323
- qemu/utils/qom.py +0 -273
- qemu/utils/qom_common.py +0 -175
- qemu/utils/qom_fuse.py +0 -207
qemu/machine/py.typed
DELETED
File without changes
|
qemu/machine/qtest.py
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
QEMU qtest library
|
3
|
-
|
4
|
-
qtest offers the QEMUQtestProtocol and QEMUQTestMachine classes, which
|
5
|
-
offer a connection to QEMU's qtest protocol socket, and a qtest-enabled
|
6
|
-
subclass of QEMUMachine, respectively.
|
7
|
-
"""
|
8
|
-
|
9
|
-
# Copyright (C) 2015 Red Hat Inc.
|
10
|
-
#
|
11
|
-
# Authors:
|
12
|
-
# Fam Zheng <famz@redhat.com>
|
13
|
-
#
|
14
|
-
# This work is licensed under the terms of the GNU GPL, version 2. See
|
15
|
-
# the COPYING file in the top-level directory.
|
16
|
-
#
|
17
|
-
# Based on qmp.py.
|
18
|
-
#
|
19
|
-
|
20
|
-
import os
|
21
|
-
import socket
|
22
|
-
from typing import (
|
23
|
-
List,
|
24
|
-
Optional,
|
25
|
-
Sequence,
|
26
|
-
TextIO,
|
27
|
-
Tuple,
|
28
|
-
)
|
29
|
-
|
30
|
-
from qemu.qmp import SocketAddrT
|
31
|
-
|
32
|
-
from .machine import QEMUMachine
|
33
|
-
|
34
|
-
|
35
|
-
class QEMUQtestProtocol:
|
36
|
-
"""
|
37
|
-
QEMUQtestProtocol implements a connection to a qtest socket.
|
38
|
-
|
39
|
-
:param address: QEMU address, can be either a unix socket path (string)
|
40
|
-
or a tuple in the form ( address, port ) for a TCP
|
41
|
-
connection
|
42
|
-
:param sock: An existing socket can be provided as an alternative to
|
43
|
-
an address. One of address or sock must be provided.
|
44
|
-
:param server: server mode, listens on the socket. Only meaningful
|
45
|
-
in conjunction with an address and not an existing
|
46
|
-
socket.
|
47
|
-
|
48
|
-
:raise socket.error: on socket connection errors
|
49
|
-
|
50
|
-
.. note::
|
51
|
-
No connection is established by __init__(), this is done
|
52
|
-
by the connect() or accept() methods.
|
53
|
-
"""
|
54
|
-
def __init__(self,
|
55
|
-
address: Optional[SocketAddrT] = None,
|
56
|
-
sock: Optional[socket.socket] = None,
|
57
|
-
server: bool = False):
|
58
|
-
if address is None and sock is None:
|
59
|
-
raise ValueError("Either 'address' or 'sock' must be specified")
|
60
|
-
if address is not None and sock is not None:
|
61
|
-
raise ValueError(
|
62
|
-
"Either 'address' or 'sock' must be specified, but not both")
|
63
|
-
if sock is not None and server:
|
64
|
-
raise ValueError("server=True is meaningless when passing socket")
|
65
|
-
|
66
|
-
self._address = address
|
67
|
-
self._sock = sock or self._get_sock()
|
68
|
-
self._sockfile: Optional[TextIO] = None
|
69
|
-
|
70
|
-
if server:
|
71
|
-
assert self._address is not None
|
72
|
-
self._sock.bind(self._address)
|
73
|
-
self._sock.listen(1)
|
74
|
-
|
75
|
-
def _get_sock(self) -> socket.socket:
|
76
|
-
assert self._address is not None
|
77
|
-
if isinstance(self._address, tuple):
|
78
|
-
family = socket.AF_INET
|
79
|
-
else:
|
80
|
-
family = socket.AF_UNIX
|
81
|
-
return socket.socket(family, socket.SOCK_STREAM)
|
82
|
-
|
83
|
-
def connect(self) -> None:
|
84
|
-
"""
|
85
|
-
Connect to the qtest socket.
|
86
|
-
|
87
|
-
@raise socket.error on socket connection errors
|
88
|
-
"""
|
89
|
-
if self._address is not None:
|
90
|
-
self._sock.connect(self._address)
|
91
|
-
self._sockfile = self._sock.makefile(mode='r')
|
92
|
-
|
93
|
-
def accept(self) -> None:
|
94
|
-
"""
|
95
|
-
Await connection from QEMU.
|
96
|
-
|
97
|
-
@raise socket.error on socket connection errors
|
98
|
-
"""
|
99
|
-
self._sock, _ = self._sock.accept()
|
100
|
-
self._sockfile = self._sock.makefile(mode='r')
|
101
|
-
|
102
|
-
def cmd(self, qtest_cmd: str) -> str:
|
103
|
-
"""
|
104
|
-
Send a qtest command on the wire.
|
105
|
-
|
106
|
-
@param qtest_cmd: qtest command text to be sent
|
107
|
-
"""
|
108
|
-
assert self._sockfile is not None
|
109
|
-
self._sock.sendall((qtest_cmd + "\n").encode('utf-8'))
|
110
|
-
resp = self._sockfile.readline()
|
111
|
-
return resp
|
112
|
-
|
113
|
-
def close(self) -> None:
|
114
|
-
"""
|
115
|
-
Close this socket.
|
116
|
-
"""
|
117
|
-
self._sock.close()
|
118
|
-
if self._sockfile:
|
119
|
-
self._sockfile.close()
|
120
|
-
self._sockfile = None
|
121
|
-
|
122
|
-
def settimeout(self, timeout: Optional[float]) -> None:
|
123
|
-
"""Set a timeout, in seconds."""
|
124
|
-
self._sock.settimeout(timeout)
|
125
|
-
|
126
|
-
|
127
|
-
class QEMUQtestMachine(QEMUMachine):
|
128
|
-
"""
|
129
|
-
A QEMU VM, with a qtest socket available.
|
130
|
-
"""
|
131
|
-
|
132
|
-
def __init__(self,
|
133
|
-
binary: str,
|
134
|
-
args: Sequence[str] = (),
|
135
|
-
wrapper: Sequence[str] = (),
|
136
|
-
name: Optional[str] = None,
|
137
|
-
base_temp_dir: str = "/var/tmp",
|
138
|
-
qmp_timer: Optional[float] = None):
|
139
|
-
# pylint: disable=too-many-arguments
|
140
|
-
|
141
|
-
if name is None:
|
142
|
-
name = "qemu-%d" % os.getpid()
|
143
|
-
super().__init__(binary, args, wrapper=wrapper, name=name,
|
144
|
-
base_temp_dir=base_temp_dir,
|
145
|
-
qmp_timer=qmp_timer)
|
146
|
-
self._qtest: Optional[QEMUQtestProtocol] = None
|
147
|
-
self._qtest_sock_pair: Optional[
|
148
|
-
Tuple[socket.socket, socket.socket]] = None
|
149
|
-
|
150
|
-
@property
|
151
|
-
def _base_args(self) -> List[str]:
|
152
|
-
args = super()._base_args
|
153
|
-
assert self._qtest_sock_pair is not None
|
154
|
-
fd = self._qtest_sock_pair[0].fileno()
|
155
|
-
args.extend([
|
156
|
-
'-chardev', f"socket,id=qtest,fd={fd}",
|
157
|
-
'-qtest', 'chardev:qtest',
|
158
|
-
'-accel', 'qtest'
|
159
|
-
])
|
160
|
-
return args
|
161
|
-
|
162
|
-
def _pre_launch(self) -> None:
|
163
|
-
self._qtest_sock_pair = socket.socketpair()
|
164
|
-
os.set_inheritable(self._qtest_sock_pair[0].fileno(), True)
|
165
|
-
super()._pre_launch()
|
166
|
-
self._qtest = QEMUQtestProtocol(sock=self._qtest_sock_pair[1])
|
167
|
-
|
168
|
-
def _post_launch(self) -> None:
|
169
|
-
assert self._qtest is not None
|
170
|
-
super()._post_launch()
|
171
|
-
if self._qtest_sock_pair:
|
172
|
-
self._qtest_sock_pair[0].close()
|
173
|
-
self._qtest.connect()
|
174
|
-
|
175
|
-
def _post_shutdown(self) -> None:
|
176
|
-
if self._qtest_sock_pair:
|
177
|
-
self._qtest_sock_pair[0].close()
|
178
|
-
self._qtest_sock_pair[1].close()
|
179
|
-
self._qtest_sock_pair = None
|
180
|
-
super()._post_shutdown()
|
181
|
-
|
182
|
-
def qtest(self, cmd: str) -> str:
|
183
|
-
"""
|
184
|
-
Send a qtest command to the guest.
|
185
|
-
|
186
|
-
:param cmd: qtest command to send
|
187
|
-
:return: qtest server response
|
188
|
-
"""
|
189
|
-
if self._qtest is None:
|
190
|
-
raise RuntimeError("qtest socket not available")
|
191
|
-
return self._qtest.cmd(cmd)
|
qemu/qmp/__init__.py
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
QEMU Monitor Protocol (QMP) development library & tooling.
|
3
|
-
|
4
|
-
This package provides a fairly low-level class for communicating
|
5
|
-
asynchronously with QMP protocol servers, as implemented by QEMU, the
|
6
|
-
QEMU Guest Agent, and the QEMU Storage Daemon.
|
7
|
-
|
8
|
-
`QMPClient` provides the main functionality of this package. All errors
|
9
|
-
raised by this library derive from `QMPError`, see `qmp.error` for
|
10
|
-
additional detail. See `qmp.events` for an in-depth tutorial on
|
11
|
-
managing QMP events.
|
12
|
-
"""
|
13
|
-
|
14
|
-
# Copyright (C) 2020-2022 John Snow for Red Hat, Inc.
|
15
|
-
#
|
16
|
-
# Authors:
|
17
|
-
# John Snow <jsnow@redhat.com>
|
18
|
-
#
|
19
|
-
# Based on earlier work by Luiz Capitulino <lcapitulino@redhat.com>.
|
20
|
-
#
|
21
|
-
# This work is licensed under the terms of the GNU LGPL, version 2 or
|
22
|
-
# later. See the COPYING file in the top-level directory.
|
23
|
-
|
24
|
-
import logging
|
25
|
-
|
26
|
-
from .error import QMPError
|
27
|
-
from .events import EventListener
|
28
|
-
from .message import Message
|
29
|
-
from .protocol import (
|
30
|
-
ConnectError,
|
31
|
-
Runstate,
|
32
|
-
SocketAddrT,
|
33
|
-
StateError,
|
34
|
-
)
|
35
|
-
from .qmp_client import ExecInterruptedError, ExecuteError, QMPClient
|
36
|
-
|
37
|
-
|
38
|
-
# Suppress logging unless an application engages it.
|
39
|
-
logging.getLogger('qemu.qmp').addHandler(logging.NullHandler())
|
40
|
-
|
41
|
-
|
42
|
-
# The order of these fields impact the Sphinx documentation order.
|
43
|
-
__all__ = (
|
44
|
-
# Classes, most to least important
|
45
|
-
'QMPClient',
|
46
|
-
'Message',
|
47
|
-
'EventListener',
|
48
|
-
'Runstate',
|
49
|
-
|
50
|
-
# Exceptions, most generic to most explicit
|
51
|
-
'QMPError',
|
52
|
-
'StateError',
|
53
|
-
'ConnectError',
|
54
|
-
'ExecuteError',
|
55
|
-
'ExecInterruptedError',
|
56
|
-
|
57
|
-
# Type aliases
|
58
|
-
'SocketAddrT',
|
59
|
-
)
|
qemu/qmp/error.py
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
QMP Error Classes
|
3
|
-
|
4
|
-
This package seeks to provide semantic error classes that are intended
|
5
|
-
to be used directly by clients when they would like to handle particular
|
6
|
-
semantic failures (e.g. "failed to connect") without needing to know the
|
7
|
-
enumeration of possible reasons for that failure.
|
8
|
-
|
9
|
-
QMPError serves as the ancestor for all exceptions raised by this
|
10
|
-
package, and is suitable for use in handling semantic errors from this
|
11
|
-
library. In most cases, individual public methods will attempt to catch
|
12
|
-
and re-encapsulate various exceptions to provide a semantic
|
13
|
-
error-handling interface.
|
14
|
-
|
15
|
-
.. admonition:: QMP Exception Hierarchy Reference
|
16
|
-
|
17
|
-
| `Exception`
|
18
|
-
| +-- `QMPError`
|
19
|
-
| +-- `ConnectError`
|
20
|
-
| +-- `StateError`
|
21
|
-
| +-- `ExecInterruptedError`
|
22
|
-
| +-- `ExecuteError`
|
23
|
-
| +-- `ListenerError`
|
24
|
-
| +-- `ProtocolError`
|
25
|
-
| +-- `DeserializationError`
|
26
|
-
| +-- `UnexpectedTypeError`
|
27
|
-
| +-- `ServerParseError`
|
28
|
-
| +-- `BadReplyError`
|
29
|
-
| +-- `GreetingError`
|
30
|
-
| +-- `NegotiationError`
|
31
|
-
"""
|
32
|
-
|
33
|
-
|
34
|
-
class QMPError(Exception):
|
35
|
-
"""Abstract error class for all errors originating from this package."""
|
36
|
-
|
37
|
-
|
38
|
-
class ProtocolError(QMPError):
|
39
|
-
"""
|
40
|
-
Abstract error class for protocol failures.
|
41
|
-
|
42
|
-
Semantically, these errors are generally the fault of either the
|
43
|
-
protocol server or as a result of a bug in this library.
|
44
|
-
|
45
|
-
:param error_message: Human-readable string describing the error.
|
46
|
-
"""
|
47
|
-
def __init__(self, error_message: str):
|
48
|
-
super().__init__(error_message)
|
49
|
-
#: Human-readable error message, without any prefix.
|
50
|
-
self.error_message: str = error_message
|