-
Notifications
You must be signed in to change notification settings - Fork 6
/
types.go
475 lines (385 loc) · 16.4 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2022 Red Hat, Inc.
*
*/
package v1alpha2
import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "kubevirt.io/api/core/v1"
)
// VirtualMachineInstancetype resource contains quantitative and resource related VirtualMachine configuration
// that can be used by multiple VirtualMachine resources.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
type VirtualMachineInstancetype struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Required spec describing the instancetype
Spec VirtualMachineInstancetypeSpec `json:"spec"`
}
// VirtualMachineInstancetypeList is a list of VirtualMachineInstancetype resources.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type VirtualMachineInstancetypeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VirtualMachineInstancetype `json:"items"`
}
// VirtualMachineClusterInstancetype is a cluster scoped version of VirtualMachineInstancetype resource.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
// +genclient:nonNamespaced
type VirtualMachineClusterInstancetype struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Required spec describing the instancetype
Spec VirtualMachineInstancetypeSpec `json:"spec"`
}
// VirtualMachineClusterInstancetypeList is a list of VirtualMachineClusterInstancetype resources.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type VirtualMachineClusterInstancetypeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VirtualMachineClusterInstancetype `json:"items"`
}
// VirtualMachineInstancetypeSpec is a description of the VirtualMachineInstancetype or VirtualMachineClusterInstancetype.
//
// CPU and Memory are required attributes with both requiring that their Guest attribute is defined, ensuring a number of vCPUs and amount of RAM is always provided by each instancetype.
type VirtualMachineInstancetypeSpec struct {
// Required CPU related attributes of the instancetype.
CPU CPUInstancetype `json:"cpu"`
// Required Memory related attributes of the instancetype.
Memory MemoryInstancetype `json:"memory"`
// Optionally defines any GPU devices associated with the instancetype.
//
// +optional
// +listType=atomic
GPUs []v1.GPU `json:"gpus,omitempty"`
// Optionally defines any HostDevices associated with the instancetype.
//
// +optional
// +listType=atomic
HostDevices []v1.HostDevice `json:"hostDevices,omitempty"`
// Optionally defines the IOThreadsPolicy to be used by the instancetype.
//
// +optional
IOThreadsPolicy *v1.IOThreadsPolicy `json:"ioThreadsPolicy,omitempty"`
// Optionally defines the LaunchSecurity to be used by the instancetype.
//
// +optional
LaunchSecurity *v1.LaunchSecurity `json:"launchSecurity,omitempty"`
}
// CPUInstancetype contains the CPU related configuration of a given VirtualMachineInstancetypeSpec.
//
// Guest is a required attribute and defines the number of vCPUs to be exposed to the guest by the instancetype.
type CPUInstancetype struct {
// Required number of vCPUs to expose to the guest.
//
// The resulting CPU topology being derived from the optional PreferredCPUTopology attribute of CPUPreferences that itself defaults to PreferSockets.
Guest uint32 `json:"guest"`
// Model specifies the CPU model inside the VMI.
// List of available models https://github.com/libvirt/libvirt/tree/master/src/cpu_map.
// It is possible to specify special cases like "host-passthrough" to get the same CPU as the node
// and "host-model" to get CPU closest to the node one.
// Defaults to host-model.
// +optional
Model string `json:"model,omitempty"`
// DedicatedCPUPlacement requests the scheduler to place the VirtualMachineInstance on a node
// with enough dedicated pCPUs and pin the vCPUs to it.
// +optional
DedicatedCPUPlacement bool `json:"dedicatedCPUPlacement,omitempty"`
// NUMA allows specifying settings for the guest NUMA topology
// +optional
NUMA *v1.NUMA `json:"numa,omitempty"`
// IsolateEmulatorThread requests one more dedicated pCPU to be allocated for the VMI to place
// the emulator thread on it.
// +optional
IsolateEmulatorThread bool `json:"isolateEmulatorThread,omitempty"`
// Realtime instructs the virt-launcher to tune the VMI for lower latency, optional for real time workloads
// +optional
Realtime *v1.Realtime `json:"realtime,omitempty"`
}
// MemoryInstancetype contains the Memory related configuration of a given VirtualMachineInstancetypeSpec.
//
// Guest is a required attribute and defines the amount of RAM to be exposed to the guest by the instancetype.
type MemoryInstancetype struct {
// Required amount of memory which is visible inside the guest OS.
Guest resource.Quantity `json:"guest"`
// Optionally enables the use of hugepages for the VirtualMachineInstance instead of regular memory.
// +optional
Hugepages *v1.Hugepages `json:"hugepages,omitempty"`
}
// VirtualMachinePreference resource contains optional preferences related to the VirtualMachine.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
type VirtualMachinePreference struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Required spec describing the preferences
Spec VirtualMachinePreferenceSpec `json:"spec"`
}
// VirtualMachinePreferenceList is a list of VirtualMachinePreference resources.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type VirtualMachinePreferenceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// +listType=set
Items []VirtualMachinePreference `json:"items"`
}
// VirtualMachineClusterPreference is a cluster scoped version of the VirtualMachinePreference resource.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
// +genclient:nonNamespaced
type VirtualMachineClusterPreference struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Required spec describing the preferences
Spec VirtualMachinePreferenceSpec `json:"spec"`
}
// VirtualMachineClusterPreferenceList is a list of VirtualMachineClusterPreference resources.
//
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type VirtualMachineClusterPreferenceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// +listType=set
Items []VirtualMachineClusterPreference `json:"items"`
}
// VirtualMachinePreferenceSpec is a description of the VirtualMachinePreference or VirtualMachineClusterPreference.
type VirtualMachinePreferenceSpec struct {
// Clock optionally defines preferences associated with the Clock attribute of a VirtualMachineInstance DomainSpec
//
//+optional
Clock *ClockPreferences `json:"clock,omitempty"`
// CPU optionally defines preferences associated with the CPU attribute of a VirtualMachineInstance DomainSpec
//
//+optional
CPU *CPUPreferences `json:"cpu,omitempty"`
// Devices optionally defines preferences associated with the Devices attribute of a VirtualMachineInstance DomainSpec
//
//+optional
Devices *DevicePreferences `json:"devices,omitempty"`
// Features optionally defines preferences associated with the Features attribute of a VirtualMachineInstance DomainSpec
//
//+optional
Features *FeaturePreferences `json:"features,omitempty"`
// Firmware optionally defines preferences associated with the Firmware attribute of a VirtualMachineInstance DomainSpec
//
//+optional
Firmware *FirmwarePreferences `json:"firmware,omitempty"`
// Machine optionally defines preferences associated with the Machine attribute of a VirtualMachineInstance DomainSpec
//
//+optional
Machine *MachinePreferences `json:"machine,omitempty"`
// Volumes optionally defines preferences associated with the Volumes attribute of a VirtualMachineInstace DomainSpec
//
//+optional
Volumes *VolumePreferences `json:"volumes,omitempty"`
}
type VolumePreferences struct {
// PreffereedStorageClassName optionally defines the preferred storageClass
//
//+optional
PreferredStorageClassName string `json:"preferredStorageClassName,omitempty"`
}
// PreferredCPUTopology defines a preferred CPU topology to be exposed to the guest
type PreferredCPUTopology string
const (
// Prefer vCPUs to be exposed as cores to the guest
PreferCores PreferredCPUTopology = "preferCores"
// Prefer vCPUs to be exposed as sockets to the guest, this is the default for the PreferredCPUTopology attribute of CPUPreferences.
PreferSockets PreferredCPUTopology = "preferSockets"
// Prefer vCPUs to be exposed as threads to the guest
PreferThreads PreferredCPUTopology = "preferThreads"
)
// CPUPreferences contains various optional CPU preferences.
type CPUPreferences struct {
// PreferredCPUTopology optionally defines the preferred guest visible CPU topology, defaults to PreferSockets.
//
//+optional
PreferredCPUTopology PreferredCPUTopology `json:"preferredCPUTopology,omitempty"`
}
// DevicePreferences contains various optional Device preferences.
type DevicePreferences struct {
// PreferredAutoattachGraphicsDevice optionally defines the preferred value of AutoattachGraphicsDevice
//
// +optional
PreferredAutoattachGraphicsDevice *bool `json:"preferredAutoattachGraphicsDevice,omitempty"`
// PreferredAutoattachMemBalloon optionally defines the preferred value of AutoattachMemBalloon
//
// +optional
PreferredAutoattachMemBalloon *bool `json:"preferredAutoattachMemBalloon,omitempty"`
// PreferredAutoattachPodInterface optionally defines the preferred value of AutoattachPodInterface
//
// +optional
PreferredAutoattachPodInterface *bool `json:"preferredAutoattachPodInterface,omitempty"`
// PreferredAutoattachSerialConsole optionally defines the preferred value of AutoattachSerialConsole
//
// +optional
PreferredAutoattachSerialConsole *bool `json:"preferredAutoattachSerialConsole,omitempty"`
// PreferredAutoattachInputDevice optionally defines the preferred value of AutoattachInputDevice
//
// +optional
PreferredAutoattachInputDevice *bool `json:"preferredAutoattachInputDevice,omitempty"`
// PreferredDisableHotplug optionally defines the preferred value of DisableHotplug
//
// +optional
PreferredDisableHotplug *bool `json:"preferredDisableHotplug,omitempty"`
// PreferredVirtualGPUOptions optionally defines the preferred value of VirtualGPUOptions
//
// +optional
PreferredVirtualGPUOptions *v1.VGPUOptions `json:"preferredVirtualGPUOptions,omitempty"`
// PreferredSoundModel optionally defines the preferred model for Sound devices.
//
// +optional
PreferredSoundModel string `json:"preferredSoundModel,omitempty"`
// PreferredUseVirtioTransitional optionally defines the preferred value of UseVirtioTransitional
//
// +optional
PreferredUseVirtioTransitional *bool `json:"preferredUseVirtioTransitional,omitempty"`
// PreferredInputBus optionally defines the preferred bus for Input devices.
//
// +optional
PreferredInputBus v1.InputBus `json:"preferredInputBus,omitempty"`
// PreferredInputType optionally defines the preferred type for Input devices.
//
// +optional
PreferredInputType v1.InputType `json:"preferredInputType,omitempty"`
// PreferredDiskBus optionally defines the preferred bus for Disk Disk devices.
//
// +optional
PreferredDiskBus v1.DiskBus `json:"preferredDiskBus,omitempty"`
// PreferredLunBus optionally defines the preferred bus for Lun Disk devices.
//
// +optional
PreferredLunBus v1.DiskBus `json:"preferredLunBus,omitempty"`
// PreferredCdromBus optionally defines the preferred bus for Cdrom Disk devices.
//
// +optional
PreferredCdromBus v1.DiskBus `json:"preferredCdromBus,omitempty"`
// PreferredDedicatedIoThread optionally enables dedicated IO threads for Disk devices.
//
// +optional
PreferredDiskDedicatedIoThread *bool `json:"preferredDiskDedicatedIoThread,omitempty"`
// PreferredCache optionally defines the DriverCache to be used by Disk devices.
//
// +optional
PreferredDiskCache v1.DriverCache `json:"preferredDiskCache,omitempty"`
// PreferredIo optionally defines the QEMU disk IO mode to be used by Disk devices.
//
// +optional
PreferredDiskIO v1.DriverIO `json:"preferredDiskIO,omitempty"`
// PreferredBlockSize optionally defines the block size of Disk devices.
//
// +optional
PreferredDiskBlockSize *v1.BlockSize `json:"preferredDiskBlockSize,omitempty"`
// PreferredInterfaceModel optionally defines the preferred model to be used by Interface devices.
//
// +optional
PreferredInterfaceModel string `json:"preferredInterfaceModel,omitempty"`
// PreferredRng optionally defines the preferred rng device to be used.
//
// +optional
PreferredRng *v1.Rng `json:"preferredRng,omitempty"`
// PreferredBlockMultiQueue optionally enables the vhost multiqueue feature for virtio disks.
//
// +optional
PreferredBlockMultiQueue *bool `json:"preferredBlockMultiQueue,omitempty"`
// PreferredNetworkInterfaceMultiQueue optionally enables the vhost multiqueue feature for virtio interfaces.
//
// +optional
PreferredNetworkInterfaceMultiQueue *bool `json:"preferredNetworkInterfaceMultiQueue,omitempty"`
// PreferredTPM optionally defines the preferred TPM device to be used.
//
// +optional
PreferredTPM *v1.TPMDevice `json:"preferredTPM,omitempty"`
}
// FeaturePreferences contains various optional defaults for Features.
type FeaturePreferences struct {
// PreferredAcpi optionally enables the ACPI feature
//
// +optional
PreferredAcpi *v1.FeatureState `json:"preferredAcpi,omitempty"`
// PreferredApic optionally enables and configures the APIC feature
//
// +optional
PreferredApic *v1.FeatureAPIC `json:"preferredApic,omitempty"`
// PreferredHyperv optionally enables and configures HyperV features
//
// +optional
PreferredHyperv *v1.FeatureHyperv `json:"preferredHyperv,omitempty"`
// PreferredKvm optionally enables and configures KVM features
//
// +optional
PreferredKvm *v1.FeatureKVM `json:"preferredKvm,omitempty"`
// PreferredPvspinlock optionally enables the Pvspinlock feature
//
// +optional
PreferredPvspinlock *v1.FeatureState `json:"preferredPvspinlock,omitempty"`
// PreferredSmm optionally enables the SMM feature
//
// +optional
PreferredSmm *v1.FeatureState `json:"preferredSmm,omitempty"`
}
// FirmwarePreferences contains various optional defaults for Firmware.
type FirmwarePreferences struct {
// PreferredUseBios optionally enables BIOS
//
// +optional
PreferredUseBios *bool `json:"preferredUseBios,omitempty"`
// PreferredUseBiosSerial optionally transmitts BIOS output over the serial.
//
// Requires PreferredUseBios to be enabled.
//
// +optional
PreferredUseBiosSerial *bool `json:"preferredUseBiosSerial,omitempty"`
// PreferredUseEfi optionally enables EFI
//
// +optional
PreferredUseEfi *bool `json:"preferredUseEfi,omitempty"`
// PreferredUseSecureBoot optionally enables SecureBoot and the OVMF roms will be swapped for SecureBoot-enabled ones.
//
// Requires PreferredUseEfi and PreferredSmm to be enabled.
//
// +optional
PreferredUseSecureBoot *bool `json:"preferredUseSecureBoot,omitempty"`
}
// MachinePreferences contains various optional defaults for Machine.
type MachinePreferences struct {
// PreferredMachineType optionally defines the preferred machine type to use.
//
// +optional
PreferredMachineType string `json:"preferredMachineType,omitempty"`
}
// ClockPreferences contains various optional defaults for Clock.
type ClockPreferences struct {
// ClockOffset allows specifying the UTC offset or the timezone of the guest clock.
//
// +optional
PreferredClockOffset *v1.ClockOffset `json:"preferredClockOffset,omitempty"`
// Timer specifies whih timers are attached to the vmi.
//
// +optional
PreferredTimer *v1.Timer `json:"preferredTimer,omitempty"`
}