libvirtpy 0.1.0__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 (154) hide show
  1. libvirtpy/__init__.py +5 -0
  2. libvirtpy/client/__init__.py +54 -0
  3. libvirtpy/client/_bases.py +326 -0
  4. libvirtpy/client/_runner.py +57 -0
  5. libvirtpy/client/aio.py +5922 -0
  6. libvirtpy/client/client.py +5695 -0
  7. libvirtpy/client/operations/__init__.py +631 -0
  8. libvirtpy/client/operations/_common.py +495 -0
  9. libvirtpy/client/operations/checkpoint.py +196 -0
  10. libvirtpy/client/operations/connection.py +93 -0
  11. libvirtpy/client/operations/connection_extra.py +256 -0
  12. libvirtpy/client/operations/domain.py +306 -0
  13. libvirtpy/client/operations/domain_agent.py +115 -0
  14. libvirtpy/client/operations/domain_block.py +368 -0
  15. libvirtpy/client/operations/domain_info.py +400 -0
  16. libvirtpy/client/operations/domain_lifecycle.py +338 -0
  17. libvirtpy/client/operations/domain_migration.py +164 -0
  18. libvirtpy/client/operations/domain_network.py +113 -0
  19. libvirtpy/client/operations/domain_tuning.py +494 -0
  20. libvirtpy/client/operations/host.py +246 -0
  21. libvirtpy/client/operations/host_interface.py +100 -0
  22. libvirtpy/client/operations/interface_extra.py +45 -0
  23. libvirtpy/client/operations/network.py +135 -0
  24. libvirtpy/client/operations/network_info.py +155 -0
  25. libvirtpy/client/operations/network_port.py +142 -0
  26. libvirtpy/client/operations/node_device.py +76 -0
  27. libvirtpy/client/operations/node_device_info.py +189 -0
  28. libvirtpy/client/operations/nwfilter.py +67 -0
  29. libvirtpy/client/operations/nwfilter_binding.py +74 -0
  30. libvirtpy/client/operations/secret.py +93 -0
  31. libvirtpy/client/operations/secret_extra.py +24 -0
  32. libvirtpy/client/operations/snapshot.py +100 -0
  33. libvirtpy/client/operations/snapshot_tree.py +114 -0
  34. libvirtpy/client/operations/storage.py +267 -0
  35. libvirtpy/client/operations/storage_info.py +188 -0
  36. libvirtpy/client/operations/streams.py +201 -0
  37. libvirtpy/client/references.py +249 -0
  38. libvirtpy/client/subscribing.py +88 -0
  39. libvirtpy/client/testing/__init__.py +24 -0
  40. libvirtpy/client/testing/_common.py +167 -0
  41. libvirtpy/client/testing/_domains.py +294 -0
  42. libvirtpy/client/testing/_objects.py +205 -0
  43. libvirtpy/client/testing/_state.py +246 -0
  44. libvirtpy/client/testing/_storage.py +171 -0
  45. libvirtpy/client/testing/async_transport.py +30 -0
  46. libvirtpy/client/testing/fake.py +81 -0
  47. libvirtpy/client/transport.py +87 -0
  48. libvirtpy/client/types.py +59 -0
  49. libvirtpy/client/wire.py +436 -0
  50. libvirtpy/client/wire_aio.py +348 -0
  51. libvirtpy/errors.py +7 -0
  52. libvirtpy/py.typed +0 -0
  53. libvirtpy/rpc/__init__.py +1 -0
  54. libvirtpy/rpc/aio.py +387 -0
  55. libvirtpy/rpc/cpumap.py +48 -0
  56. libvirtpy/rpc/errors.py +186 -0
  57. libvirtpy/rpc/events.py +259 -0
  58. libvirtpy/rpc/options.py +66 -0
  59. libvirtpy/rpc/procedure.py +27 -0
  60. libvirtpy/rpc/protocol/__init__.py +0 -0
  61. libvirtpy/rpc/protocol/procedures.py +5163 -0
  62. libvirtpy/rpc/protocol/typed_hints.py +210 -0
  63. libvirtpy/rpc/protocol/types.py +9299 -0
  64. libvirtpy/rpc/remote.py +295 -0
  65. libvirtpy/rpc/remote_aio.py +106 -0
  66. libvirtpy/rpc/sasl.py +467 -0
  67. libvirtpy/rpc/session.py +424 -0
  68. libvirtpy/rpc/sockets.py +251 -0
  69. libvirtpy/rpc/stream.py +323 -0
  70. libvirtpy/rpc/subscription.py +451 -0
  71. libvirtpy/rpc/sync.py +460 -0
  72. libvirtpy/rpc/typed_params.py +97 -0
  73. libvirtpy/rpc/uri.py +85 -0
  74. libvirtpy/rpc/xdr.py +552 -0
  75. libvirtpy/xml/__init__.py +49 -0
  76. libvirtpy/xml/_base.py +145 -0
  77. libvirtpy/xml/_shared/__init__.py +1 -0
  78. libvirtpy/xml/_shared/metadata.py +67 -0
  79. libvirtpy/xml/_shared/network.py +108 -0
  80. libvirtpy/xml/_shared/storage.py +131 -0
  81. libvirtpy/xml/_shared/sysinfo.py +83 -0
  82. libvirtpy/xml/_types.py +197 -0
  83. libvirtpy/xml/_xml_element.py +134 -0
  84. libvirtpy/xml/backup/__init__.py +25 -0
  85. libvirtpy/xml/backup/backup.py +89 -0
  86. libvirtpy/xml/backup/checkpoint.py +48 -0
  87. libvirtpy/xml/capabilities/__init__.py +43 -0
  88. libvirtpy/xml/capabilities/domain.py +436 -0
  89. libvirtpy/xml/capabilities/host.py +413 -0
  90. libvirtpy/xml/capabilities/storagepool.py +59 -0
  91. libvirtpy/xml/domain/__init__.py +493 -0
  92. libvirtpy/xml/domain/blkiotune.py +81 -0
  93. libvirtpy/xml/domain/clock.py +79 -0
  94. libvirtpy/xml/domain/cpu.py +265 -0
  95. libvirtpy/xml/domain/devices/__init__.py +495 -0
  96. libvirtpy/xml/domain/devices/address.py +152 -0
  97. libvirtpy/xml/domain/devices/audio.py +204 -0
  98. libvirtpy/xml/domain/devices/chardev.py +197 -0
  99. libvirtpy/xml/domain/devices/common.py +75 -0
  100. libvirtpy/xml/domain/devices/controller.py +262 -0
  101. libvirtpy/xml/domain/devices/devices.py +79 -0
  102. libvirtpy/xml/domain/devices/disk.py +471 -0
  103. libvirtpy/xml/domain/devices/filesystem.py +206 -0
  104. libvirtpy/xml/domain/devices/graphics.py +245 -0
  105. libvirtpy/xml/domain/devices/hostdev.py +221 -0
  106. libvirtpy/xml/domain/devices/input.py +89 -0
  107. libvirtpy/xml/domain/devices/interface.py +459 -0
  108. libvirtpy/xml/domain/devices/iommu.py +54 -0
  109. libvirtpy/xml/domain/devices/memballoon.py +42 -0
  110. libvirtpy/xml/domain/devices/memory_device.py +101 -0
  111. libvirtpy/xml/domain/devices/misc.py +169 -0
  112. libvirtpy/xml/domain/devices/nvram.py +20 -0
  113. libvirtpy/xml/domain/devices/shmem.py +46 -0
  114. libvirtpy/xml/domain/devices/sound.py +42 -0
  115. libvirtpy/xml/domain/devices/tpm.py +103 -0
  116. libvirtpy/xml/domain/devices/usb.py +86 -0
  117. libvirtpy/xml/domain/devices/video.py +101 -0
  118. libvirtpy/xml/domain/domain.py +157 -0
  119. libvirtpy/xml/domain/features.py +312 -0
  120. libvirtpy/xml/domain/iothread.py +41 -0
  121. libvirtpy/xml/domain/launch_security.py +82 -0
  122. libvirtpy/xml/domain/memory.py +149 -0
  123. libvirtpy/xml/domain/misc.py +113 -0
  124. libvirtpy/xml/domain/namespaces.py +96 -0
  125. libvirtpy/xml/domain/numa.py +140 -0
  126. libvirtpy/xml/domain/os.py +267 -0
  127. libvirtpy/xml/domain/qemu.py +102 -0
  128. libvirtpy/xml/domain/seclabel.py +29 -0
  129. libvirtpy/xml/domain/storage_source.py +466 -0
  130. libvirtpy/xml/domain/sysinfo.py +34 -0
  131. libvirtpy/xml/interface/__init__.py +17 -0
  132. libvirtpy/xml/interface/interface.py +153 -0
  133. libvirtpy/xml/network/__init__.py +101 -0
  134. libvirtpy/xml/network/network.py +311 -0
  135. libvirtpy/xml/network/port.py +84 -0
  136. libvirtpy/xml/nodedev/__init__.py +13 -0
  137. libvirtpy/xml/nodedev/nodedev.py +490 -0
  138. libvirtpy/xml/nwfilter/__init__.py +81 -0
  139. libvirtpy/xml/nwfilter/binding.py +51 -0
  140. libvirtpy/xml/nwfilter/filter.py +92 -0
  141. libvirtpy/xml/nwfilter/rules.py +534 -0
  142. libvirtpy/xml/secret/__init__.py +11 -0
  143. libvirtpy/xml/secret/secret.py +36 -0
  144. libvirtpy/xml/snapshot/__init__.py +29 -0
  145. libvirtpy/xml/snapshot/snapshot.py +136 -0
  146. libvirtpy/xml/storage/__init__.py +75 -0
  147. libvirtpy/xml/storage/pool.py +219 -0
  148. libvirtpy/xml/storage/volume.py +102 -0
  149. libvirtpy/xml/sysinfo.py +40 -0
  150. libvirtpy-0.1.0.dist-info/METADATA +109 -0
  151. libvirtpy-0.1.0.dist-info/RECORD +154 -0
  152. libvirtpy-0.1.0.dist-info/WHEEL +4 -0
  153. libvirtpy-0.1.0.dist-info/licenses/LICENSE +501 -0
  154. libvirtpy-0.1.0.dist-info/licenses/NOTICE +23 -0
@@ -0,0 +1,115 @@
1
+ """Operations that talk to the guest agent inside a domain."""
2
+
3
+ from libvirtpy.client.operations._common import as_int, as_list, as_text, on_domain
4
+ from libvirtpy.client.references import DomainRef
5
+ from libvirtpy.client.transport import Operation
6
+
7
+ __all__ = [
8
+ "freeze_domain_filesystems",
9
+ "get_domain_authorized_ssh_keys",
10
+ "set_domain_agent_timeout",
11
+ "set_domain_authorized_ssh_keys",
12
+ "thaw_domain_filesystems",
13
+ "trim_domain_filesystems",
14
+ ]
15
+
16
+
17
+ def freeze_domain_filesystems(
18
+ domain: DomainRef, mount_points: list[str] | None = None, *, flags: int = 0
19
+ ) -> Operation[int]:
20
+ """Freeze the file systems of the guest, so a consistent backup can be taken.
21
+
22
+ :param domain: the domain.
23
+ :param mount_points: the file systems; ``None`` for all.
24
+ :param flags: reserved, 0.
25
+ :returns: how many file systems were frozen.
26
+ """
27
+ reply = yield from on_domain(
28
+ domain, "domain_fsfreeze", mountpoints=mount_points or [], flags=flags
29
+ )
30
+ return as_int(reply)
31
+
32
+
33
+ def thaw_domain_filesystems(
34
+ domain: DomainRef, mount_points: list[str] | None = None, *, flags: int = 0
35
+ ) -> Operation[int]:
36
+ """Thaw file systems that ``freeze_domain_filesystems`` froze.
37
+
38
+ :param domain: the domain.
39
+ :param mount_points: the file systems; ``None`` for all.
40
+ :param flags: reserved, 0.
41
+ :returns: how many file systems were thawed.
42
+ """
43
+ reply = yield from on_domain(
44
+ domain, "domain_fsthaw", mountpoints=mount_points or [], flags=flags
45
+ )
46
+ return as_int(reply)
47
+
48
+
49
+ def trim_domain_filesystems(
50
+ domain: DomainRef,
51
+ mount_point: str | None = None,
52
+ minimum: int = 0,
53
+ *,
54
+ flags: int = 0,
55
+ ) -> Operation[None]:
56
+ """Tell the guest to discard unused blocks (``fstrim``).
57
+
58
+ :param domain: the domain.
59
+ :param mount_point: the file system; ``None`` for all.
60
+ :param minimum: the smallest free range to discard, in bytes.
61
+ :param flags: reserved, 0.
62
+ """
63
+ yield from on_domain(
64
+ domain,
65
+ "domain_fstrim",
66
+ mount_point=mount_point,
67
+ minimum=minimum,
68
+ flags=flags,
69
+ )
70
+
71
+
72
+ def get_domain_authorized_ssh_keys(
73
+ domain: DomainRef, user: str, *, flags: int = 0
74
+ ) -> Operation[list[str]]:
75
+ """Read the authorized SSH keys of a user in the guest.
76
+
77
+ :param domain: the domain.
78
+ :param user: the user name in the guest.
79
+ :param flags: reserved, 0.
80
+ :returns: the keys, one per entry.
81
+ """
82
+ reply = yield from on_domain(
83
+ domain, "domain_authorized_ssh_keys_get", user=user, flags=flags
84
+ )
85
+ return [as_text(key) for key in as_list(reply)]
86
+
87
+
88
+ def set_domain_authorized_ssh_keys(
89
+ domain: DomainRef, user: str, keys: list[str], *, flags: int = 0
90
+ ) -> Operation[None]:
91
+ """Change the authorized SSH keys of a user in the guest.
92
+
93
+ :param domain: the domain.
94
+ :param user: the user name in the guest.
95
+ :param keys: the keys.
96
+ :param flags: ``virDomainAuthorizedSSHKeysSetFlags``: 1 append, 2 remove.
97
+ """
98
+ yield from on_domain(
99
+ domain, "domain_authorized_ssh_keys_set", user=user, keys=keys, flags=flags
100
+ )
101
+
102
+
103
+ def set_domain_agent_timeout(
104
+ domain: DomainRef, timeout: int, *, flags: int = 0
105
+ ) -> Operation[None]:
106
+ """Set how long libvirt waits for the guest agent to answer.
107
+
108
+ :param domain: the domain.
109
+ :param timeout: seconds; ``virDomainAgentResponseTimeoutValues``: 0 no wait,
110
+ -1 block, -2 default.
111
+ :param flags: reserved, 0.
112
+ """
113
+ yield from on_domain(
114
+ domain, "domain_agent_set_response_timeout", timeout=timeout, flags=flags
115
+ )
@@ -0,0 +1,368 @@
1
+ """Operations on the disks of a running domain: statistics, resizing, block jobs."""
2
+
3
+ from libvirtpy.client.operations._common import (
4
+ as_bytes,
5
+ as_list,
6
+ as_struct,
7
+ get_typed_parameters,
8
+ on_domain,
9
+ )
10
+ from libvirtpy.client.references import DomainRef
11
+ from libvirtpy.client.transport import Operation
12
+ from libvirtpy.rpc.protocol import types
13
+ from libvirtpy.rpc.typed_params import TypedValue, to_wire
14
+
15
+ __all__ = [
16
+ "abort_domain_block_job",
17
+ "commit_domain_block",
18
+ "copy_domain_block",
19
+ "delete_domain_throttle_group",
20
+ "detach_domain_device_by_alias",
21
+ "get_domain_block_info",
22
+ "get_domain_block_io_tune",
23
+ "get_domain_block_job_info",
24
+ "get_domain_block_stats",
25
+ "get_domain_disk_errors",
26
+ "peek_domain_block",
27
+ "pull_domain_block",
28
+ "rebase_domain_block",
29
+ "resize_domain_block",
30
+ "set_domain_block_io_tune",
31
+ "set_domain_block_job_speed",
32
+ "set_domain_block_threshold",
33
+ "set_domain_throttle_group",
34
+ ]
35
+
36
+
37
+ def get_domain_block_stats(
38
+ domain: DomainRef, disk: str, *, flags: int = 0
39
+ ) -> Operation[dict[str, TypedValue]]:
40
+ """Return the I/O statistics of a disk of a running domain.
41
+
42
+ :param domain: the domain.
43
+ :param disk: the disk, by target name (``vda``) or image path.
44
+ :param flags: reserved, 0.
45
+ :returns: ``rd_bytes``, ``rd_operations``, ``wr_bytes``, ``wr_operations``...
46
+ """
47
+ return (
48
+ yield from get_typed_parameters(
49
+ domain, "domain_block_stats_flags", flags, path=disk
50
+ )
51
+ )
52
+
53
+
54
+ def get_domain_block_info(
55
+ domain: DomainRef, disk: str, *, flags: int = 0
56
+ ) -> Operation[types.DomainGetBlockInfoRet]:
57
+ """Return the size of a disk.
58
+
59
+ :param domain: the domain.
60
+ :param disk: the disk, by target name or image path.
61
+ :param flags: reserved, 0.
62
+ :returns: ``capacity`` (virtual size), ``allocation`` (used by the guest) and
63
+ ``physical`` (on the host), all in bytes.
64
+ """
65
+ reply = yield from on_domain(
66
+ domain, "domain_get_block_info", path=disk, flags=flags
67
+ )
68
+ return as_struct(reply, types.DomainGetBlockInfoRet)
69
+
70
+
71
+ def resize_domain_block(
72
+ domain: DomainRef, disk: str, size: int, *, flags: int = 0
73
+ ) -> Operation[None]:
74
+ """Change the virtual size of a disk of a running domain.
75
+
76
+ :param domain: the domain.
77
+ :param disk: the disk, by target name or image path.
78
+ :param size: the new size, in KiB unless ``flags`` has the bytes bit.
79
+ :param flags: ``virDomainBlockResizeFlags``: 1 the size is in bytes.
80
+ """
81
+ yield from on_domain(
82
+ domain, "domain_block_resize", disk=disk, size=size, flags=flags
83
+ )
84
+
85
+
86
+ def peek_domain_block(
87
+ domain: DomainRef, disk: str, offset: int, size: int, *, flags: int = 0
88
+ ) -> Operation[bytes]:
89
+ """Read bytes from a disk of a domain.
90
+
91
+ :param domain: the domain.
92
+ :param disk: the disk, by target name or image path.
93
+ :param offset: where to start, in bytes.
94
+ :param size: how many bytes.
95
+ :param flags: reserved, 0.
96
+ :returns: the bytes.
97
+ """
98
+ reply = yield from on_domain(
99
+ domain, "domain_block_peek", path=disk, offset=offset, size=size, flags=flags
100
+ )
101
+ return as_bytes(reply)
102
+
103
+
104
+ def get_domain_block_io_tune(
105
+ domain: DomainRef, disk: str | None = None, *, flags: int = 0
106
+ ) -> Operation[dict[str, TypedValue]]:
107
+ """Return the I/O limits of a disk.
108
+
109
+ :param domain: the domain.
110
+ :param disk: the disk, by target name; ``None`` for the number of disks only.
111
+ :param flags: ``virDomainModificationImpact``: live, config.
112
+ :returns: ``total_bytes_sec``, ``read_iops_sec``, ``group_name``...
113
+ """
114
+ return (
115
+ yield from get_typed_parameters(
116
+ domain, "domain_get_block_io_tune", flags, disk=disk
117
+ )
118
+ )
119
+
120
+
121
+ def set_domain_block_io_tune(
122
+ domain: DomainRef,
123
+ disk: str,
124
+ parameters: dict[str, TypedValue],
125
+ *,
126
+ flags: int = 0,
127
+ ) -> Operation[None]:
128
+ """Change the I/O limits of a disk.
129
+
130
+ :param domain: the domain.
131
+ :param disk: the disk, by target name.
132
+ :param parameters: e.g. ``{"total_bytes_sec": 10_000_000}``.
133
+ :param flags: ``virDomainModificationImpact``: live, config.
134
+ """
135
+ yield from on_domain(
136
+ domain,
137
+ "domain_set_block_io_tune",
138
+ disk=disk,
139
+ params=to_wire(parameters),
140
+ flags=flags,
141
+ )
142
+
143
+
144
+ def abort_domain_block_job(
145
+ domain: DomainRef, disk: str, *, flags: int = 0
146
+ ) -> Operation[None]:
147
+ """Cancel the active block job (pull, copy, commit) of a disk.
148
+
149
+ :param domain: the domain.
150
+ :param disk: the disk, by target name or image path.
151
+ :param flags: ``virDomainBlockJobAbortFlags``: async, pivot.
152
+ """
153
+ yield from on_domain(domain, "domain_block_job_abort", path=disk, flags=flags)
154
+
155
+
156
+ def get_domain_block_job_info(
157
+ domain: DomainRef, disk: str, *, flags: int = 0
158
+ ) -> Operation[types.DomainGetBlockJobInfoRet]:
159
+ """Return the progress of the block job of a disk.
160
+
161
+ :param domain: the domain.
162
+ :param disk: the disk, by target name or image path.
163
+ :param flags: ``virDomainBlockJobInfoFlags``: 1 the bandwidth in bytes.
164
+ :returns: ``found`` (0 if no job), ``type``, ``bandwidth``, and ``cur`` out of
165
+ ``end`` for the progress.
166
+ """
167
+ reply = yield from on_domain(
168
+ domain, "domain_get_block_job_info", path=disk, flags=flags
169
+ )
170
+ return as_struct(reply, types.DomainGetBlockJobInfoRet)
171
+
172
+
173
+ def set_domain_block_job_speed(
174
+ domain: DomainRef, disk: str, bandwidth: int, *, flags: int = 0
175
+ ) -> Operation[None]:
176
+ """Limit the speed of the block job of a disk.
177
+
178
+ :param domain: the domain.
179
+ :param disk: the disk, by target name or image path.
180
+ :param bandwidth: MiB per second (bytes with the flag); 0 for no limit.
181
+ :param flags: ``virDomainBlockJobSetSpeedFlags``: 1 the bandwidth in bytes.
182
+ """
183
+ yield from on_domain(
184
+ domain,
185
+ "domain_block_job_set_speed",
186
+ path=disk,
187
+ bandwidth=bandwidth,
188
+ flags=flags,
189
+ )
190
+
191
+
192
+ def pull_domain_block(
193
+ domain: DomainRef, disk: str, bandwidth: int = 0, *, flags: int = 0
194
+ ) -> Operation[None]:
195
+ """Copy the backing chain into a disk image, so it stands alone.
196
+
197
+ :param domain: the domain.
198
+ :param disk: the disk, by target name or image path.
199
+ :param bandwidth: MiB per second; 0 for no limit.
200
+ :param flags: ``virDomainBlockPullFlags``.
201
+ """
202
+ yield from on_domain(
203
+ domain, "domain_block_pull", path=disk, bandwidth=bandwidth, flags=flags
204
+ )
205
+
206
+
207
+ def rebase_domain_block(
208
+ domain: DomainRef,
209
+ disk: str,
210
+ base: str | None = None,
211
+ bandwidth: int = 0,
212
+ *,
213
+ flags: int = 0,
214
+ ) -> Operation[None]:
215
+ """Change the backing file of a disk, copying data as needed.
216
+
217
+ :param domain: the domain.
218
+ :param disk: the disk, by target name or image path.
219
+ :param base: the new backing image; ``None`` flattens the chain.
220
+ :param bandwidth: MiB per second; 0 for no limit.
221
+ :param flags: ``virDomainBlockRebaseFlags``: shallow, relative, copy...
222
+ """
223
+ yield from on_domain(
224
+ domain,
225
+ "domain_block_rebase",
226
+ path=disk,
227
+ base=base,
228
+ bandwidth=bandwidth,
229
+ flags=flags,
230
+ )
231
+
232
+
233
+ def commit_domain_block(
234
+ domain: DomainRef,
235
+ disk: str,
236
+ base: str | None = None,
237
+ top: str | None = None,
238
+ bandwidth: int = 0,
239
+ *,
240
+ flags: int = 0,
241
+ ) -> Operation[None]:
242
+ """Merge a layer of a disk's backing chain into a lower one.
243
+
244
+ :param domain: the domain.
245
+ :param disk: the disk, by target name or image path.
246
+ :param base: the image to merge into; ``None`` for the bottom of the chain.
247
+ :param top: the image to merge from; ``None`` for the active layer.
248
+ :param bandwidth: MiB per second; 0 for no limit.
249
+ :param flags: ``virDomainBlockCommitFlags``: shallow, delete, active, relative.
250
+ """
251
+ yield from on_domain(
252
+ domain,
253
+ "domain_block_commit",
254
+ disk=disk,
255
+ base=base,
256
+ top=top,
257
+ bandwidth=bandwidth,
258
+ flags=flags,
259
+ )
260
+
261
+
262
+ def copy_domain_block(
263
+ domain: DomainRef,
264
+ disk: str,
265
+ destination: str,
266
+ parameters: dict[str, TypedValue] | None = None,
267
+ *,
268
+ flags: int = 0,
269
+ ) -> Operation[None]:
270
+ """Copy a disk to a new destination while the domain runs.
271
+
272
+ :param domain: the domain.
273
+ :param disk: the disk, by target name or image path.
274
+ :param destination: the destination disk as XML (``<disk>`` element).
275
+ :param parameters: ``bandwidth``, ``granularity``, ``buf-size``.
276
+ :param flags: ``virDomainBlockCopyFlags``: shallow, reuse external, ...
277
+ """
278
+ yield from on_domain(
279
+ domain,
280
+ "domain_block_copy",
281
+ path=disk,
282
+ destxml=destination,
283
+ params=to_wire(parameters or {}),
284
+ flags=flags,
285
+ )
286
+
287
+
288
+ def set_domain_block_threshold(
289
+ domain: DomainRef, device: str, threshold: int, *, flags: int = 0
290
+ ) -> Operation[None]:
291
+ """Ask for an event when a disk's usage passes a threshold.
292
+
293
+ :param domain: the domain.
294
+ :param device: the disk target (``vda``) or an image ``vda[1]``.
295
+ :param threshold: the limit in bytes; 0 clears it.
296
+ :param flags: reserved, 0.
297
+ """
298
+ yield from on_domain(
299
+ domain,
300
+ "domain_set_block_threshold",
301
+ dev=device,
302
+ threshold=threshold,
303
+ flags=flags,
304
+ )
305
+
306
+
307
+ def get_domain_disk_errors(
308
+ domain: DomainRef, *, max_errors: int = 64, flags: int = 0
309
+ ) -> Operation[list[types.DomainDiskError]]:
310
+ """List the disks of a domain that report errors.
311
+
312
+ :param domain: the domain.
313
+ :param max_errors: how many to ask for at most.
314
+ :param flags: reserved, 0.
315
+ :returns: ``(disk, error)`` pairs; ``error`` is ``virDomainDiskErrorCode``.
316
+ """
317
+ reply = yield from on_domain(
318
+ domain, "domain_get_disk_errors", maxerrors=max_errors, flags=flags
319
+ )
320
+ result = as_struct(reply, types.DomainGetDiskErrorsRet)
321
+ return [as_struct(item, types.DomainDiskError) for item in as_list(result.errors)]
322
+
323
+
324
+ def set_domain_throttle_group(
325
+ domain: DomainRef,
326
+ group: str,
327
+ parameters: dict[str, TypedValue],
328
+ *,
329
+ flags: int = 0,
330
+ ) -> Operation[None]:
331
+ """Create or change a group of disks that share I/O limits.
332
+
333
+ :param domain: the domain.
334
+ :param group: the group name.
335
+ :param parameters: the limits, e.g. ``{"total_bytes_sec": 1_000_000}``.
336
+ :param flags: ``virDomainModificationImpact``: live, config.
337
+ """
338
+ yield from on_domain(
339
+ domain,
340
+ "domain_set_throttle_group",
341
+ group=group,
342
+ params=to_wire(parameters),
343
+ flags=flags,
344
+ )
345
+
346
+
347
+ def delete_domain_throttle_group(
348
+ domain: DomainRef, group: str | None = None, *, flags: int = 0
349
+ ) -> Operation[None]:
350
+ """Remove a group of disks that share I/O limits.
351
+
352
+ :param domain: the domain.
353
+ :param group: the group name.
354
+ :param flags: ``virDomainModificationImpact``: live, config.
355
+ """
356
+ yield from on_domain(domain, "domain_del_throttle_group", group=group, flags=flags)
357
+
358
+
359
+ def detach_domain_device_by_alias(
360
+ domain: DomainRef, alias: str, *, flags: int = 0
361
+ ) -> Operation[None]:
362
+ """Unplug a device by its alias (``ua-...``) instead of its XML.
363
+
364
+ :param domain: the domain.
365
+ :param alias: the device alias.
366
+ :param flags: ``virDomainDeviceModifyFlags``: live, config.
367
+ """
368
+ yield from on_domain(domain, "domain_detach_device_alias", alias=alias, flags=flags)