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,338 @@
1
+ """Operations that change the power or saved state of a domain."""
2
+
3
+ from libvirtpy.client.operations._common import (
4
+ as_bool,
5
+ as_text,
6
+ as_xml,
7
+ on_domain,
8
+ )
9
+ from libvirtpy.client.references import DomainRef
10
+ from libvirtpy.client.transport import Operation, Request
11
+ from libvirtpy.xml.domain import Domain
12
+
13
+ __all__ = [
14
+ "define_domain_managed_save_xml",
15
+ "define_saved_domain_xml",
16
+ "dump_domain_core",
17
+ "get_domain_autostart_once",
18
+ "get_domain_managed_save_xml",
19
+ "get_saved_domain_xml",
20
+ "has_domain_managed_save",
21
+ "inject_domain_nmi",
22
+ "reload_domain_graphics",
23
+ "remove_domain_managed_save",
24
+ "rename_domain",
25
+ "restore_domain",
26
+ "save_domain",
27
+ "save_domain_managed",
28
+ "send_domain_keys",
29
+ "send_domain_signal",
30
+ "set_domain_autostart_once",
31
+ "set_domain_lifecycle_action",
32
+ "set_domain_user_password",
33
+ "suspend_domain_for_duration",
34
+ "wake_domain",
35
+ ]
36
+
37
+
38
+ def suspend_domain_for_duration(
39
+ domain: DomainRef, target: int, duration: int = 0, *, flags: int = 0
40
+ ) -> Operation[None]:
41
+ """Put the guest to sleep (power management suspend), through the guest agent.
42
+
43
+ :param domain: the domain.
44
+ :param target: ``virNodeSuspendTarget``: 0 memory (S3), 1 disk (S4), 2 hybrid.
45
+ :param duration: seconds until the guest wakes up by itself; 0 for no wake-up.
46
+ :param flags: reserved, 0.
47
+ """
48
+ yield from on_domain(
49
+ domain,
50
+ "domain_pm_suspend_for_duration",
51
+ target=target,
52
+ duration=duration,
53
+ flags=flags,
54
+ )
55
+
56
+
57
+ def wake_domain(domain: DomainRef, *, flags: int = 0) -> Operation[None]:
58
+ """Wake a guest that is suspended by power management.
59
+
60
+ :param domain: the domain.
61
+ :param flags: reserved, 0.
62
+ """
63
+ yield from on_domain(domain, "domain_pm_wakeup", flags=flags)
64
+
65
+
66
+ def inject_domain_nmi(domain: DomainRef, *, flags: int = 0) -> Operation[None]:
67
+ """Send a non-maskable interrupt to the guest (often used to trigger a dump).
68
+
69
+ :param domain: the domain.
70
+ :param flags: reserved, 0.
71
+ """
72
+ yield from on_domain(domain, "domain_inject_nmi", flags=flags)
73
+
74
+
75
+ def send_domain_keys(
76
+ domain: DomainRef,
77
+ keycodes: list[int],
78
+ *,
79
+ codeset: int = 0,
80
+ holdtime: int = 0,
81
+ flags: int = 0,
82
+ ) -> Operation[None]:
83
+ """Type keys into the guest, as if pressed together.
84
+
85
+ :param domain: the domain.
86
+ :param keycodes: the key codes, in the numbering of ``codeset``.
87
+ :param codeset: ``virKeycodeSet``: 0 Linux, 1 XT, 2 AT set 1, ...
88
+ :param holdtime: how long to hold the keys, in milliseconds.
89
+ :param flags: reserved, 0.
90
+ """
91
+ yield from on_domain(
92
+ domain,
93
+ "domain_send_key",
94
+ codeset=codeset,
95
+ holdtime=holdtime,
96
+ keycodes=keycodes,
97
+ flags=flags,
98
+ )
99
+
100
+
101
+ def send_domain_signal(
102
+ domain: DomainRef, pid: int, signal: int, *, flags: int = 0
103
+ ) -> Operation[None]:
104
+ """Send a signal to a process in the guest, through the guest agent.
105
+
106
+ :param domain: the domain.
107
+ :param pid: the process id in the guest; negative to signal a process group.
108
+ :param signal: ``virDomainProcessSignal``, e.g. 15 for SIGTERM.
109
+ :param flags: reserved, 0.
110
+ """
111
+ yield from on_domain(
112
+ domain, "domain_send_process_signal", pid_value=pid, signum=signal, flags=flags
113
+ )
114
+
115
+
116
+ def rename_domain(
117
+ domain: DomainRef, new_name: str, *, flags: int = 0
118
+ ) -> Operation[None]:
119
+ """Rename an inactive domain.
120
+
121
+ :param domain: the domain; it must not be running.
122
+ :param new_name: the new name.
123
+ :param flags: reserved, 0.
124
+ :raises OperationInvalidError: if the domain is running.
125
+ """
126
+ yield from on_domain(domain, "domain_rename", new_name=new_name, flags=flags)
127
+
128
+
129
+ def set_domain_lifecycle_action(
130
+ domain: DomainRef, action_type: int, action: int, *, flags: int = 0
131
+ ) -> Operation[None]:
132
+ """Choose what libvirt does when the guest powers off, reboots or crashes.
133
+
134
+ :param domain: the domain.
135
+ :param action_type: ``virDomainLifecycle``: 0 poweroff, 1 reboot, 2 crash.
136
+ :param action: ``virDomainLifecycleAction``: 0 destroy, 1 restart, 2 rename-
137
+ restart,
138
+ 3 preserve, 4 coredump-destroy, 5 coredump-restart.
139
+ :param flags: ``virDomainModificationImpact``: live, config.
140
+ """
141
+ yield from on_domain(
142
+ domain,
143
+ "domain_set_lifecycle_action",
144
+ type=action_type,
145
+ action=action,
146
+ flags=flags,
147
+ )
148
+
149
+
150
+ def set_domain_user_password(
151
+ domain: DomainRef, user: str, password: str, *, flags: int = 0
152
+ ) -> Operation[None]:
153
+ """Set the password of a user inside the guest, through the guest agent.
154
+
155
+ :param domain: the domain.
156
+ :param user: the user name in the guest.
157
+ :param password: the new password; plain text unless ``flags`` says encrypted.
158
+ :param flags: ``virDomainSetUserPasswordFlags``: 1 if the password is encrypted.
159
+ """
160
+ yield from on_domain(
161
+ domain, "domain_set_user_password", user=user, password=password, flags=flags
162
+ )
163
+
164
+
165
+ def get_domain_autostart_once(domain: DomainRef) -> Operation[bool]:
166
+ """Tell whether the domain is set to start at the next host boot only.
167
+
168
+ :param domain: the domain.
169
+ :returns: ``True`` if the one-time autostart is on.
170
+ """
171
+ return as_bool((yield from on_domain(domain, "domain_get_autostart_once")))
172
+
173
+
174
+ def set_domain_autostart_once(domain: DomainRef, enabled: bool) -> Operation[None]:
175
+ """Start the domain at the next host boot only.
176
+
177
+ :param domain: the domain.
178
+ :param enabled: ``True`` to turn the one-time autostart on, ``False`` off.
179
+ """
180
+ yield from on_domain(domain, "domain_set_autostart_once", autostart=int(enabled))
181
+
182
+
183
+ def reload_domain_graphics(
184
+ domain: DomainRef, graphics_type: int = 0, *, flags: int = 0
185
+ ) -> Operation[None]:
186
+ """Make a graphics server reload its certificates.
187
+
188
+ :param domain: the domain.
189
+ :param graphics_type: ``virDomainGraphicsType``: 0 sdl, 1 vnc, 2 rdp, 3 desktop,
190
+ 4 spice.
191
+ :param flags: reserved, 0.
192
+ """
193
+ yield from on_domain(
194
+ domain, "domain_graphics_reload", type=graphics_type, flags=flags
195
+ )
196
+
197
+
198
+ def save_domain_managed(domain: DomainRef, *, flags: int = 0) -> Operation[None]:
199
+ """Save the memory of a running domain to a file libvirt manages, and stop it.
200
+
201
+ The domain restores from it on its next start.
202
+
203
+ :param domain: the domain.
204
+ :param flags: ``virDomainSaveRestoreFlags``: running, paused, bypass cache.
205
+ """
206
+ yield from on_domain(domain, "domain_managed_save", flags=flags)
207
+
208
+
209
+ def has_domain_managed_save(domain: DomainRef, *, flags: int = 0) -> Operation[bool]:
210
+ """Tell whether the domain has a managed save image.
211
+
212
+ :param domain: the domain.
213
+ :param flags: reserved, 0.
214
+ :returns: ``True`` if one exists.
215
+ """
216
+ return as_bool(
217
+ (yield from on_domain(domain, "domain_has_managed_save_image", flags=flags))
218
+ )
219
+
220
+
221
+ def remove_domain_managed_save(domain: DomainRef, *, flags: int = 0) -> Operation[None]:
222
+ """Delete the managed save image of a domain.
223
+
224
+ :param domain: the domain.
225
+ :param flags: reserved, 0.
226
+ """
227
+ yield from on_domain(domain, "domain_managed_save_remove", flags=flags)
228
+
229
+
230
+ def get_domain_managed_save_xml(
231
+ domain: DomainRef, *, flags: int = 0
232
+ ) -> Operation[Domain]:
233
+ """Read the configuration stored in the managed save image of a domain.
234
+
235
+ :param domain: the domain.
236
+ :param flags: ``virDomainXMLFlags``, e.g. secure.
237
+ :returns: the saved domain configuration.
238
+ """
239
+ xml = as_text(
240
+ (yield from on_domain(domain, "domain_managed_save_get_xml_desc", flags=flags))
241
+ )
242
+ return Domain.from_xml(xml)
243
+
244
+
245
+ def define_domain_managed_save_xml(
246
+ domain: DomainRef, definition: Domain | str | None = None, *, flags: int = 0
247
+ ) -> Operation[None]:
248
+ """Replace the configuration stored in the managed save image of a domain.
249
+
250
+ :param domain: the domain.
251
+ :param definition: the new configuration as a model or XML; ``None`` keeps it.
252
+ :param flags: ``virDomainSaveRestoreFlags``: running or paused on restore.
253
+ """
254
+ xml = None if definition is None else as_xml(definition)
255
+ yield from on_domain(
256
+ domain, "domain_managed_save_define_xml", dxml=xml, flags=flags
257
+ )
258
+
259
+
260
+ def save_domain(
261
+ domain: DomainRef,
262
+ path: str,
263
+ *,
264
+ definition: Domain | str | None = None,
265
+ flags: int = 0,
266
+ ) -> Operation[None]:
267
+ """Save the memory of a running domain to a file on the host, and stop it.
268
+
269
+ :param domain: the domain.
270
+ :param path: the file, on the host of the daemon.
271
+ :param definition: a different configuration to restore with, or ``None``.
272
+ :param flags: ``virDomainSaveRestoreFlags``: bypass cache, running, paused...
273
+ """
274
+ xml = None if definition is None else as_xml(definition)
275
+ yield from on_domain(domain, "domain_save_flags", to=path, dxml=xml, flags=flags)
276
+
277
+
278
+ def restore_domain(
279
+ path: str, *, definition: Domain | str | None = None, flags: int = 0
280
+ ) -> Operation[None]:
281
+ """Start a domain from a file made by ``save_domain``.
282
+
283
+ :param path: the file, on the host of the daemon.
284
+ :param definition: a different configuration to restore with, or ``None``.
285
+ :param flags: ``virDomainSaveRestoreFlags``: running or paused afterwards.
286
+ """
287
+ xml = None if definition is None else as_xml(definition)
288
+ yield Request("domain_restore_flags", {"from_": path, "dxml": xml, "flags": flags})
289
+
290
+
291
+ def get_saved_domain_xml(path: str, *, flags: int = 0) -> Operation[Domain]:
292
+ """Read the configuration stored in a save file.
293
+
294
+ :param path: the file, on the host of the daemon.
295
+ :param flags: ``virDomainXMLFlags``, e.g. secure.
296
+ :returns: the saved domain configuration.
297
+ """
298
+ xml = as_text(
299
+ (
300
+ yield Request(
301
+ "domain_save_image_get_xml_desc", {"file": path, "flags": flags}
302
+ )
303
+ )
304
+ )
305
+ return Domain.from_xml(xml)
306
+
307
+
308
+ def define_saved_domain_xml(
309
+ path: str, definition: Domain | str, *, flags: int = 0
310
+ ) -> Operation[None]:
311
+ """Replace the configuration stored in a save file.
312
+
313
+ :param path: the file, on the host of the daemon.
314
+ :param definition: the new configuration as a model or XML.
315
+ :param flags: ``virDomainSaveRestoreFlags``: running or paused on restore.
316
+ """
317
+ arguments = {"file": path, "dxml": as_xml(definition), "flags": flags}
318
+ yield Request("domain_save_image_define_xml", arguments)
319
+
320
+
321
+ def dump_domain_core(
322
+ domain: DomainRef, path: str, *, dump_format: int = 0, flags: int = 0
323
+ ) -> Operation[None]:
324
+ """Dump the core of a domain to a file on the host, for debugging.
325
+
326
+ :param domain: the domain.
327
+ :param path: the file, on the host of the daemon.
328
+ :param dump_format: ``virDomainCoreDumpFormat``: 0 raw, 1 zlib, 2 lzo, 3 snappy,
329
+ 4 kdump.
330
+ :param flags: ``virDomainCoreDumpFlags``: crash, live, reset, ...
331
+ """
332
+ yield from on_domain(
333
+ domain,
334
+ "domain_core_dump_with_format",
335
+ to=path,
336
+ dumpformat=dump_format,
337
+ flags=flags,
338
+ )
@@ -0,0 +1,164 @@
1
+ """Operations that tune a migration of a domain.
2
+
3
+ Starting a migration is not here: libvirt coordinates it in the client between
4
+ two daemons (the ``migrate_*3`` steps), which this library does not do yet.
5
+ """
6
+
7
+ from libvirtpy.client.operations._common import as_int, on_domain
8
+ from libvirtpy.client.references import DomainRef
9
+ from libvirtpy.client.transport import Operation, Request
10
+ from libvirtpy.rpc.typed_params import TypedValue, to_wire
11
+
12
+ __all__ = [
13
+ "get_domain_migration_compression_cache",
14
+ "get_domain_migration_max_downtime",
15
+ "get_domain_migration_max_speed",
16
+ "restore_domain_with_parameters",
17
+ "save_domain_with_parameters",
18
+ "set_domain_launch_security_state",
19
+ "set_domain_migration_compression_cache",
20
+ "set_domain_migration_max_downtime",
21
+ "set_domain_migration_max_speed",
22
+ "start_domain_migration_post_copy",
23
+ ]
24
+
25
+
26
+ def get_domain_migration_max_speed(
27
+ domain: DomainRef, *, flags: int = 0
28
+ ) -> Operation[int]:
29
+ """Return the bandwidth limit of the migration of a domain.
30
+
31
+ :param domain: the domain.
32
+ :param flags: ``virDomainMigrateMaxSpeedFlags``: 1 post-copy.
33
+ :returns: the limit in MiB per second; 0 for none.
34
+ """
35
+ reply = yield from on_domain(domain, "domain_migrate_get_max_speed", flags=flags)
36
+ return as_int(reply)
37
+
38
+
39
+ def set_domain_migration_max_speed(
40
+ domain: DomainRef, bandwidth: int, *, flags: int = 0
41
+ ) -> Operation[None]:
42
+ """Limit the bandwidth of the migration of a domain.
43
+
44
+ :param domain: the domain.
45
+ :param bandwidth: MiB per second; 0 for no limit.
46
+ :param flags: ``virDomainMigrateMaxSpeedFlags``: 1 post-copy.
47
+ """
48
+ yield from on_domain(
49
+ domain, "domain_migrate_set_max_speed", bandwidth=bandwidth, flags=flags
50
+ )
51
+
52
+
53
+ def get_domain_migration_max_downtime(
54
+ domain: DomainRef, *, flags: int = 0
55
+ ) -> Operation[int]:
56
+ """Return the longest pause allowed at the end of a live migration.
57
+
58
+ :param domain: the domain.
59
+ :param flags: reserved, 0.
60
+ :returns: the limit in milliseconds.
61
+ """
62
+ reply = yield from on_domain(domain, "domain_migrate_get_max_downtime", flags=flags)
63
+ return as_int(reply)
64
+
65
+
66
+ def set_domain_migration_max_downtime(
67
+ domain: DomainRef, downtime: int, *, flags: int = 0
68
+ ) -> Operation[None]:
69
+ """Set the longest pause allowed at the end of a live migration.
70
+
71
+ :param domain: the domain.
72
+ :param downtime: the limit in milliseconds.
73
+ :param flags: reserved, 0.
74
+ """
75
+ yield from on_domain(
76
+ domain, "domain_migrate_set_max_downtime", downtime=downtime, flags=flags
77
+ )
78
+
79
+
80
+ def get_domain_migration_compression_cache(
81
+ domain: DomainRef, *, flags: int = 0
82
+ ) -> Operation[int]:
83
+ """Return the size of the cache used to compress a migration.
84
+
85
+ :param domain: the domain.
86
+ :param flags: reserved, 0.
87
+ :returns: the size in bytes.
88
+ """
89
+ reply = yield from on_domain(
90
+ domain, "domain_migrate_get_compression_cache", flags=flags
91
+ )
92
+ return as_int(reply)
93
+
94
+
95
+ def set_domain_migration_compression_cache(
96
+ domain: DomainRef, size: int, *, flags: int = 0
97
+ ) -> Operation[None]:
98
+ """Set the size of the cache used to compress a migration.
99
+
100
+ :param domain: the domain.
101
+ :param size: the size in bytes.
102
+ :param flags: reserved, 0.
103
+ """
104
+ yield from on_domain(
105
+ domain, "domain_migrate_set_compression_cache", cache_size=size, flags=flags
106
+ )
107
+
108
+
109
+ def start_domain_migration_post_copy(
110
+ domain: DomainRef, *, flags: int = 0
111
+ ) -> Operation[None]:
112
+ """Switch a running live migration to post-copy mode.
113
+
114
+ :param domain: the domain.
115
+ :param flags: reserved, 0.
116
+ """
117
+ yield from on_domain(domain, "domain_migrate_start_post_copy", flags=flags)
118
+
119
+
120
+ def save_domain_with_parameters(
121
+ domain: DomainRef, parameters: dict[str, TypedValue], *, flags: int = 0
122
+ ) -> Operation[None]:
123
+ """Save a domain to a file, with the options of the parameter form.
124
+
125
+ :param domain: the domain.
126
+ :param parameters: ``file`` (required), ``dom_xml``, ``bandwidth``,
127
+ ``parallel.connections``, ...
128
+ :param flags: ``virDomainSaveRestoreFlags``.
129
+ """
130
+ yield from on_domain(
131
+ domain, "domain_save_params", params=to_wire(parameters), flags=flags
132
+ )
133
+
134
+
135
+ def restore_domain_with_parameters(
136
+ parameters: dict[str, TypedValue], *, flags: int = 0
137
+ ) -> Operation[None]:
138
+ """Start a domain from a save file, with the options of the parameter form.
139
+
140
+ :param parameters: ``file`` (required), ``dom_xml``, ``bandwidth``,
141
+ ``parallel.connections``, ...
142
+ :param flags: ``virDomainSaveRestoreFlags``.
143
+ """
144
+ yield Request(
145
+ "domain_restore_params", {"params": to_wire(parameters), "flags": flags}
146
+ )
147
+
148
+
149
+ def set_domain_launch_security_state(
150
+ domain: DomainRef, parameters: dict[str, TypedValue], *, flags: int = 0
151
+ ) -> Operation[None]:
152
+ """Set the launch security state of a confidential guest (e.g. its secret).
153
+
154
+ :param domain: the domain.
155
+ :param parameters: ``sev-secret``, ``sev-secret-header``, ``sev-secret-set-
156
+ address``.
157
+ :param flags: reserved, 0.
158
+ """
159
+ yield from on_domain(
160
+ domain,
161
+ "domain_set_launch_security_state",
162
+ params=to_wire(parameters),
163
+ flags=flags,
164
+ )
@@ -0,0 +1,113 @@
1
+ """Operations on the network interfaces of a running domain."""
2
+
3
+ from libvirtpy.client.operations._common import (
4
+ as_list,
5
+ as_struct,
6
+ get_typed_parameters,
7
+ on_domain,
8
+ )
9
+ from libvirtpy.client.references import DomainRef
10
+ from libvirtpy.client.transport import Operation
11
+ from libvirtpy.rpc.protocol import types
12
+ from libvirtpy.rpc.typed_params import TypedValue, to_wire
13
+
14
+ __all__ = [
15
+ "announce_domain_interface",
16
+ "get_domain_interface_parameters",
17
+ "get_domain_interface_stats",
18
+ "list_domain_interface_addresses",
19
+ "set_domain_interface_parameters",
20
+ ]
21
+
22
+
23
+ def get_domain_interface_stats(
24
+ domain: DomainRef, device: str
25
+ ) -> Operation[types.DomainInterfaceStatsRet]:
26
+ """Return the traffic counters of an interface of a running domain.
27
+
28
+ :param domain: the domain.
29
+ :param device: the host side device name (``vnet0``) or the MAC address.
30
+ :returns: the received and transmitted bytes, packets, errors and drops.
31
+ """
32
+ reply = yield from on_domain(domain, "domain_interface_stats", device=device)
33
+ return as_struct(reply, types.DomainInterfaceStatsRet)
34
+
35
+
36
+ def list_domain_interface_addresses(
37
+ domain: DomainRef, source: int = 0, *, flags: int = 0
38
+ ) -> Operation[list[types.DomainInterface]]:
39
+ """List the IP addresses of the interfaces of a running domain.
40
+
41
+ :param domain: the domain.
42
+ :param source: ``virDomainInterfaceAddressesSource``: 0 DHCP lease, 1 guest
43
+ agent, 2 ARP table.
44
+ :param flags: reserved, 0.
45
+ :returns: for each interface its ``name``, ``hwaddr`` and ``addrs``.
46
+ """
47
+ reply = yield from on_domain(
48
+ domain, "domain_interface_addresses", source=source, flags=flags
49
+ )
50
+ return [as_struct(item, types.DomainInterface) for item in as_list(reply)]
51
+
52
+
53
+ def get_domain_interface_parameters(
54
+ domain: DomainRef, device: str, *, flags: int = 0
55
+ ) -> Operation[dict[str, TypedValue]]:
56
+ """Return the bandwidth limits of an interface.
57
+
58
+ :param domain: the domain.
59
+ :param device: the host side device name or the MAC address.
60
+ :param flags: ``virDomainModificationImpact``: live, config.
61
+ :returns: ``inbound.average``, ``outbound.peak``, ...
62
+ """
63
+ return (
64
+ yield from get_typed_parameters(
65
+ domain, "domain_get_interface_parameters", flags, device=device
66
+ )
67
+ )
68
+
69
+
70
+ def set_domain_interface_parameters(
71
+ domain: DomainRef,
72
+ device: str,
73
+ parameters: dict[str, TypedValue],
74
+ *,
75
+ flags: int = 0,
76
+ ) -> Operation[None]:
77
+ """Change the bandwidth limits of an interface.
78
+
79
+ :param domain: the domain.
80
+ :param device: the host side device name or the MAC address.
81
+ :param parameters: e.g. ``{"inbound.average": 1000}``.
82
+ :param flags: ``virDomainModificationImpact``: live, config.
83
+ """
84
+ yield from on_domain(
85
+ domain,
86
+ "domain_set_interface_parameters",
87
+ device=device,
88
+ params=to_wire(parameters),
89
+ flags=flags,
90
+ )
91
+
92
+
93
+ def announce_domain_interface(
94
+ domain: DomainRef,
95
+ device: str | None = None,
96
+ parameters: dict[str, TypedValue] | None = None,
97
+ *,
98
+ flags: int = 0,
99
+ ) -> Operation[None]:
100
+ """Make the guest's interface announce itself on the network (gratuitous ARP).
101
+
102
+ :param domain: the domain.
103
+ :param device: the interface, by MAC address; ``None`` for all.
104
+ :param parameters: ``rounds``, ``initial``, ``max``, ``step``.
105
+ :param flags: ``virDomainModificationImpact``: live.
106
+ """
107
+ yield from on_domain(
108
+ domain,
109
+ "domain_announce_interface",
110
+ device=device,
111
+ params=to_wire(parameters or {}),
112
+ flags=flags,
113
+ )