kubevirt.io/api@v1.2.0/core/v1/schema.go (about)

     1  /*
     2   * This file is part of the KubeVirt project
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   *
    16   * Copyright 2017, 2018 Red Hat, Inc.
    17   *
    18   */
    19  
    20  package v1
    21  
    22  import (
    23  	"encoding/json"
    24  
    25  	v1 "k8s.io/api/core/v1"
    26  	"k8s.io/apimachinery/pkg/api/resource"
    27  	"k8s.io/apimachinery/pkg/types"
    28  )
    29  
    30  type IOThreadsPolicy string
    31  
    32  const (
    33  	IOThreadsPolicyShared  IOThreadsPolicy = "shared"
    34  	IOThreadsPolicyAuto    IOThreadsPolicy = "auto"
    35  	CPUModeHostPassthrough                 = "host-passthrough"
    36  	CPUModeHostModel                       = "host-model"
    37  	DefaultCPUModel                        = CPUModeHostModel
    38  )
    39  
    40  const HotplugDiskDir = "/var/run/kubevirt/hotplug-disks/"
    41  
    42  type DiskErrorPolicy string
    43  
    44  const (
    45  	DiskErrorPolicyStop     DiskErrorPolicy = "stop"
    46  	DiskErrorPolicyIgnore   DiskErrorPolicy = "ignore"
    47  	DiskErrorPolicyReport   DiskErrorPolicy = "report"
    48  	DiskErrorPolicyEnospace DiskErrorPolicy = "enospace"
    49  )
    50  
    51  /*
    52   ATTENTION: Rerun code generators when comments on structs or fields are modified.
    53  */
    54  
    55  // Represents a disk created on the cluster level
    56  type HostDisk struct {
    57  	// The path to HostDisk image located on the cluster
    58  	Path string `json:"path"`
    59  	// Contains information if disk.img exists or should be created
    60  	// allowed options are 'Disk' and 'DiskOrCreate'
    61  	Type HostDiskType `json:"type"`
    62  	// Capacity of the sparse disk
    63  	// +optional
    64  	Capacity resource.Quantity `json:"capacity,omitempty"`
    65  	// Shared indicate whether the path is shared between nodes
    66  	Shared *bool `json:"shared,omitempty"`
    67  }
    68  
    69  // ConfigMapVolumeSource adapts a ConfigMap into a volume.
    70  // More info: https://kubernetes.io/docs/concepts/storage/volumes/#configmap
    71  type ConfigMapVolumeSource struct {
    72  	v1.LocalObjectReference `json:",inline"`
    73  	// Specify whether the ConfigMap or it's keys must be defined
    74  	// +optional
    75  	Optional *bool `json:"optional,omitempty"`
    76  	// The volume label of the resulting disk inside the VMI.
    77  	// Different bootstrapping mechanisms require different values.
    78  	// Typical values are "cidata" (cloud-init), "config-2" (cloud-init) or "OEMDRV" (kickstart).
    79  	// +optional
    80  	VolumeLabel string `json:"volumeLabel,omitempty"`
    81  }
    82  
    83  // SecretVolumeSource adapts a Secret into a volume.
    84  type SecretVolumeSource struct {
    85  	// Name of the secret in the pod's namespace to use.
    86  	// More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
    87  	SecretName string `json:"secretName,omitempty"`
    88  	// Specify whether the Secret or it's keys must be defined
    89  	// +optional
    90  	Optional *bool `json:"optional,omitempty"`
    91  	// The volume label of the resulting disk inside the VMI.
    92  	// Different bootstrapping mechanisms require different values.
    93  	// Typical values are "cidata" (cloud-init), "config-2" (cloud-init) or "OEMDRV" (kickstart).
    94  	// +optional
    95  	VolumeLabel string `json:"volumeLabel,omitempty"`
    96  }
    97  
    98  // DownwardAPIVolumeSource represents a volume containing downward API info.
    99  type DownwardAPIVolumeSource struct {
   100  	// Fields is a list of downward API volume file
   101  	// +optional
   102  	Fields []v1.DownwardAPIVolumeFile `json:"fields,omitempty"`
   103  	// The volume label of the resulting disk inside the VMI.
   104  	// Different bootstrapping mechanisms require different values.
   105  	// Typical values are "cidata" (cloud-init), "config-2" (cloud-init) or "OEMDRV" (kickstart).
   106  	// +optional
   107  	VolumeLabel string `json:"volumeLabel,omitempty"`
   108  }
   109  
   110  // ServiceAccountVolumeSource adapts a ServiceAccount into a volume.
   111  type ServiceAccountVolumeSource struct {
   112  	// Name of the service account in the pod's namespace to use.
   113  	// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
   114  	ServiceAccountName string `json:"serviceAccountName,omitempty"`
   115  }
   116  
   117  // DownwardMetricsVolumeSource adds a very small disk to VMIs which contains a limited view of host and guest
   118  // metrics. The disk content is compatible with vhostmd (https://github.com/vhostmd/vhostmd) and vm-dump-metrics.
   119  type DownwardMetricsVolumeSource struct {
   120  }
   121  
   122  // Represents a Sysprep volume source.
   123  type SysprepSource struct {
   124  	// Secret references a k8s Secret that contains Sysprep answer file named autounattend.xml that should be attached as disk of CDROM type.
   125  	// + optional
   126  	Secret *v1.LocalObjectReference `json:"secret,omitempty"`
   127  	// ConfigMap references a ConfigMap that contains Sysprep answer file named autounattend.xml that should be attached as disk of CDROM type.
   128  	// + optional
   129  	ConfigMap *v1.LocalObjectReference `json:"configMap,omitempty"`
   130  }
   131  
   132  // Represents a cloud-init nocloud user data source.
   133  // More info: http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
   134  type CloudInitNoCloudSource struct {
   135  	// UserDataSecretRef references a k8s secret that contains NoCloud userdata.
   136  	// + optional
   137  	UserDataSecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
   138  	// UserDataBase64 contains NoCloud cloud-init userdata as a base64 encoded string.
   139  	// + optional
   140  	UserDataBase64 string `json:"userDataBase64,omitempty"`
   141  	// UserData contains NoCloud inline cloud-init userdata.
   142  	// + optional
   143  	UserData string `json:"userData,omitempty"`
   144  	// NetworkDataSecretRef references a k8s secret that contains NoCloud networkdata.
   145  	// + optional
   146  	NetworkDataSecretRef *v1.LocalObjectReference `json:"networkDataSecretRef,omitempty"`
   147  	// NetworkDataBase64 contains NoCloud cloud-init networkdata as a base64 encoded string.
   148  	// + optional
   149  	NetworkDataBase64 string `json:"networkDataBase64,omitempty"`
   150  	// NetworkData contains NoCloud inline cloud-init networkdata.
   151  	// + optional
   152  	NetworkData string `json:"networkData,omitempty"`
   153  }
   154  
   155  // Represents a cloud-init config drive user data source.
   156  // More info: https://cloudinit.readthedocs.io/en/latest/topics/datasources/configdrive.html
   157  type CloudInitConfigDriveSource struct {
   158  	// UserDataSecretRef references a k8s secret that contains config drive userdata.
   159  	// + optional
   160  	UserDataSecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"`
   161  	// UserDataBase64 contains config drive cloud-init userdata as a base64 encoded string.
   162  	// + optional
   163  	UserDataBase64 string `json:"userDataBase64,omitempty"`
   164  	// UserData contains config drive inline cloud-init userdata.
   165  	// + optional
   166  	UserData string `json:"userData,omitempty"`
   167  	// NetworkDataSecretRef references a k8s secret that contains config drive networkdata.
   168  	// + optional
   169  	NetworkDataSecretRef *v1.LocalObjectReference `json:"networkDataSecretRef,omitempty"`
   170  	// NetworkDataBase64 contains config drive cloud-init networkdata as a base64 encoded string.
   171  	// + optional
   172  	NetworkDataBase64 string `json:"networkDataBase64,omitempty"`
   173  	// NetworkData contains config drive inline cloud-init networkdata.
   174  	// + optional
   175  	NetworkData string `json:"networkData,omitempty"`
   176  }
   177  
   178  type DomainSpec struct {
   179  	// Resources describes the Compute Resources required by this vmi.
   180  	Resources ResourceRequirements `json:"resources,omitempty"`
   181  	// CPU allow specified the detailed CPU topology inside the vmi.
   182  	// +optional
   183  	CPU *CPU `json:"cpu,omitempty"`
   184  	// Memory allow specifying the VMI memory features.
   185  	// +optional
   186  	Memory *Memory `json:"memory,omitempty"`
   187  	// Machine type.
   188  	// +optional
   189  	Machine *Machine `json:"machine,omitempty"`
   190  	// Firmware.
   191  	// +optional
   192  	Firmware *Firmware `json:"firmware,omitempty"`
   193  	// Clock sets the clock and timers of the vmi.
   194  	// +optional
   195  	Clock *Clock `json:"clock,omitempty"`
   196  	// Features like acpi, apic, hyperv, smm.
   197  	// +optional
   198  	Features *Features `json:"features,omitempty"`
   199  	// Devices allows adding disks, network interfaces, and others
   200  	Devices Devices `json:"devices"`
   201  	// Controls whether or not disks will share IOThreads.
   202  	// Omitting IOThreadsPolicy disables use of IOThreads.
   203  	// One of: shared, auto
   204  	// +optional
   205  	IOThreadsPolicy *IOThreadsPolicy `json:"ioThreadsPolicy,omitempty"`
   206  	// Chassis specifies the chassis info passed to the domain.
   207  	// +optional
   208  	Chassis *Chassis `json:"chassis,omitempty"`
   209  	// Launch Security setting of the vmi.
   210  	// +optional
   211  	LaunchSecurity *LaunchSecurity `json:"launchSecurity,omitempty"`
   212  }
   213  
   214  // Chassis specifies the chassis info passed to the domain.
   215  type Chassis struct {
   216  	Manufacturer string `json:"manufacturer,omitempty"`
   217  	Version      string `json:"version,omitempty"`
   218  	Serial       string `json:"serial,omitempty"`
   219  	Asset        string `json:"asset,omitempty"`
   220  	Sku          string `json:"sku,omitempty"`
   221  }
   222  
   223  // Represents the firmware blob used to assist in the domain creation process.
   224  // Used for setting the QEMU BIOS file path for the libvirt domain.
   225  type Bootloader struct {
   226  	// If set (default), BIOS will be used.
   227  	// +optional
   228  	BIOS *BIOS `json:"bios,omitempty"`
   229  	// If set, EFI will be used instead of BIOS.
   230  	// +optional
   231  	EFI *EFI `json:"efi,omitempty"`
   232  }
   233  
   234  // If set (default), BIOS will be used.
   235  type BIOS struct {
   236  	// If set, the BIOS output will be transmitted over serial
   237  	// +optional
   238  	UseSerial *bool `json:"useSerial,omitempty"`
   239  }
   240  
   241  // If set, EFI will be used instead of BIOS.
   242  type EFI struct {
   243  	// If set, SecureBoot will be enabled and the OVMF roms will be swapped for
   244  	// SecureBoot-enabled ones.
   245  	// Requires SMM to be enabled.
   246  	// Defaults to true
   247  	// +optional
   248  	SecureBoot *bool `json:"secureBoot,omitempty"`
   249  	// If set to true, Persistent will persist the EFI NVRAM across reboots.
   250  	// Defaults to false
   251  	// +optional
   252  	Persistent *bool `json:"persistent,omitempty"`
   253  }
   254  
   255  // If set, the VM will be booted from the defined kernel / initrd.
   256  type KernelBootContainer struct {
   257  	// Image that contains initrd / kernel files.
   258  	Image string `json:"image"`
   259  	// ImagePullSecret is the name of the Docker registry secret required to pull the image. The secret must already exist.
   260  	//+optional
   261  	ImagePullSecret string `json:"imagePullSecret,omitempty"`
   262  	// Image pull policy.
   263  	// One of Always, Never, IfNotPresent.
   264  	// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
   265  	// Cannot be updated.
   266  	// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
   267  	// +optional
   268  	ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
   269  	// The fully-qualified path to the kernel image in the host OS
   270  	//+optional
   271  	KernelPath string `json:"kernelPath,omitempty"`
   272  	// the fully-qualified path to the ramdisk image in the host OS
   273  	//+optional
   274  	InitrdPath string `json:"initrdPath,omitempty"`
   275  }
   276  
   277  // Represents the firmware blob used to assist in the kernel boot process.
   278  // Used for setting the kernel, initrd and command line arguments
   279  type KernelBoot struct {
   280  	// Arguments to be passed to the kernel at boot time
   281  	KernelArgs string `json:"kernelArgs,omitempty"`
   282  	// Container defines the container that containes kernel artifacts
   283  	Container *KernelBootContainer `json:"container,omitempty"`
   284  }
   285  
   286  type ResourceRequirements struct {
   287  	// Requests is a description of the initial vmi resources.
   288  	// Valid resource keys are "memory" and "cpu".
   289  	// +optional
   290  	Requests v1.ResourceList `json:"requests,omitempty"`
   291  	// Limits describes the maximum amount of compute resources allowed.
   292  	// Valid resource keys are "memory" and "cpu".
   293  	// +optional
   294  	Limits v1.ResourceList `json:"limits,omitempty"`
   295  	// Don't ask the scheduler to take the guest-management overhead into account. Instead
   296  	// put the overhead only into the container's memory limit. This can lead to crashes if
   297  	// all memory is in use on a node. Defaults to false.
   298  	OvercommitGuestOverhead bool `json:"overcommitGuestOverhead,omitempty"`
   299  }
   300  
   301  // CPU allows specifying the CPU topology.
   302  type CPU struct {
   303  	// Cores specifies the number of cores inside the vmi.
   304  	// Must be a value greater or equal 1.
   305  	Cores uint32 `json:"cores,omitempty"`
   306  	// Sockets specifies the number of sockets inside the vmi.
   307  	// Must be a value greater or equal 1.
   308  	Sockets uint32 `json:"sockets,omitempty"`
   309  	// MaxSockets specifies the maximum amount of sockets that can
   310  	// be hotplugged
   311  	MaxSockets uint32 `json:"maxSockets,omitempty"`
   312  	// Threads specifies the number of threads inside the vmi.
   313  	// Must be a value greater or equal 1.
   314  	Threads uint32 `json:"threads,omitempty"`
   315  	// Model specifies the CPU model inside the VMI.
   316  	// List of available models https://github.com/libvirt/libvirt/tree/master/src/cpu_map.
   317  	// It is possible to specify special cases like "host-passthrough" to get the same CPU as the node
   318  	// and "host-model" to get CPU closest to the node one.
   319  	// Defaults to host-model.
   320  	// +optional
   321  	Model string `json:"model,omitempty"`
   322  	// Features specifies the CPU features list inside the VMI.
   323  	// +optional
   324  	Features []CPUFeature `json:"features,omitempty"`
   325  	// DedicatedCPUPlacement requests the scheduler to place the VirtualMachineInstance on a node
   326  	// with enough dedicated pCPUs and pin the vCPUs to it.
   327  	// +optional
   328  	DedicatedCPUPlacement bool `json:"dedicatedCpuPlacement,omitempty"`
   329  
   330  	// NUMA allows specifying settings for the guest NUMA topology
   331  	// +optional
   332  	NUMA *NUMA `json:"numa,omitempty"`
   333  
   334  	// IsolateEmulatorThread requests one more dedicated pCPU to be allocated for the VMI to place
   335  	// the emulator thread on it.
   336  	// +optional
   337  	IsolateEmulatorThread bool `json:"isolateEmulatorThread,omitempty"`
   338  	// Realtime instructs the virt-launcher to tune the VMI for lower latency, optional for real time workloads
   339  	// +optional
   340  	Realtime *Realtime `json:"realtime,omitempty"`
   341  }
   342  
   343  // Realtime holds the tuning knobs specific for realtime workloads.
   344  type Realtime struct {
   345  	// Mask defines the vcpu mask expression that defines which vcpus are used for realtime. Format matches libvirt's expressions.
   346  	// Example: "0-3,^1","0,2,3","2-3"
   347  	// +optional
   348  	Mask string `json:"mask,omitempty"`
   349  }
   350  
   351  // NUMAGuestMappingPassthrough instructs kubevirt to model numa topology which is compatible with the CPU pinning on the guest.
   352  // This will result in a subset of the node numa topology being passed through, ensuring that virtual numa nodes and their memory
   353  // never cross boundaries coming from the node numa mapping.
   354  type NUMAGuestMappingPassthrough struct {
   355  }
   356  
   357  type NUMA struct {
   358  	// GuestMappingPassthrough will create an efficient guest topology based on host CPUs exclusively assigned to a pod.
   359  	// The created topology ensures that memory and CPUs on the virtual numa nodes never cross boundaries of host numa nodes.
   360  	// +opitonal
   361  	GuestMappingPassthrough *NUMAGuestMappingPassthrough `json:"guestMappingPassthrough,omitempty"`
   362  }
   363  
   364  // CPUFeature allows specifying a CPU feature.
   365  type CPUFeature struct {
   366  	// Name of the CPU feature
   367  	Name string `json:"name"`
   368  	// Policy is the CPU feature attribute which can have the following attributes:
   369  	// force    - The virtual CPU will claim the feature is supported regardless of it being supported by host CPU.
   370  	// require  - Guest creation will fail unless the feature is supported by the host CPU or the hypervisor is able to emulate it.
   371  	// optional - The feature will be supported by virtual CPU if and only if it is supported by host CPU.
   372  	// disable  - The feature will not be supported by virtual CPU.
   373  	// forbid   - Guest creation will fail if the feature is supported by host CPU.
   374  	// Defaults to require
   375  	// +optional
   376  	Policy string `json:"policy,omitempty"`
   377  }
   378  
   379  // Memory allows specifying the VirtualMachineInstance memory features.
   380  type Memory struct {
   381  	// Hugepages allow to use hugepages for the VirtualMachineInstance instead of regular memory.
   382  	// +optional
   383  	Hugepages *Hugepages `json:"hugepages,omitempty"`
   384  	// Guest allows to specifying the amount of memory which is visible inside the Guest OS.
   385  	// The Guest must lie between Requests and Limits from the resources section.
   386  	// Defaults to the requested memory in the resources section if not specified.
   387  	// + optional
   388  	Guest *resource.Quantity `json:"guest,omitempty"`
   389  	// MaxGuest allows to specify the maximum amount of memory which is visible inside the Guest OS.
   390  	// The delta between MaxGuest and Guest is the amount of memory that can be hot(un)plugged.
   391  	MaxGuest *resource.Quantity `json:"maxGuest,omitempty"`
   392  }
   393  
   394  type MemoryStatus struct {
   395  	// GuestAtBoot specifies with how much memory the VirtualMachine intiallly booted with.
   396  	// +optional
   397  	GuestAtBoot *resource.Quantity `json:"guestAtBoot,omitempty"`
   398  	// GuestCurrent specifies how much memory is currently available for the VirtualMachine.
   399  	// +optional
   400  	GuestCurrent *resource.Quantity `json:"guestCurrent,omitempty"`
   401  	// GuestRequested specifies how much memory was requested (hotplug) for the VirtualMachine.
   402  	// +optional
   403  	GuestRequested *resource.Quantity `json:"guestRequested,omitempty"`
   404  }
   405  
   406  // Hugepages allow to use hugepages for the VirtualMachineInstance instead of regular memory.
   407  type Hugepages struct {
   408  	// PageSize specifies the hugepage size, for x86_64 architecture valid values are 1Gi and 2Mi.
   409  	PageSize string `json:"pageSize,omitempty"`
   410  }
   411  
   412  type Machine struct {
   413  	// QEMU machine type is the actual chipset of the VirtualMachineInstance.
   414  	// +optional
   415  	Type string `json:"type"`
   416  }
   417  
   418  type Firmware struct {
   419  	// UUID reported by the vmi bios.
   420  	// Defaults to a random generated uid.
   421  	UUID types.UID `json:"uuid,omitempty"`
   422  	// Settings to control the bootloader that is used.
   423  	// +optional
   424  	Bootloader *Bootloader `json:"bootloader,omitempty"`
   425  	// The system-serial-number in SMBIOS
   426  	Serial string `json:"serial,omitempty"`
   427  	// Settings to set the kernel for booting.
   428  	// +optional
   429  	KernelBoot *KernelBoot `json:"kernelBoot,omitempty"`
   430  	// Information that can be set in the ACPI table
   431  	ACPI *ACPI `json:"acpi,omitempty"`
   432  }
   433  
   434  type ACPI struct {
   435  	// SlicNameRef should match the volume name of a secret object. The data in the secret should
   436  	// be a binary blob that follows the ACPI SLIC standard, see:
   437  	// https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653305(v=vs.85)
   438  	SlicNameRef string `json:"slicNameRef,omitempty"`
   439  }
   440  
   441  type Devices struct {
   442  	// Fall back to legacy virtio 0.9 support if virtio bus is selected on devices.
   443  	// This is helpful for old machines like CentOS6 or RHEL6 which
   444  	// do not understand virtio_non_transitional (virtio 1.0).
   445  	UseVirtioTransitional *bool `json:"useVirtioTransitional,omitempty"`
   446  	// DisableHotplug disabled the ability to hotplug disks.
   447  	DisableHotplug bool `json:"disableHotplug,omitempty"`
   448  	// Disks describes disks, cdroms and luns which are connected to the vmi.
   449  	Disks []Disk `json:"disks,omitempty"`
   450  	// Watchdog describes a watchdog device which can be added to the vmi.
   451  	Watchdog *Watchdog `json:"watchdog,omitempty"`
   452  	// Interfaces describe network interfaces which are added to the vmi.
   453  	Interfaces []Interface `json:"interfaces,omitempty"`
   454  	// Inputs describe input devices
   455  	Inputs []Input `json:"inputs,omitempty"`
   456  	// Whether to attach a pod network interface. Defaults to true.
   457  	AutoattachPodInterface *bool `json:"autoattachPodInterface,omitempty"`
   458  	// Whether to attach the default graphics device or not.
   459  	// VNC will not be available if set to false. Defaults to true.
   460  	AutoattachGraphicsDevice *bool `json:"autoattachGraphicsDevice,omitempty"`
   461  	// Whether to attach the default virtio-serial console or not.
   462  	// Serial console access will not be available if set to false. Defaults to true.
   463  	AutoattachSerialConsole *bool `json:"autoattachSerialConsole,omitempty"`
   464  	// Whether to log the auto-attached default serial console or not.
   465  	// Serial console logs will be collect to a file and then streamed from a named `guest-console-log`.
   466  	// Not relevant if autoattachSerialConsole is disabled.
   467  	// Defaults to cluster wide setting on VirtualMachineOptions.
   468  	LogSerialConsole *bool `json:"logSerialConsole,omitempty"`
   469  	// Whether to attach the Memory balloon device with default period.
   470  	// Period can be adjusted in virt-config.
   471  	// Defaults to true.
   472  	// +optional
   473  	AutoattachMemBalloon *bool `json:"autoattachMemBalloon,omitempty"`
   474  	// Whether to attach an Input Device.
   475  	// Defaults to false.
   476  	// +optional
   477  	AutoattachInputDevice *bool `json:"autoattachInputDevice,omitempty"`
   478  	// Whether to attach the VSOCK CID to the VM or not.
   479  	// VSOCK access will be available if set to true. Defaults to false.
   480  	AutoattachVSOCK *bool `json:"autoattachVSOCK,omitempty"`
   481  	// Whether to have random number generator from host
   482  	// +optional
   483  	Rng *Rng `json:"rng,omitempty"`
   484  	// Whether or not to enable virtio multi-queue for block devices.
   485  	// Defaults to false.
   486  	// +optional
   487  	BlockMultiQueue *bool `json:"blockMultiQueue,omitempty"`
   488  	// If specified, virtual network interfaces configured with a virtio bus will also enable the vhost multiqueue feature for network devices. The number of queues created depends on additional factors of the VirtualMachineInstance, like the number of guest CPUs.
   489  	// +optional
   490  	NetworkInterfaceMultiQueue *bool `json:"networkInterfaceMultiqueue,omitempty"`
   491  	//Whether to attach a GPU device to the vmi.
   492  	// +optional
   493  	// +listType=atomic
   494  	GPUs []GPU `json:"gpus,omitempty"`
   495  	// DownwardMetrics creates a virtio serials for exposing the downward metrics to the vmi.
   496  	// +optional
   497  	DownwardMetrics *DownwardMetrics `json:"downwardMetrics,omitempty"`
   498  	// Filesystems describes filesystem which is connected to the vmi.
   499  	// +optional
   500  	// +listType=atomic
   501  	Filesystems []Filesystem `json:"filesystems,omitempty"`
   502  	//Whether to attach a host device to the vmi.
   503  	// +optional
   504  	// +listType=atomic
   505  	HostDevices []HostDevice `json:"hostDevices,omitempty"`
   506  	// To configure and access client devices such as redirecting USB
   507  	// +optional
   508  	ClientPassthrough *ClientPassthroughDevices `json:"clientPassthrough,omitempty"`
   509  	// Whether to emulate a sound device.
   510  	// +optional
   511  	Sound *SoundDevice `json:"sound,omitempty"`
   512  	// Whether to emulate a TPM device.
   513  	// +optional
   514  	TPM *TPMDevice `json:"tpm,omitempty"`
   515  }
   516  
   517  // Represent a subset of client devices that can be accessed by VMI. At the
   518  // moment only, USB devices using Usbredir's library and tooling. Another fit
   519  // would be a smartcard with libcacard.
   520  //
   521  // The struct is currently empty as there is no immediate request for
   522  // user-facing APIs. This structure simply turns on USB redirection of
   523  // UsbClientPassthroughMaxNumberOf devices.
   524  type ClientPassthroughDevices struct {
   525  }
   526  
   527  // Represents the upper limit allowed by QEMU + KubeVirt.
   528  const (
   529  	UsbClientPassthroughMaxNumberOf = 4
   530  )
   531  
   532  // Represents the user's configuration to emulate sound cards in the VMI.
   533  type SoundDevice struct {
   534  	// User's defined name for this sound device
   535  	Name string `json:"name"`
   536  	// We only support ich9 or ac97.
   537  	// If SoundDevice is not set: No sound card is emulated.
   538  	// If SoundDevice is set but Model is not: ich9
   539  	// +optional
   540  	Model string `json:"model,omitempty"`
   541  }
   542  
   543  type TPMDevice struct {
   544  	// Persistent indicates the state of the TPM device should be kept accross reboots
   545  	// Defaults to false
   546  	Persistent *bool `json:"persistent,omitempty"`
   547  }
   548  
   549  type InputBus string
   550  
   551  const (
   552  	InputBusUSB    InputBus = "usb"
   553  	InputBusVirtio InputBus = "virtio"
   554  )
   555  
   556  type InputType string
   557  
   558  const (
   559  	InputTypeTablet   InputType = "tablet"
   560  	InputTypeKeyboard InputType = "keyboard"
   561  )
   562  
   563  type Input struct {
   564  	// Bus indicates the bus of input device to emulate.
   565  	// Supported values: virtio, usb.
   566  	Bus InputBus `json:"bus,omitempty"`
   567  	// Type indicated the type of input device.
   568  	// Supported values: tablet.
   569  	Type InputType `json:"type"`
   570  	// Name is the device name
   571  	Name string `json:"name"`
   572  }
   573  
   574  type Filesystem struct {
   575  	// Name is the device name
   576  	Name string `json:"name"`
   577  	// Virtiofs is supported
   578  	Virtiofs *FilesystemVirtiofs `json:"virtiofs"`
   579  }
   580  
   581  type FilesystemVirtiofs struct{}
   582  
   583  type DownwardMetrics struct{}
   584  
   585  type GPU struct {
   586  	// Name of the GPU device as exposed by a device plugin
   587  	Name              string       `json:"name"`
   588  	DeviceName        string       `json:"deviceName"`
   589  	VirtualGPUOptions *VGPUOptions `json:"virtualGPUOptions,omitempty"`
   590  	// If specified, the virtual network interface address and its tag will be provided to the guest via config drive
   591  	// +optional
   592  	Tag string `json:"tag,omitempty"`
   593  }
   594  
   595  type VGPUOptions struct {
   596  	Display *VGPUDisplayOptions `json:"display,omitempty"`
   597  }
   598  
   599  type VGPUDisplayOptions struct {
   600  	// Enabled determines if a display addapter backed by a vGPU should be enabled or disabled on the guest.
   601  	// Defaults to true.
   602  	// +optional
   603  	Enabled *bool `json:"enabled,omitempty"`
   604  	// Enables a boot framebuffer, until the guest OS loads a real GPU driver
   605  	// Defaults to true.
   606  	// +optional
   607  	RamFB *FeatureState `json:"ramFB,omitempty"`
   608  }
   609  
   610  type HostDevice struct {
   611  	Name string `json:"name"`
   612  	// DeviceName is the resource name of the host device exposed by a device plugin
   613  	DeviceName string `json:"deviceName"`
   614  	// If specified, the virtual network interface address and its tag will be provided to the guest via config drive
   615  	// +optional
   616  	Tag string `json:"tag,omitempty"`
   617  }
   618  
   619  type Disk struct {
   620  	// Name is the device name
   621  	Name string `json:"name"`
   622  	// DiskDevice specifies as which device the disk should be added to the guest.
   623  	// Defaults to Disk.
   624  	DiskDevice `json:",inline"`
   625  	// BootOrder is an integer value > 0, used to determine ordering of boot devices.
   626  	// Lower values take precedence.
   627  	// Each disk or interface that has a boot order must have a unique value.
   628  	// Disks without a boot order are not tried if a disk with a boot order exists.
   629  	// +optional
   630  	BootOrder *uint `json:"bootOrder,omitempty"`
   631  	// Serial provides the ability to specify a serial number for the disk device.
   632  	// +optional
   633  	Serial string `json:"serial,omitempty"`
   634  	// dedicatedIOThread indicates this disk should have an exclusive IO Thread.
   635  	// Enabling this implies useIOThreads = true.
   636  	// Defaults to false.
   637  	// +optional
   638  	DedicatedIOThread *bool `json:"dedicatedIOThread,omitempty"`
   639  	// Cache specifies which kvm disk cache mode should be used.
   640  	// Supported values are: CacheNone, CacheWriteThrough.
   641  	// +optional
   642  	Cache DriverCache `json:"cache,omitempty"`
   643  	// IO specifies which QEMU disk IO mode should be used.
   644  	// Supported values are: native, default, threads.
   645  	// +optional
   646  	IO DriverIO `json:"io,omitempty"`
   647  	// If specified, disk address and its tag will be provided to the guest via config drive metadata
   648  	// +optional
   649  	Tag string `json:"tag,omitempty"`
   650  	// If specified, the virtual disk will be presented with the given block sizes.
   651  	// +optional
   652  	BlockSize *BlockSize `json:"blockSize,omitempty"`
   653  	// If specified the disk is made sharable and multiple write from different VMs are permitted
   654  	// +optional
   655  	Shareable *bool `json:"shareable,omitempty"`
   656  	// If specified, it can change the default error policy (stop) for the disk
   657  	// +optional
   658  	ErrorPolicy *DiskErrorPolicy `json:"errorPolicy,omitempty"`
   659  }
   660  
   661  // CustomBlockSize represents the desired logical and physical block size for a VM disk.
   662  type CustomBlockSize struct {
   663  	Logical  uint `json:"logical"`
   664  	Physical uint `json:"physical"`
   665  }
   666  
   667  // BlockSize provides the option to change the block size presented to the VM for a disk.
   668  // Only one of its members may be specified.
   669  type BlockSize struct {
   670  	Custom      *CustomBlockSize `json:"custom,omitempty"`
   671  	MatchVolume *FeatureState    `json:"matchVolume,omitempty"`
   672  }
   673  
   674  // Represents the target of a volume to mount.
   675  // Only one of its members may be specified.
   676  type DiskDevice struct {
   677  	// Attach a volume as a disk to the vmi.
   678  	Disk *DiskTarget `json:"disk,omitempty"`
   679  	// Attach a volume as a LUN to the vmi.
   680  	LUN *LunTarget `json:"lun,omitempty"`
   681  	// Attach a volume as a cdrom to the vmi.
   682  	CDRom *CDRomTarget `json:"cdrom,omitempty"`
   683  }
   684  
   685  type DiskBus string
   686  
   687  const (
   688  	DiskBusSCSI   DiskBus = "scsi"
   689  	DiskBusSATA   DiskBus = "sata"
   690  	DiskBusVirtio DiskBus = VirtIO
   691  	DiskBusUSB    DiskBus = "usb"
   692  )
   693  
   694  type DiskTarget struct {
   695  	// Bus indicates the type of disk device to emulate.
   696  	// supported values: virtio, sata, scsi, usb.
   697  	Bus DiskBus `json:"bus,omitempty"`
   698  	// ReadOnly.
   699  	// Defaults to false.
   700  	ReadOnly bool `json:"readonly,omitempty"`
   701  	// If specified, the virtual disk will be placed on the guests pci address with the specified PCI address. For example: 0000:81:01.10
   702  	// +optional
   703  	PciAddress string `json:"pciAddress,omitempty"`
   704  }
   705  
   706  type LaunchSecurity struct {
   707  	// AMD Secure Encrypted Virtualization (SEV).
   708  	SEV *SEV `json:"sev,omitempty"`
   709  }
   710  
   711  type SEV struct {
   712  	// Guest policy flags as defined in AMD SEV API specification.
   713  	// Note: due to security reasons it is not allowed to enable guest debugging. Therefore NoDebug flag is not exposed to users and is always true.
   714  	Policy *SEVPolicy `json:"policy,omitempty"`
   715  	// If specified, run the attestation process for a vmi.
   716  	// +opitonal
   717  	Attestation *SEVAttestation `json:"attestation,omitempty"`
   718  	// Base64 encoded session blob.
   719  	Session string `json:"session,omitempty"`
   720  	// Base64 encoded guest owner's Diffie-Hellman key.
   721  	DHCert string `json:"dhCert,omitempty"`
   722  }
   723  
   724  type SEVPolicy struct {
   725  	// SEV-ES is required.
   726  	// Defaults to false.
   727  	// +optional
   728  	EncryptedState *bool `json:"encryptedState,omitempty"`
   729  }
   730  
   731  type SEVAttestation struct {
   732  }
   733  
   734  type LunTarget struct {
   735  	// Bus indicates the type of disk device to emulate.
   736  	// supported values: virtio, sata, scsi.
   737  	Bus DiskBus `json:"bus,omitempty"`
   738  	// ReadOnly.
   739  	// Defaults to false.
   740  	ReadOnly bool `json:"readonly,omitempty"`
   741  	// Reservation indicates if the disk needs to support the persistent reservation for the SCSI disk
   742  	Reservation bool `json:"reservation,omitempty"`
   743  }
   744  
   745  // TrayState indicates if a tray of a cdrom is open or closed.
   746  type TrayState string
   747  
   748  const (
   749  	// TrayStateOpen indicates that the tray of a cdrom is open.
   750  	TrayStateOpen TrayState = "open"
   751  	// TrayStateClosed indicates that the tray of a cdrom is closed.
   752  	TrayStateClosed TrayState = "closed"
   753  )
   754  
   755  type CDRomTarget struct {
   756  	// Bus indicates the type of disk device to emulate.
   757  	// supported values: virtio, sata, scsi.
   758  	Bus DiskBus `json:"bus,omitempty"`
   759  	// ReadOnly.
   760  	// Defaults to true.
   761  	ReadOnly *bool `json:"readonly,omitempty"`
   762  	// Tray indicates if the tray of the device is open or closed.
   763  	// Allowed values are "open" and "closed".
   764  	// Defaults to closed.
   765  	// +optional
   766  	Tray TrayState `json:"tray,omitempty"`
   767  }
   768  
   769  // Volume represents a named volume in a vmi.
   770  type Volume struct {
   771  	// Volume's name.
   772  	// Must be a DNS_LABEL and unique within the vmi.
   773  	// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
   774  	Name string `json:"name"`
   775  	// VolumeSource represents the location and type of the mounted volume.
   776  	// Defaults to Disk, if no type is specified.
   777  	VolumeSource `json:",inline"`
   778  }
   779  
   780  // Represents the source of a volume to mount.
   781  // Only one of its members may be specified.
   782  type VolumeSource struct {
   783  	// HostDisk represents a disk created on the cluster level
   784  	// +optional
   785  	HostDisk *HostDisk `json:"hostDisk,omitempty"`
   786  	// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
   787  	// Directly attached to the vmi via qemu.
   788  	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
   789  	// +optional
   790  	PersistentVolumeClaim *PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
   791  	// CloudInitNoCloud represents a cloud-init NoCloud user-data source.
   792  	// The NoCloud data will be added as a disk to the vmi. A proper cloud-init installation is required inside the guest.
   793  	// More info: http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
   794  	// +optional
   795  	CloudInitNoCloud *CloudInitNoCloudSource `json:"cloudInitNoCloud,omitempty"`
   796  	// CloudInitConfigDrive represents a cloud-init Config Drive user-data source.
   797  	// The Config Drive data will be added as a disk to the vmi. A proper cloud-init installation is required inside the guest.
   798  	// More info: https://cloudinit.readthedocs.io/en/latest/topics/datasources/configdrive.html
   799  	// +optional
   800  	CloudInitConfigDrive *CloudInitConfigDriveSource `json:"cloudInitConfigDrive,omitempty"`
   801  	// Represents a Sysprep volume source.
   802  	// +optional
   803  	Sysprep *SysprepSource `json:"sysprep,omitempty"`
   804  	// ContainerDisk references a docker image, embedding a qcow or raw disk.
   805  	// More info: https://kubevirt.gitbooks.io/user-guide/registry-disk.html
   806  	// +optional
   807  	ContainerDisk *ContainerDiskSource `json:"containerDisk,omitempty"`
   808  	// Ephemeral is a special volume source that "wraps" specified source and provides copy-on-write image on top of it.
   809  	// +optional
   810  	Ephemeral *EphemeralVolumeSource `json:"ephemeral,omitempty"`
   811  	// EmptyDisk represents a temporary disk which shares the vmis lifecycle.
   812  	// More info: https://kubevirt.gitbooks.io/user-guide/disks-and-volumes.html
   813  	// +optional
   814  	EmptyDisk *EmptyDiskSource `json:"emptyDisk,omitempty"`
   815  	// DataVolume represents the dynamic creation a PVC for this volume as well as
   816  	// the process of populating that PVC with a disk image.
   817  	// +optional
   818  	DataVolume *DataVolumeSource `json:"dataVolume,omitempty"`
   819  	// ConfigMapSource represents a reference to a ConfigMap in the same namespace.
   820  	// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
   821  	// +optional
   822  	ConfigMap *ConfigMapVolumeSource `json:"configMap,omitempty"`
   823  	// SecretVolumeSource represents a reference to a secret data in the same namespace.
   824  	// More info: https://kubernetes.io/docs/concepts/configuration/secret/
   825  	// +optional
   826  	Secret *SecretVolumeSource `json:"secret,omitempty"`
   827  	// DownwardAPI represents downward API about the pod that should populate this volume
   828  	// +optional
   829  	DownwardAPI *DownwardAPIVolumeSource `json:"downwardAPI,omitempty"`
   830  	// ServiceAccountVolumeSource represents a reference to a service account.
   831  	// There can only be one volume of this type!
   832  	// More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
   833  	// +optional
   834  	ServiceAccount *ServiceAccountVolumeSource `json:"serviceAccount,omitempty"`
   835  	// DownwardMetrics adds a very small disk to VMIs which contains a limited view of host and guest
   836  	// metrics. The disk content is compatible with vhostmd (https://github.com/vhostmd/vhostmd) and vm-dump-metrics.
   837  	DownwardMetrics *DownwardMetricsVolumeSource `json:"downwardMetrics,omitempty"`
   838  	// MemoryDump is attached to the virt launcher and is populated with a memory dump of the vmi
   839  	MemoryDump *MemoryDumpVolumeSource `json:"memoryDump,omitempty"`
   840  }
   841  
   842  // HotplugVolumeSource Represents the source of a volume to mount which are capable
   843  // of being hotplugged on a live running VMI.
   844  // Only one of its members may be specified.
   845  type HotplugVolumeSource struct {
   846  	// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
   847  	// Directly attached to the vmi via qemu.
   848  	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
   849  	// +optional
   850  	PersistentVolumeClaim *PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
   851  	// DataVolume represents the dynamic creation a PVC for this volume as well as
   852  	// the process of populating that PVC with a disk image.
   853  	// +optional
   854  	DataVolume *DataVolumeSource `json:"dataVolume,omitempty"`
   855  }
   856  
   857  type DataVolumeSource struct {
   858  	// Name of both the DataVolume and the PVC in the same namespace.
   859  	// After PVC population the DataVolume is garbage collected by default.
   860  	Name string `json:"name"`
   861  	// Hotpluggable indicates whether the volume can be hotplugged and hotunplugged.
   862  	// +optional
   863  	Hotpluggable bool `json:"hotpluggable,omitempty"`
   864  }
   865  
   866  // PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
   867  // Directly attached to the vmi via qemu.
   868  // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
   869  type PersistentVolumeClaimVolumeSource struct {
   870  	v1.PersistentVolumeClaimVolumeSource `json:",inline"`
   871  	// Hotpluggable indicates whether the volume can be hotplugged and hotunplugged.
   872  	// +optional
   873  	Hotpluggable bool `json:"hotpluggable,omitempty"`
   874  }
   875  
   876  type MemoryDumpVolumeSource struct {
   877  	// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
   878  	// Directly attached to the virt launcher
   879  	// +optional
   880  	PersistentVolumeClaimVolumeSource `json:",inline"`
   881  }
   882  
   883  type EphemeralVolumeSource struct {
   884  	// PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace.
   885  	// Directly attached to the vmi via qemu.
   886  	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
   887  	// +optional
   888  	PersistentVolumeClaim *v1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
   889  }
   890  
   891  // EmptyDisk represents a temporary disk which shares the vmis lifecycle.
   892  type EmptyDiskSource struct {
   893  	// Capacity of the sparse disk.
   894  	Capacity resource.Quantity `json:"capacity"`
   895  }
   896  
   897  // Represents a docker image with an embedded disk.
   898  type ContainerDiskSource struct {
   899  	// Image is the name of the image with the embedded disk.
   900  	Image string `json:"image"`
   901  	// ImagePullSecret is the name of the Docker registry secret required to pull the image. The secret must already exist.
   902  	ImagePullSecret string `json:"imagePullSecret,omitempty"`
   903  	// Path defines the path to disk file in the container
   904  	Path string `json:"path,omitempty"`
   905  	// Image pull policy.
   906  	// One of Always, Never, IfNotPresent.
   907  	// Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.
   908  	// Cannot be updated.
   909  	// More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
   910  	// +optional
   911  	ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
   912  }
   913  
   914  // Exactly one of its members must be set.
   915  type ClockOffset struct {
   916  	// UTC sets the guest clock to UTC on each boot. If an offset is specified,
   917  	// guest changes to the clock will be kept during reboots and are not reset.
   918  	UTC *ClockOffsetUTC `json:"utc,omitempty"`
   919  	// Timezone sets the guest clock to the specified timezone.
   920  	// Zone name follows the TZ environment variable format (e.g. 'America/New_York').
   921  	Timezone *ClockOffsetTimezone `json:"timezone,omitempty"`
   922  }
   923  
   924  // UTC sets the guest clock to UTC on each boot.
   925  type ClockOffsetUTC struct {
   926  	// OffsetSeconds specifies an offset in seconds, relative to UTC. If set,
   927  	// guest changes to the clock will be kept during reboots and not reset.
   928  	OffsetSeconds *int `json:"offsetSeconds,omitempty"`
   929  }
   930  
   931  // ClockOffsetTimezone sets the guest clock to the specified timezone.
   932  // Zone name follows the TZ environment variable format (e.g. 'America/New_York').
   933  type ClockOffsetTimezone string
   934  
   935  // Represents the clock and timers of a vmi.
   936  // +kubebuilder:pruning:PreserveUnknownFields
   937  type Clock struct {
   938  	// ClockOffset allows specifying the UTC offset or the timezone of the guest clock.
   939  	ClockOffset `json:",inline"`
   940  	// Timer specifies whih timers are attached to the vmi.
   941  	// +optional
   942  	Timer *Timer `json:"timer,omitempty"`
   943  }
   944  
   945  // Represents all available timers in a vmi.
   946  type Timer struct {
   947  	// HPET (High Precision Event Timer) - multiple timers with periodic interrupts.
   948  	HPET *HPETTimer `json:"hpet,omitempty"`
   949  	// KVM 	(KVM clock) - lets guests read the host’s wall clock time (paravirtualized). For linux guests.
   950  	KVM *KVMTimer `json:"kvm,omitempty"`
   951  	// PIT (Programmable Interval Timer) - a timer with periodic interrupts.
   952  	PIT *PITTimer `json:"pit,omitempty"`
   953  	// RTC (Real Time Clock) - a continuously running timer with periodic interrupts.
   954  	RTC *RTCTimer `json:"rtc,omitempty"`
   955  	// Hyperv (Hypervclock) - lets guests read the host’s wall clock time (paravirtualized). For windows guests.
   956  	Hyperv *HypervTimer `json:"hyperv,omitempty"`
   957  }
   958  
   959  // HPETTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
   960  type HPETTickPolicy string
   961  
   962  // PITTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
   963  type PITTickPolicy string
   964  
   965  // RTCTickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
   966  type RTCTickPolicy string
   967  
   968  const (
   969  	// HPETTickPolicyDelay delivers ticks at a constant rate. The guest time will
   970  	// be delayed due to the late tick
   971  	HPETTickPolicyDelay HPETTickPolicy = "delay"
   972  	// HPETTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
   973  	// missed tick. The guest time should not be delayed once catchup is complete
   974  	HPETTickPolicyCatchup HPETTickPolicy = "catchup"
   975  	// HPETTickPolicyMerge merges the missed tick(s) into one tick and inject. The
   976  	// guest time may be delayed, depending on how the OS reacts to the merging
   977  	// of ticks.
   978  	HPETTickPolicyMerge HPETTickPolicy = "merge"
   979  	// HPETTickPolicyDiscard discards all missed ticks.
   980  	HPETTickPolicyDiscard HPETTickPolicy = "discard"
   981  
   982  	// PITTickPolicyDelay delivers ticks at a constant rate. The guest time will
   983  	// be delayed due to the late tick.
   984  	PITTickPolicyDelay PITTickPolicy = "delay"
   985  	// PITTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
   986  	// missed tick. The guest time should not be delayed once catchup is complete.
   987  	PITTickPolicyCatchup PITTickPolicy = "catchup"
   988  	// PITTickPolicyDiscard discards all missed ticks.
   989  	PITTickPolicyDiscard PITTickPolicy = "discard"
   990  
   991  	// RTCTickPolicyDelay delivers ticks at a constant rate. The guest time will
   992  	// be delayed due to the late tick.
   993  	RTCTickPolicyDelay RTCTickPolicy = "delay"
   994  	// RTCTickPolicyCatchup Delivers ticks at a higher rate to catch up with the
   995  	// missed tick. The guest time should not be delayed once catchup is complete.
   996  	RTCTickPolicyCatchup RTCTickPolicy = "catchup"
   997  )
   998  
   999  // RTCTimerTrack specifies from which source to track the time.
  1000  type RTCTimerTrack string
  1001  
  1002  const (
  1003  	// TrackGuest tracks the guest time.
  1004  	TrackGuest RTCTimerTrack = "guest"
  1005  	// TrackWall tracks the host time.
  1006  	TrackWall RTCTimerTrack = "wall"
  1007  )
  1008  
  1009  type RTCTimer struct {
  1010  	// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
  1011  	// One of "delay", "catchup".
  1012  	TickPolicy RTCTickPolicy `json:"tickPolicy,omitempty"`
  1013  	// Enabled set to false makes sure that the machine type or a preset can't add the timer.
  1014  	// Defaults to true.
  1015  	// +optional
  1016  	Enabled *bool `json:"present,omitempty"`
  1017  	// Track the guest or the wall clock.
  1018  	Track RTCTimerTrack `json:"track,omitempty"`
  1019  }
  1020  
  1021  type HPETTimer struct {
  1022  	// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
  1023  	// One of "delay", "catchup", "merge", "discard".
  1024  	TickPolicy HPETTickPolicy `json:"tickPolicy,omitempty"`
  1025  	// Enabled set to false makes sure that the machine type or a preset can't add the timer.
  1026  	// Defaults to true.
  1027  	// +optional
  1028  	Enabled *bool `json:"present,omitempty"`
  1029  }
  1030  
  1031  type PITTimer struct {
  1032  	// TickPolicy determines what happens when QEMU misses a deadline for injecting a tick to the guest.
  1033  	// One of "delay", "catchup", "discard".
  1034  	TickPolicy PITTickPolicy `json:"tickPolicy,omitempty"`
  1035  	// Enabled set to false makes sure that the machine type or a preset can't add the timer.
  1036  	// Defaults to true.
  1037  	// +optional
  1038  	Enabled *bool `json:"present,omitempty"`
  1039  }
  1040  
  1041  type KVMTimer struct {
  1042  	// Enabled set to false makes sure that the machine type or a preset can't add the timer.
  1043  	// Defaults to true.
  1044  	// +optional
  1045  	Enabled *bool `json:"present,omitempty"`
  1046  }
  1047  
  1048  type HypervTimer struct {
  1049  	// Enabled set to false makes sure that the machine type or a preset can't add the timer.
  1050  	// Defaults to true.
  1051  	// +optional
  1052  	Enabled *bool `json:"present,omitempty"`
  1053  }
  1054  
  1055  type Features struct {
  1056  	// ACPI enables/disables ACPI inside the guest.
  1057  	// Defaults to enabled.
  1058  	// +optional
  1059  	ACPI FeatureState `json:"acpi,omitempty"`
  1060  	// Defaults to the machine type setting.
  1061  	// +optional
  1062  	APIC *FeatureAPIC `json:"apic,omitempty"`
  1063  	// Defaults to the machine type setting.
  1064  	// +optional
  1065  	Hyperv *FeatureHyperv `json:"hyperv,omitempty"`
  1066  	// SMM enables/disables System Management Mode.
  1067  	// TSEG not yet implemented.
  1068  	// +optional
  1069  	SMM *FeatureState `json:"smm,omitempty"`
  1070  	// Configure how KVM presence is exposed to the guest.
  1071  	// +optional
  1072  	KVM *FeatureKVM `json:"kvm,omitempty"`
  1073  	// Notify the guest that the host supports paravirtual spinlocks.
  1074  	// For older kernels this feature should be explicitly disabled.
  1075  	// +optional
  1076  	Pvspinlock *FeatureState `json:"pvspinlock,omitempty"`
  1077  }
  1078  
  1079  type SyNICTimer struct {
  1080  	Enabled *bool         `json:"enabled,omitempty"`
  1081  	Direct  *FeatureState `json:"direct,omitempty"`
  1082  }
  1083  
  1084  // Represents if a feature is enabled or disabled.
  1085  type FeatureState struct {
  1086  	// Enabled determines if the feature should be enabled or disabled on the guest.
  1087  	// Defaults to true.
  1088  	// +optional
  1089  	Enabled *bool `json:"enabled,omitempty"`
  1090  }
  1091  
  1092  type FeatureAPIC struct {
  1093  	// Enabled determines if the feature should be enabled or disabled on the guest.
  1094  	// Defaults to true.
  1095  	// +optional
  1096  	Enabled *bool `json:"enabled,omitempty"`
  1097  	// EndOfInterrupt enables the end of interrupt notification in the guest.
  1098  	// Defaults to false.
  1099  	// +optional
  1100  	EndOfInterrupt bool `json:"endOfInterrupt,omitempty"`
  1101  }
  1102  
  1103  type FeatureSpinlocks struct {
  1104  	// Enabled determines if the feature should be enabled or disabled on the guest.
  1105  	// Defaults to true.
  1106  	// +optional
  1107  	Enabled *bool `json:"enabled,omitempty"`
  1108  	// Retries indicates the number of retries.
  1109  	// Must be a value greater or equal 4096.
  1110  	// Defaults to 4096.
  1111  	// +optional
  1112  	Retries *uint32 `json:"spinlocks,omitempty"`
  1113  }
  1114  
  1115  type FeatureVendorID struct {
  1116  	// Enabled determines if the feature should be enabled or disabled on the guest.
  1117  	// Defaults to true.
  1118  	// +optional
  1119  	Enabled *bool `json:"enabled,omitempty"`
  1120  	// VendorID sets the hypervisor vendor id, visible to the vmi.
  1121  	// String up to twelve characters.
  1122  	VendorID string `json:"vendorid,omitempty"`
  1123  }
  1124  
  1125  // Hyperv specific features.
  1126  type FeatureHyperv struct {
  1127  	// Relaxed instructs the guest OS to disable watchdog timeouts.
  1128  	// Defaults to the machine type setting.
  1129  	// +optional
  1130  	Relaxed *FeatureState `json:"relaxed,omitempty"`
  1131  	// VAPIC improves the paravirtualized handling of interrupts.
  1132  	// Defaults to the machine type setting.
  1133  	// +optional
  1134  	VAPIC *FeatureState `json:"vapic,omitempty"`
  1135  	// Spinlocks allows to configure the spinlock retry attempts.
  1136  	// +optional
  1137  	Spinlocks *FeatureSpinlocks `json:"spinlocks,omitempty"`
  1138  	// VPIndex enables the Virtual Processor Index to help windows identifying virtual processors.
  1139  	// Defaults to the machine type setting.
  1140  	// +optional
  1141  	VPIndex *FeatureState `json:"vpindex,omitempty"`
  1142  	// Runtime improves the time accounting to improve scheduling in the guest.
  1143  	// Defaults to the machine type setting.
  1144  	// +optional
  1145  	Runtime *FeatureState `json:"runtime,omitempty"`
  1146  	// SyNIC enables the Synthetic Interrupt Controller.
  1147  	// Defaults to the machine type setting.
  1148  	// +optional
  1149  	SyNIC *FeatureState `json:"synic,omitempty"`
  1150  	// SyNICTimer enables Synthetic Interrupt Controller Timers, reducing CPU load.
  1151  	// Defaults to the machine type setting.
  1152  	// +optional
  1153  	SyNICTimer *SyNICTimer `json:"synictimer,omitempty"`
  1154  	// Reset enables Hyperv reboot/reset for the vmi. Requires synic.
  1155  	// Defaults to the machine type setting.
  1156  	// +optional
  1157  	Reset *FeatureState `json:"reset,omitempty"`
  1158  	// VendorID allows setting the hypervisor vendor id.
  1159  	// Defaults to the machine type setting.
  1160  	// +optional
  1161  	VendorID *FeatureVendorID `json:"vendorid,omitempty"`
  1162  	// Frequencies improves the TSC clock source handling for Hyper-V on KVM.
  1163  	// Defaults to the machine type setting.
  1164  	// +optional
  1165  	Frequencies *FeatureState `json:"frequencies,omitempty"`
  1166  	// Reenlightenment enables the notifications on TSC frequency changes.
  1167  	// Defaults to the machine type setting.
  1168  	// +optional
  1169  	Reenlightenment *FeatureState `json:"reenlightenment,omitempty"`
  1170  	// TLBFlush improves performances in overcommited environments. Requires vpindex.
  1171  	// Defaults to the machine type setting.
  1172  	// +optional
  1173  	TLBFlush *FeatureState `json:"tlbflush,omitempty"`
  1174  	// IPI improves performances in overcommited environments. Requires vpindex.
  1175  	// Defaults to the machine type setting.
  1176  	// +optional
  1177  	IPI *FeatureState `json:"ipi,omitempty"`
  1178  	// EVMCS Speeds up L2 vmexits, but disables other virtualization features. Requires vapic.
  1179  	// Defaults to the machine type setting.
  1180  	// +optional
  1181  	EVMCS *FeatureState `json:"evmcs,omitempty"`
  1182  }
  1183  
  1184  type FeatureKVM struct {
  1185  	// Hide the KVM hypervisor from standard MSR based discovery.
  1186  	// Defaults to false
  1187  	Hidden bool `json:"hidden,omitempty"`
  1188  }
  1189  
  1190  // WatchdogAction defines the watchdog action, if a watchdog gets triggered.
  1191  type WatchdogAction string
  1192  
  1193  const (
  1194  	// WatchdogActionPoweroff will poweroff the vmi if the watchdog gets triggered.
  1195  	WatchdogActionPoweroff WatchdogAction = "poweroff"
  1196  	// WatchdogActionReset will reset the vmi if the watchdog gets triggered.
  1197  	WatchdogActionReset WatchdogAction = "reset"
  1198  	// WatchdogActionShutdown will shutdown the vmi if the watchdog gets triggered.
  1199  	WatchdogActionShutdown WatchdogAction = "shutdown"
  1200  )
  1201  
  1202  // Named watchdog device.
  1203  type Watchdog struct {
  1204  	// Name of the watchdog.
  1205  	Name string `json:"name"`
  1206  	// WatchdogDevice contains the watchdog type and actions.
  1207  	// Defaults to i6300esb.
  1208  	WatchdogDevice `json:",inline"`
  1209  }
  1210  
  1211  // Hardware watchdog device.
  1212  // Exactly one of its members must be set.
  1213  type WatchdogDevice struct {
  1214  	// i6300esb watchdog device.
  1215  	// +optional
  1216  	I6300ESB *I6300ESBWatchdog `json:"i6300esb,omitempty"`
  1217  }
  1218  
  1219  // i6300esb watchdog device.
  1220  type I6300ESBWatchdog struct {
  1221  	// The action to take. Valid values are poweroff, reset, shutdown.
  1222  	// Defaults to reset.
  1223  	Action WatchdogAction `json:"action,omitempty"`
  1224  }
  1225  
  1226  type Interface struct {
  1227  	// Logical name of the interface as well as a reference to the associated networks.
  1228  	// Must match the Name of a Network.
  1229  	Name string `json:"name"`
  1230  	// Interface model.
  1231  	// One of: e1000, e1000e, ne2k_pci, pcnet, rtl8139, virtio.
  1232  	// Defaults to virtio.
  1233  	// TODO:(ihar) switch to enums once opengen-api supports them. See: https://github.com/kubernetes/kube-openapi/issues/51
  1234  	Model string `json:"model,omitempty"`
  1235  	// BindingMethod specifies the method which will be used to connect the interface to the guest.
  1236  	// Defaults to Bridge.
  1237  	InterfaceBindingMethod `json:",inline"`
  1238  	// Binding specifies the binding plugin that will be used to connect the interface to the guest.
  1239  	// It provides an alternative to InterfaceBindingMethod.
  1240  	// version: 1alphav1
  1241  	Binding *PluginBinding `json:"binding,omitempty"`
  1242  	// List of ports to be forwarded to the virtual machine.
  1243  	Ports []Port `json:"ports,omitempty"`
  1244  	// Interface MAC address. For example: de:ad:00:00:be:af or DE-AD-00-00-BE-AF.
  1245  	MacAddress string `json:"macAddress,omitempty"`
  1246  	// BootOrder is an integer value > 0, used to determine ordering of boot devices.
  1247  	// Lower values take precedence.
  1248  	// Each interface or disk that has a boot order must have a unique value.
  1249  	// Interfaces without a boot order are not tried.
  1250  	// +optional
  1251  	BootOrder *uint `json:"bootOrder,omitempty"`
  1252  	// If specified, the virtual network interface will be placed on the guests pci address with the specified PCI address. For example: 0000:81:01.10
  1253  	// +optional
  1254  	PciAddress string `json:"pciAddress,omitempty"`
  1255  	// If specified the network interface will pass additional DHCP options to the VMI
  1256  	// +optional
  1257  	DHCPOptions *DHCPOptions `json:"dhcpOptions,omitempty"`
  1258  	// If specified, the virtual network interface address and its tag will be provided to the guest via config drive
  1259  	// +optional
  1260  	Tag string `json:"tag,omitempty"`
  1261  	// If specified, the ACPI index is used to provide network interface device naming, that is stable across changes
  1262  	// in PCI addresses assigned to the device.
  1263  	// This value is required to be unique across all devices and be between 1 and (16*1024-1).
  1264  	// +optional
  1265  	ACPIIndex int `json:"acpiIndex,omitempty"`
  1266  	// State represents the requested operational state of the interface.
  1267  	// The (only) value supported is `absent`, expressing a request to remove the interface.
  1268  	// +optional
  1269  	State InterfaceState `json:"state,omitempty"`
  1270  }
  1271  
  1272  type InterfaceState string
  1273  
  1274  const (
  1275  	InterfaceStateAbsent InterfaceState = "absent"
  1276  )
  1277  
  1278  // Extra DHCP options to use in the interface.
  1279  type DHCPOptions struct {
  1280  	// If specified will pass option 67 to interface's DHCP server
  1281  	// +optional
  1282  	BootFileName string `json:"bootFileName,omitempty"`
  1283  	// If specified will pass option 66 to interface's DHCP server
  1284  	// +optional
  1285  	TFTPServerName string `json:"tftpServerName,omitempty"`
  1286  	// If specified will pass the configured NTP server to the VM via DHCP option 042.
  1287  	// +optional
  1288  	NTPServers []string `json:"ntpServers,omitempty"`
  1289  	// If specified will pass extra DHCP options for private use, range: 224-254
  1290  	// +optional
  1291  	PrivateOptions []DHCPPrivateOptions `json:"privateOptions,omitempty"`
  1292  }
  1293  
  1294  func (d *DHCPOptions) UnmarshalJSON(data []byte) error {
  1295  	type DHCPOptionsAlias DHCPOptions
  1296  	var dhcpOptionsAlias DHCPOptionsAlias
  1297  
  1298  	if err := json.Unmarshal(data, &dhcpOptionsAlias); err != nil {
  1299  		return err
  1300  	}
  1301  
  1302  	for i, ntpServer := range dhcpOptionsAlias.NTPServers {
  1303  		if sanitizedIP, err := sanitizeIP(ntpServer); err == nil {
  1304  			dhcpOptionsAlias.NTPServers[i] = sanitizedIP
  1305  		}
  1306  	}
  1307  
  1308  	*d = DHCPOptions(dhcpOptionsAlias)
  1309  	return nil
  1310  }
  1311  
  1312  // DHCPExtraOptions defines Extra DHCP options for a VM.
  1313  type DHCPPrivateOptions struct {
  1314  	// Option is an Integer value from 224-254
  1315  	// Required.
  1316  	Option int `json:"option"`
  1317  	// Value is a String value for the Option provided
  1318  	// Required.
  1319  	Value string `json:"value"`
  1320  }
  1321  
  1322  // Represents the method which will be used to connect the interface to the guest.
  1323  // Only one of its members may be specified.
  1324  type InterfaceBindingMethod struct {
  1325  	Bridge     *InterfaceBridge     `json:"bridge,omitempty"`
  1326  	Slirp      *InterfaceSlirp      `json:"slirp,omitempty"`
  1327  	Masquerade *InterfaceMasquerade `json:"masquerade,omitempty"`
  1328  	SRIOV      *InterfaceSRIOV      `json:"sriov,omitempty"`
  1329  	// Deprecated, please refer to Kubevirt user guide for alternatives.
  1330  	// +optional
  1331  	Macvtap *InterfaceMacvtap `json:"macvtap,omitempty"`
  1332  	// Deprecated, please refer to Kubevirt user guide for alternatives.
  1333  	// +optional
  1334  	Passt *InterfacePasst `json:"passt,omitempty"`
  1335  }
  1336  
  1337  // InterfaceBridge connects to a given network via a linux bridge.
  1338  type InterfaceBridge struct{}
  1339  
  1340  // InterfaceSlirp connects to a given network using QEMU user networking mode.
  1341  type InterfaceSlirp struct{}
  1342  
  1343  // InterfaceMasquerade connects to a given network using netfilter rules to nat the traffic.
  1344  type InterfaceMasquerade struct{}
  1345  
  1346  // InterfaceSRIOV connects to a given network by passing-through an SR-IOV PCI device via vfio.
  1347  type InterfaceSRIOV struct{}
  1348  
  1349  // InterfaceMacvtap connects to a given network by extending the Kubernetes node's L2 networks via a macvtap interface.
  1350  type InterfaceMacvtap struct{}
  1351  
  1352  // InterfacePasst connects to a given network.
  1353  type InterfacePasst struct{}
  1354  
  1355  // PluginBinding represents a binding implemented in a plugin.
  1356  type PluginBinding struct {
  1357  	// Name references to the binding name as denined in the kubevirt CR.
  1358  	// version: 1alphav1
  1359  	Name string `json:"name"`
  1360  }
  1361  
  1362  // Port represents a port to expose from the virtual machine.
  1363  // Default protocol TCP.
  1364  // The port field is mandatory
  1365  type Port struct {
  1366  	// If specified, this must be an IANA_SVC_NAME and unique within the pod. Each
  1367  	// named port in a pod must have a unique name. Name for the port that can be
  1368  	// referred to by services.
  1369  	// +optional
  1370  	Name string `json:"name,omitempty"`
  1371  	// Protocol for port. Must be UDP or TCP.
  1372  	// Defaults to "TCP".
  1373  	// +optional
  1374  	Protocol string `json:"protocol,omitempty"`
  1375  	// Number of port to expose for the virtual machine.
  1376  	// This must be a valid port number, 0 < x < 65536.
  1377  	Port int32 `json:"port"`
  1378  }
  1379  
  1380  type AccessCredentialSecretSource struct {
  1381  	// SecretName represents the name of the secret in the VMI's namespace
  1382  	SecretName string `json:"secretName"`
  1383  }
  1384  
  1385  type ConfigDriveSSHPublicKeyAccessCredentialPropagation struct{}
  1386  type NoCloudSSHPublicKeyAccessCredentialPropagation struct{}
  1387  
  1388  // AuthorizedKeysFile represents a path within the guest
  1389  // that ssh public keys should be propagated to
  1390  type AuthorizedKeysFile struct {
  1391  	// FilePath represents the place on the guest that the authorized_keys
  1392  	// file should be writen to. This is expected to be a full path including
  1393  	// both the base directory and file name.
  1394  	FilePath string `json:"filePath"`
  1395  }
  1396  
  1397  type QemuGuestAgentUserPasswordAccessCredentialPropagation struct{}
  1398  
  1399  type QemuGuestAgentSSHPublicKeyAccessCredentialPropagation struct {
  1400  	// Users represents a list of guest users that should have the ssh public keys
  1401  	// added to their authorized_keys file.
  1402  	// +listType=set
  1403  	Users []string `json:"users"`
  1404  }
  1405  
  1406  // SSHPublicKeyAccessCredentialSource represents where to retrieve the ssh key
  1407  // credentials
  1408  // Only one of its members may be specified.
  1409  type SSHPublicKeyAccessCredentialSource struct {
  1410  	// Secret means that the access credential is pulled from a kubernetes secret
  1411  	// +optional
  1412  	Secret *AccessCredentialSecretSource `json:"secret,omitempty"`
  1413  }
  1414  
  1415  // SSHPublicKeyAccessCredentialPropagationMethod represents the method used to
  1416  // inject a ssh public key into the vm guest.
  1417  // Only one of its members may be specified.
  1418  type SSHPublicKeyAccessCredentialPropagationMethod struct {
  1419  	// ConfigDrivePropagation means that the ssh public keys are injected
  1420  	// into the VM using metadata using the configDrive cloud-init provider
  1421  	// +optional
  1422  	ConfigDrive *ConfigDriveSSHPublicKeyAccessCredentialPropagation `json:"configDrive,omitempty"`
  1423  
  1424  	// NoCloudPropagation means that the ssh public keys are injected
  1425  	// into the VM using metadata using the noCloud cloud-init provider
  1426  	// +optional
  1427  	NoCloud *NoCloudSSHPublicKeyAccessCredentialPropagation `json:"noCloud,omitempty"`
  1428  
  1429  	// QemuGuestAgentAccessCredentailPropagation means ssh public keys are
  1430  	// dynamically injected into the vm at runtime via the qemu guest agent.
  1431  	// This feature requires the qemu guest agent to be running within the guest.
  1432  	// +optional
  1433  	QemuGuestAgent *QemuGuestAgentSSHPublicKeyAccessCredentialPropagation `json:"qemuGuestAgent,omitempty"`
  1434  }
  1435  
  1436  // SSHPublicKeyAccessCredential represents a source and propagation method for
  1437  // injecting ssh public keys into a vm guest
  1438  type SSHPublicKeyAccessCredential struct {
  1439  	// Source represents where the public keys are pulled from
  1440  	Source SSHPublicKeyAccessCredentialSource `json:"source"`
  1441  
  1442  	// PropagationMethod represents how the public key is injected into the vm guest.
  1443  	PropagationMethod SSHPublicKeyAccessCredentialPropagationMethod `json:"propagationMethod"`
  1444  }
  1445  
  1446  // UserPasswordAccessCredentialSource represents where to retrieve the user password
  1447  // credentials
  1448  // Only one of its members may be specified.
  1449  type UserPasswordAccessCredentialSource struct {
  1450  	// Secret means that the access credential is pulled from a kubernetes secret
  1451  	// +optional
  1452  	Secret *AccessCredentialSecretSource `json:"secret,omitempty"`
  1453  }
  1454  
  1455  // UserPasswordAccessCredentialPropagationMethod represents the method used to
  1456  // inject a user passwords into the vm guest.
  1457  // Only one of its members may be specified.
  1458  type UserPasswordAccessCredentialPropagationMethod struct {
  1459  	// QemuGuestAgentAccessCredentailPropagation means passwords are
  1460  	// dynamically injected into the vm at runtime via the qemu guest agent.
  1461  	// This feature requires the qemu guest agent to be running within the guest.
  1462  	// +optional
  1463  	QemuGuestAgent *QemuGuestAgentUserPasswordAccessCredentialPropagation `json:"qemuGuestAgent,omitempty"`
  1464  }
  1465  
  1466  // UserPasswordAccessCredential represents a source and propagation method for
  1467  // injecting user passwords into a vm guest
  1468  // Only one of its members may be specified.
  1469  type UserPasswordAccessCredential struct {
  1470  	// Source represents where the user passwords are pulled from
  1471  	Source UserPasswordAccessCredentialSource `json:"source"`
  1472  
  1473  	// propagationMethod represents how the user passwords are injected into the vm guest.
  1474  	PropagationMethod UserPasswordAccessCredentialPropagationMethod `json:"propagationMethod"`
  1475  }
  1476  
  1477  // AccessCredential represents a credential source that can be used to
  1478  // authorize remote access to the vm guest
  1479  // Only one of its members may be specified.
  1480  type AccessCredential struct {
  1481  	// SSHPublicKey represents the source and method of applying a ssh public
  1482  	// key into a guest virtual machine.
  1483  	// +optional
  1484  	SSHPublicKey *SSHPublicKeyAccessCredential `json:"sshPublicKey,omitempty"`
  1485  	// UserPassword represents the source and method for applying a guest user's
  1486  	// password
  1487  	// +optional
  1488  	UserPassword *UserPasswordAccessCredential `json:"userPassword,omitempty"`
  1489  }
  1490  
  1491  // Network represents a network type and a resource that should be connected to the vm.
  1492  type Network struct {
  1493  	// Network name.
  1494  	// Must be a DNS_LABEL and unique within the vm.
  1495  	// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
  1496  	Name string `json:"name"`
  1497  	// NetworkSource represents the network type and the source interface that should be connected to the virtual machine.
  1498  	// Defaults to Pod, if no type is specified.
  1499  	NetworkSource `json:",inline"`
  1500  }
  1501  
  1502  // Represents the source resource that will be connected to the vm.
  1503  // Only one of its members may be specified.
  1504  type NetworkSource struct {
  1505  	Pod    *PodNetwork    `json:"pod,omitempty"`
  1506  	Multus *MultusNetwork `json:"multus,omitempty"`
  1507  }
  1508  
  1509  // Represents the stock pod network interface.
  1510  type PodNetwork struct {
  1511  	// CIDR for vm network.
  1512  	// Default 10.0.2.0/24 if not specified.
  1513  	VMNetworkCIDR string `json:"vmNetworkCIDR,omitempty"`
  1514  
  1515  	// IPv6 CIDR for the vm network.
  1516  	// Defaults to fd10:0:2::/120 if not specified.
  1517  	VMIPv6NetworkCIDR string `json:"vmIPv6NetworkCIDR,omitempty"`
  1518  }
  1519  
  1520  func (podNet *PodNetwork) UnmarshalJSON(data []byte) error {
  1521  	type PodNetworkAlias PodNetwork
  1522  	var podNetAlias PodNetworkAlias
  1523  
  1524  	if err := json.Unmarshal(data, &podNetAlias); err != nil {
  1525  		return err
  1526  	}
  1527  
  1528  	if sanitizedCIDR, err := sanitizeCIDR(podNetAlias.VMNetworkCIDR); err == nil {
  1529  		podNetAlias.VMNetworkCIDR = sanitizedCIDR
  1530  	}
  1531  
  1532  	*podNet = PodNetwork(podNetAlias)
  1533  	return nil
  1534  }
  1535  
  1536  // Rng represents the random device passed from host
  1537  type Rng struct {
  1538  }
  1539  
  1540  // Represents the multus cni network.
  1541  type MultusNetwork struct {
  1542  	// References to a NetworkAttachmentDefinition CRD object. Format:
  1543  	// <networkName>, <namespace>/<networkName>. If namespace is not
  1544  	// specified, VMI namespace is assumed.
  1545  	NetworkName string `json:"networkName"`
  1546  
  1547  	// Select the default network and add it to the
  1548  	// multus-cni.io/default-network annotation.
  1549  	Default bool `json:"default,omitempty"`
  1550  }
  1551  
  1552  // CPUTopology allows specifying the amount of cores, sockets
  1553  // and threads.
  1554  type CPUTopology struct {
  1555  	// Cores specifies the number of cores inside the vmi.
  1556  	// Must be a value greater or equal 1.
  1557  	Cores uint32 `json:"cores,omitempty"`
  1558  	// Sockets specifies the number of sockets inside the vmi.
  1559  	// Must be a value greater or equal 1.
  1560  	Sockets uint32 `json:"sockets,omitempty"`
  1561  	// Threads specifies the number of threads inside the vmi.
  1562  	// Must be a value greater or equal 1.
  1563  	Threads uint32 `json:"threads,omitempty"`
  1564  }