util

package
v1.5.0-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 11 Imported by: 20

Documentation

Index

Constants

View Source
const (
	ExtensionAPIServerAuthenticationConfigMap = "extension-apiserver-authentication"
	RequestHeaderClientCAFileKey              = "requestheader-client-ca-file"
	VirtShareDir                              = "/var/run/kubevirt"
	VirtPrivateDir                            = "/var/run/kubevirt-private"
	KubeletRoot                               = "/var/lib/kubelet"
	KubeletPodsDir                            = KubeletRoot + "/pods"
	HostRootMount                             = "/proc/1/root/"

	NonRootUID        = 107
	NonRootUserString = "qemu"
	RootUser          = 0
)

Variables

This section is empty.

Functions

func AlignImageSizeTo1MiB added in v0.49.1

func AlignImageSizeTo1MiB(size int64, logger *log.FilteredLogger) int64

AlignImageSizeTo1MiB rounds down the size to the nearest multiple of 1MiB A warning or an error may get logged The caller is responsible for ensuring the rounded-down size is not 0

func CalcExpectedMemoryDumpSize added in v0.56.0

func CalcExpectedMemoryDumpSize(vmi *v1.VirtualMachineInstance) *resource.Quantity

func CloseIOAndCheckErr added in v0.36.0

func CloseIOAndCheckErr(c io.Closer, err *error)

CloseIOAndCheckErr closes the file and check the returned error. If there was an error a log messages will be printed. If a valid address (not nil) is passed in err the function will also update the error Note: to update the error the calling funtion need to use named returned variable (If called as defer function)

func GenerateKubeVirtGroupVersionKind added in v0.58.1

func GenerateKubeVirtGroupVersionKind(obj runtime.Object) (runtime.Object, error)

GenerateKubeVirtGroupVersionKind ensures a provided object registered with KubeVirts generated schema has GVK set correctly. This is required as client-go continues to return objects without TypeMeta set as set out in the following issue: https://github.com/kubernetes/client-go/issues/413

func GenerateVMExportToken

func GenerateVMExportToken() (string, error)

GenerateVMExportToken creates a cryptographically secure token for VM export

func HasKernelBootContainerImage added in v0.42.0

func HasKernelBootContainerImage(vmi *v1.VirtualMachineInstance) bool

Checks if kernel boot is defined in a valid way

func IsAutoAttachVSOCK added in v0.59.0

func IsAutoAttachVSOCK(vmi *v1.VirtualMachineInstance) bool

func IsGPUVMI added in v0.22.0

func IsGPUVMI(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests GPU

func IsHostDevVMI added in v0.36.0

func IsHostDevVMI(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests a HostDevice

func IsNonRootVMI added in v0.44.1

func IsNonRootVMI(vmi *v1.VirtualMachineInstance) bool

func IsSEVAttestationRequested added in v1.1.0

func IsSEVAttestationRequested(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests SEV with attestation

func IsSEVVMI added in v0.49.0

func IsSEVVMI(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests AMD SEV

func IsVFIOVMI added in v0.36.0

func IsVFIOVMI(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests a VFIO device

func IsVMIVirtiofsEnabled added in v0.34.0

func IsVMIVirtiofsEnabled(vmi *v1.VirtualMachineInstance) bool

Check if a VMI spec requests VirtIO-FS

func MkdirAllWithNosec added in v0.40.0

func MkdirAllWithNosec(pathName string) error

func NeedTunDevice added in v0.51.0

func NeedTunDevice(vmi *v1.VirtualMachineInstance) bool

func OpenFileWithNosec added in v0.40.0

func OpenFileWithNosec(pathName string, flag int) (*os.File, error)

func ResourceNameToEnvVar added in v0.36.0

func ResourceNameToEnvVar(prefix string, resourceName string) string

func SetDefaultVolumeDisk added in v0.55.0

func SetDefaultVolumeDisk(spec *v1.VirtualMachineInstanceSpec)

func WantVirtioNetDevice added in v0.45.0

func WantVirtioNetDevice(vmi *v1.VirtualMachineInstance) bool

WantVirtioNetDevice checks whether a VMI references at least one "virtio" network interface. Note that the reference can be explicit or implicit (unspecified nic models defaults to "virtio").

func WriteBytes added in v0.36.4

func WriteBytes(f *os.File, c byte, n int64) error

func WriteFileWithNosec added in v0.40.0

func WriteFileWithNosec(pathName string, data []byte) error

Types

This section is empty.

Directories

Path Synopsis
net
dns
grpc
* 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.
* 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.
ip
* 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.
* 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL