Skip to content

Commit

Permalink
virt-api, Arm64: validate if setting watchdog or sound device
Browse files Browse the repository at this point in the history
For more details, please refer to:
kubevirt#8916 (comment)

Signed-off-by: howard zhang <[email protected]>
  • Loading branch information
zhlhahaha committed Jan 12, 2023
1 parent 486065d commit d438014
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/virt-api/webhooks/arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func ValidateVirtualMachineInstanceArm64Setting(field *k8sfield.Path, spec *v1.V
validateBootOptions(field, spec, &statusCauses)
validateCPUModel(field, spec, &statusCauses)
validateDiskBus(field, spec, &statusCauses)
validateWatchdog(field, spec, &statusCauses)
validateSoundDevice(field, spec, &statusCauses)
return statusCauses
}

Expand Down Expand Up @@ -112,6 +114,26 @@ func validateDiskBus(field *k8sfield.Path, spec *v1.VirtualMachineInstanceSpec,
}
}

func validateWatchdog(field *k8sfield.Path, spec *v1.VirtualMachineInstanceSpec, statusCauses *[]metav1.StatusCause) {
if spec.Domain.Devices.Watchdog != nil {
*statusCauses = append(*statusCauses, metav1.StatusCause{
Type: metav1.CauseTypeFieldValueNotSupported,
Message: "Arm64 not support Watchdog device",
Field: field.Child("domain", "devices", "watchdog").String(),
})
}
}

func validateSoundDevice(field *k8sfield.Path, spec *v1.VirtualMachineInstanceSpec, statusCauses *[]metav1.StatusCause) {
if spec.Domain.Devices.Sound != nil {
*statusCauses = append(*statusCauses, metav1.StatusCause{
Type: metav1.CauseTypeFieldValueNotSupported,
Message: "Arm64 not support sound device",
Field: field.Child("domain", "devices", "sound").String(),
})
}
}

// setDefaultCPUModel set default cpu model to host-passthrough
func setDefaultCPUModel(vmi *v1.VirtualMachineInstance) {
if vmi.Spec.Domain.CPU == nil {
Expand Down

0 comments on commit d438014

Please sign in to comment.