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,436 @@
1
+ """``<domainCapabilities>``: what a hypervisor supports for a domain.
2
+
3
+ Read-only: libvirt generates it, you only parse it. Most of it is a list of
4
+ blocks that say whether a feature is ``supported`` and which values of it are
5
+ allowed (``<enum>``), so those share ``FeatureSupport``.
6
+
7
+ See https://libvirt.org/formatdomaincaps.html
8
+ """
9
+
10
+ from typing import Literal, cast
11
+
12
+ from lxml import etree as lxml_etree
13
+ from pydantic_xml import attr, element, xml_field_serializer
14
+ from pydantic_xml.element.element import XmlElementWriter
15
+
16
+ from libvirtpy.xml._base import LibvirtXmlModel
17
+ from libvirtpy.xml._xml_element import StableXmlElement
18
+
19
+ __all__ = [
20
+ "CapsEnum",
21
+ "DomainCapabilities",
22
+ "FeatureSupport",
23
+ ]
24
+
25
+ YesNo = Literal["yes", "no"]
26
+
27
+
28
+ class CapsEnum(LibvirtXmlModel, tag="enum"):
29
+ """``<enum>``: the allowed values of an option."""
30
+
31
+ name: str = attr(name="name")
32
+ values: list[str] = element(tag="value", default_factory=list)
33
+
34
+
35
+ class FeatureSupport(LibvirtXmlModel):
36
+ """Base of the blocks that say ``supported`` and list their ``<enum>``\\ s."""
37
+
38
+ supported: YesNo = attr(name="supported")
39
+ enums: list[CapsEnum] = element(tag="enum", default_factory=list)
40
+
41
+
42
+ class CapsVcpu(LibvirtXmlModel, tag="vcpu"):
43
+ max: int = attr(name="max", ge=0)
44
+
45
+
46
+ class CapsIothreads(LibvirtXmlModel, tag="iothreads"):
47
+ supported: YesNo = attr(name="supported")
48
+
49
+
50
+ class CapsFirmwareFeatures(FeatureSupport, tag="firmwareFeatures"):
51
+ """``<firmwareFeatures>``: firmware features the hypervisor can select."""
52
+
53
+
54
+ class CapsLoader(LibvirtXmlModel, tag="loader"):
55
+ """``<loader>``: the firmware images that can be used.
56
+
57
+ Not a ``FeatureSupport``: the schema wants the ``<value>`` elements before
58
+ the ``<enum>`` elements, and a base class's fields are written first.
59
+ """
60
+
61
+ supported: YesNo = attr(name="supported")
62
+ values: list[str] = element(tag="value", default_factory=list)
63
+ enums: list[CapsEnum] = element(tag="enum", default_factory=list)
64
+
65
+
66
+ class CapsVarstore(LibvirtXmlModel, tag="varstore"):
67
+ supported: YesNo = attr(name="supported")
68
+
69
+
70
+ class CapsOs(FeatureSupport, tag="os"):
71
+ """``<os>``: what ``<os>`` can be set to."""
72
+
73
+ firmware_features: CapsFirmwareFeatures | None = element(
74
+ tag="firmwareFeatures", default=None
75
+ )
76
+ loader: CapsLoader | None = element(tag="loader", default=None)
77
+ varstore: CapsVarstore | None = element(tag="varstore", default=None)
78
+
79
+
80
+ class CapsCpuModel(LibvirtXmlModel, tag="model"):
81
+ """``<model>`` of the ``host-model`` mode: the CPU the host would expose."""
82
+
83
+ value: str = ""
84
+ fallback: Literal["allow", "forbid"] | None = attr(name="fallback", default=None)
85
+ vendor_id: str | None = attr(name="vendor_id", default=None)
86
+
87
+
88
+ class CapsCpuMaxPhysAddr(LibvirtXmlModel, tag="maxphysaddr"):
89
+ mode: Literal["emulate", "passthrough"] = attr(name="mode")
90
+ bits: int | None = attr(name="bits", default=None, ge=0)
91
+ limit: int | None = attr(name="limit", default=None, ge=0)
92
+
93
+
94
+ class CapsCpuFeature(LibvirtXmlModel, tag="feature"):
95
+ policy: Literal["force", "require", "optional", "disable", "forbid"] = attr(
96
+ name="policy"
97
+ )
98
+ name: str = attr(name="name")
99
+
100
+
101
+ class HostPassthroughMode(FeatureSupport, tag="mode"):
102
+ """``<mode name='host-passthrough'>``."""
103
+
104
+ name: Literal["host-passthrough"] = attr(name="name")
105
+
106
+
107
+ class MaximumMode(FeatureSupport, tag="mode"):
108
+ """``<mode name='maximum'>``."""
109
+
110
+ name: Literal["maximum"] = attr(name="name")
111
+
112
+
113
+ class HostModelMode(LibvirtXmlModel, tag="mode"):
114
+ """``<mode name='host-model'>``."""
115
+
116
+ name: Literal["host-model"] = attr(name="name")
117
+ supported: YesNo = attr(name="supported")
118
+ model: CapsCpuModel | None = element(tag="model", default=None)
119
+ vendor: str | None = element(tag="vendor", default=None)
120
+ maxphysaddr: CapsCpuMaxPhysAddr | None = element(tag="maxphysaddr", default=None)
121
+ features: list[CapsCpuFeature] = element(tag="feature", default_factory=list)
122
+
123
+
124
+ class CustomModel(LibvirtXmlModel, tag="model"):
125
+ """``<model>`` of the ``custom`` mode: a CPU model the hypervisor knows."""
126
+
127
+ value: str = ""
128
+ usable: Literal["yes", "no", "unknown"] = attr(name="usable")
129
+ deprecated: YesNo | None = attr(name="deprecated", default=None)
130
+ canonical: str | None = attr(name="canonical", default=None)
131
+ vendor: str = attr(name="vendor")
132
+
133
+
134
+ class BlockerFeature(LibvirtXmlModel, tag="feature"):
135
+ name: str = attr(name="name")
136
+
137
+
138
+ class CustomBlockers(LibvirtXmlModel, tag="blockers"):
139
+ """``<blockers>``: the host features that make a CPU model unusable."""
140
+
141
+ model: str = attr(name="model")
142
+ features: list[BlockerFeature] = element(tag="feature", default_factory=list)
143
+
144
+
145
+ class CustomMode(LibvirtXmlModel, tag="mode"):
146
+ """``<mode name='custom'>``: the named CPU models.
147
+
148
+ libvirt writes the ``<blockers>`` of an unusable model right after that
149
+ model, and the schema requires it. ``models`` and ``blockers`` are two
150
+ lists; they are written back interleaved, each ``<blockers model=X>``
151
+ after the model ``X`` it explains.
152
+ """
153
+
154
+ name: Literal["custom"] = attr(name="name")
155
+ supported: YesNo = attr(name="supported")
156
+ models: list[CustomModel] = element(tag="model", default_factory=list)
157
+ blockers: list[CustomBlockers] = element(tag="blockers", default_factory=list)
158
+
159
+ @xml_field_serializer("models")
160
+ def _write_models(
161
+ self, element: XmlElementWriter, value: list[CustomModel], field_name: str
162
+ ) -> XmlElementWriter:
163
+ """Write each model, followed by the ``<blockers>`` that explain it.
164
+
165
+ :param element: the ``<mode>`` element being written.
166
+ :param value: the models to write.
167
+ :param field_name: the field this writer serializes (``models``).
168
+ :returns: ``element``, with the children appended.
169
+ """
170
+ for model in value:
171
+ element.append_element(_as_element(model))
172
+ for blockers in self.blockers:
173
+ if blockers.model == model.value:
174
+ element.append_element(_as_element(blockers))
175
+ return element
176
+
177
+ @xml_field_serializer("blockers")
178
+ def _write_unmatched_blockers(
179
+ self, element: XmlElementWriter, value: list[CustomBlockers], field_name: str
180
+ ) -> XmlElementWriter:
181
+ """Write the ``<blockers>`` that name no model of this mode.
182
+
183
+ :param element: the ``<mode>`` element being written.
184
+ :param value: all the blockers of the mode.
185
+ :param field_name: the field this writer serializes (``blockers``).
186
+ :returns: ``element``, with the children appended.
187
+ """
188
+ model_names = {model.value for model in self.models}
189
+ for blockers in value:
190
+ if blockers.model not in model_names:
191
+ element.append_element(_as_element(blockers))
192
+ return element
193
+
194
+
195
+ CpuMode = HostPassthroughMode | MaximumMode | HostModelMode | CustomMode
196
+
197
+
198
+ """Any ``<mode>`` of ``<cpu>``; the variant is chosen by its ``name`` attribute."""
199
+
200
+
201
+ class CapsCpu(LibvirtXmlModel, tag="cpu"):
202
+ """``<cpu>``: the CPU modes the hypervisor supports."""
203
+
204
+ modes: list[CpuMode] = element(tag="mode", default_factory=list)
205
+
206
+
207
+ class CapsMemoryBacking(FeatureSupport, tag="memoryBacking"):
208
+ """``<memoryBacking>``: the memory backing options."""
209
+
210
+
211
+ class DiskCaps(FeatureSupport, tag="disk"):
212
+ """``<disk>``: the disk options."""
213
+
214
+
215
+ class GraphicsCaps(FeatureSupport, tag="graphics"):
216
+ """``<graphics>``: the graphics types."""
217
+
218
+
219
+ class VideoCaps(FeatureSupport, tag="video"):
220
+ """``<video>``: the video models."""
221
+
222
+
223
+ class HostdevCaps(FeatureSupport, tag="hostdev"):
224
+ """``<hostdev>``: the host device types."""
225
+
226
+
227
+ class RngCaps(FeatureSupport, tag="rng"):
228
+ """``<rng>``: the RNG models and backends."""
229
+
230
+
231
+ class FilesystemCaps(FeatureSupport, tag="filesystem"):
232
+ """``<filesystem>``: the filesystem drivers."""
233
+
234
+
235
+ class TpmCaps(FeatureSupport, tag="tpm"):
236
+ """``<tpm>``: the TPM models and backends."""
237
+
238
+
239
+ class RedirdevCaps(FeatureSupport, tag="redirdev"):
240
+ """``<redirdev>``: the redirection buses."""
241
+
242
+
243
+ class ChannelCaps(FeatureSupport, tag="channel"):
244
+ """``<channel>``: the channel types."""
245
+
246
+
247
+ class CryptoCaps(FeatureSupport, tag="crypto"):
248
+ """``<crypto>``: the crypto models."""
249
+
250
+
251
+ class InterfaceCaps(FeatureSupport, tag="interface"):
252
+ """``<interface>``: the interface backends."""
253
+
254
+
255
+ class PanicCaps(FeatureSupport, tag="panic"):
256
+ """``<panic>``: the panic models."""
257
+
258
+
259
+ class ConsoleCaps(FeatureSupport, tag="console"):
260
+ """``<console>``: the console models."""
261
+
262
+
263
+ class CapsDevices(LibvirtXmlModel, tag="devices"):
264
+ """``<devices>``: what each kind of device supports."""
265
+
266
+ disk: DiskCaps | None = element(tag="disk", default=None)
267
+ graphics: GraphicsCaps | None = element(tag="graphics", default=None)
268
+ video: VideoCaps | None = element(tag="video", default=None)
269
+ hostdev: HostdevCaps | None = element(tag="hostdev", default=None)
270
+ rng: RngCaps | None = element(tag="rng", default=None)
271
+ filesystem: FilesystemCaps | None = element(tag="filesystem", default=None)
272
+ tpm: TpmCaps | None = element(tag="tpm", default=None)
273
+ redirdev: RedirdevCaps | None = element(tag="redirdev", default=None)
274
+ channel: ChannelCaps | None = element(tag="channel", default=None)
275
+ crypto: CryptoCaps | None = element(tag="crypto", default=None)
276
+ interface: InterfaceCaps | None = element(tag="interface", default=None)
277
+ panic: PanicCaps | None = element(tag="panic", default=None)
278
+ console: ConsoleCaps | None = element(tag="console", default=None)
279
+
280
+
281
+ class SupportOnly(LibvirtXmlModel):
282
+ """Base of the features that only say whether they are supported."""
283
+
284
+ supported: YesNo = attr(name="supported")
285
+
286
+
287
+ class GicCaps(FeatureSupport, tag="gic"):
288
+ """``<gic>``: the interrupt controller versions."""
289
+
290
+
291
+ class VmcoreinfoCaps(SupportOnly, tag="vmcoreinfo"):
292
+ """``<vmcoreinfo>``."""
293
+
294
+
295
+ class GenidCaps(SupportOnly, tag="genid"):
296
+ """``<genid>``: VM generation ID."""
297
+
298
+
299
+ class BackingStoreInputCaps(SupportOnly, tag="backingStoreInput"):
300
+ """``<backingStoreInput>``."""
301
+
302
+
303
+ class BackupCaps(SupportOnly, tag="backup"):
304
+ """``<backup>``."""
305
+
306
+
307
+ class AsyncTeardownCaps(SupportOnly, tag="async-teardown"):
308
+ """``<async-teardown>``."""
309
+
310
+
311
+ class S390PvCaps(SupportOnly, tag="s390-pv"):
312
+ """``<s390-pv>``."""
313
+
314
+
315
+ class Ps2Caps(SupportOnly, tag="ps2"):
316
+ """``<ps2>``."""
317
+
318
+
319
+ class TdxCaps(SupportOnly, tag="tdx"):
320
+ """``<tdx>``."""
321
+
322
+
323
+ class SevCaps(SupportOnly, tag="sev"):
324
+ """``<sev>``: AMD SEV parameters of the host."""
325
+
326
+ cbitpos: int | None = element(tag="cbitpos", default=None, ge=0)
327
+ reduced_phys_bits: int | None = element(tag="reducedPhysBits", default=None, ge=0)
328
+ max_guests: int | None = element(tag="maxGuests", default=None, ge=0)
329
+ max_es_guests: int | None = element(tag="maxESGuests", default=None, ge=0)
330
+ cpu0_id: str | None = element(tag="cpu0Id", default=None)
331
+
332
+
333
+ class SgxSize(LibvirtXmlModel):
334
+ """Base of ``<section_size>``: an amount in KiB."""
335
+
336
+ value: int
337
+ unit: Literal["KiB"] = attr(name="unit")
338
+
339
+
340
+ class SgxSectionSize(SgxSize, tag="section_size"):
341
+ """``<section_size>``: the size of the EPC sections."""
342
+
343
+
344
+ class SgxSection(LibvirtXmlModel, tag="section"):
345
+ node: int = attr(name="node", ge=0)
346
+ size: int = attr(name="size", ge=0)
347
+ unit: Literal["KiB"] = attr(name="unit")
348
+
349
+
350
+ class SgxSections(LibvirtXmlModel, tag="sections"):
351
+ sections: list[SgxSection] = element(tag="section", default_factory=list)
352
+
353
+
354
+ class SgxCaps(SupportOnly, tag="sgx"):
355
+ """``<sgx>``: Intel SGX parameters of the host."""
356
+
357
+ flc: YesNo | None = element(tag="flc", default=None)
358
+ sgx1: YesNo | None = element(tag="sgx1", default=None)
359
+ sgx2: YesNo | None = element(tag="sgx2", default=None)
360
+ section_size: SgxSectionSize | None = element(tag="section_size", default=None)
361
+ sections: SgxSections | None = element(tag="sections", default=None)
362
+
363
+
364
+ class HypervDefaults(LibvirtXmlModel, tag="defaults"):
365
+ spinlocks: int | None = element(tag="spinlocks", default=None, ge=0)
366
+ stimer_direct: Literal["on", "off"] | None = element(
367
+ tag="stimer_direct", default=None
368
+ )
369
+ tlbflush_direct: Literal["on", "off"] | None = element(
370
+ tag="tlbflush_direct", default=None
371
+ )
372
+ tlbflush_extended: Literal["on", "off"] | None = element(
373
+ tag="tlbflush_extended", default=None
374
+ )
375
+ vendor_id: str | None = element(tag="vendor_id", default=None)
376
+
377
+
378
+ class HypervCaps(FeatureSupport, tag="hyperv"):
379
+ """``<hyperv>``: the supported enlightenments and their defaults."""
380
+
381
+ defaults: HypervDefaults | None = element(tag="defaults", default=None)
382
+
383
+
384
+ class LaunchSecurityCaps(FeatureSupport, tag="launchSecurity"):
385
+ """``<launchSecurity>``: the launch security types."""
386
+
387
+
388
+ class CapsFeatures(LibvirtXmlModel, tag="features"):
389
+ """``<features>``: the domain features the hypervisor supports."""
390
+
391
+ gic: GicCaps | None = element(tag="gic", default=None)
392
+ vmcoreinfo: VmcoreinfoCaps | None = element(tag="vmcoreinfo", default=None)
393
+ genid: GenidCaps | None = element(tag="genid", default=None)
394
+ backing_store_input: BackingStoreInputCaps | None = element(
395
+ tag="backingStoreInput", default=None
396
+ )
397
+ backup: BackupCaps | None = element(tag="backup", default=None)
398
+ async_teardown: AsyncTeardownCaps | None = element(
399
+ tag="async-teardown", default=None
400
+ )
401
+ s390_pv: S390PvCaps | None = element(tag="s390-pv", default=None)
402
+ ps2: Ps2Caps | None = element(tag="ps2", default=None)
403
+ tdx: TdxCaps | None = element(tag="tdx", default=None)
404
+ sev: SevCaps | None = element(tag="sev", default=None)
405
+ sgx: SgxCaps | None = element(tag="sgx", default=None)
406
+ hyperv: HypervCaps | None = element(tag="hyperv", default=None)
407
+ launch_security: LaunchSecurityCaps | None = element(
408
+ tag="launchSecurity", default=None
409
+ )
410
+
411
+
412
+ class DomainCapabilities(LibvirtXmlModel, tag="domainCapabilities"):
413
+ """``<domainCapabilities>``: what a hypervisor supports for one domain type."""
414
+
415
+ path: str | None = element(tag="path", default=None)
416
+ domain: str = element(tag="domain")
417
+ machine: str | None = element(tag="machine", default=None)
418
+ arch: str = element(tag="arch")
419
+ vcpu: CapsVcpu | None = element(tag="vcpu", default=None)
420
+ iothreads: CapsIothreads | None = element(tag="iothreads", default=None)
421
+ os: CapsOs | None = element(tag="os", default=None)
422
+ cpu: CapsCpu | None = element(tag="cpu", default=None)
423
+ memory_backing: CapsMemoryBacking | None = element(
424
+ tag="memoryBacking", default=None
425
+ )
426
+ devices: CapsDevices | None = element(tag="devices", default=None)
427
+ features: CapsFeatures | None = element(tag="features", default=None)
428
+
429
+
430
+ def _as_element(model: LibvirtXmlModel) -> StableXmlElement:
431
+ """Return the XML of ``model`` as an element for a custom field serializer.
432
+
433
+ :param model: the model to convert.
434
+ :returns: its element, ready to append to the element being written.
435
+ """
436
+ return StableXmlElement.from_native(cast(lxml_etree._Element, model.to_xml_tree()))