vmis with virtiofs require memory backing shared access
@@ -822,12 +822,27 @@ func Convert_v1_VirtualMachine_To_api_Domain(vmi *v1.VirtualMachineInstance, dom
return err
}
+ var isMemfdRequired = false
if vmi.Spec.Domain.Memory != nil && vmi.Spec.Domain.Memory.Hugepages != nil {
domain.Spec.MemoryBacking = &MemoryBacking{
HugePages: &HugePages{},
}
-
if val := vmi.Annotations[v1.MemfdMemoryBackend]; val != "false" {
+ isMemfdRequired = true
+ }
+ }
+ // virtiofs require shared access
+ if utils.IsVMIVirtiofsEnabled {
+ if domain.Spec.MemoryBacking == nil {
+ domain.Spec.MemoryBacking = &MemoryBacking{}
+ }
+ domain.Spec.MemoryBacking.Access = &MemoryBackingAccess{
+ Mode: "shared",
+ }
+ isMemfdRequired = true
+ }
+
+ if isMemfdRequired {
// Set memfd as memory backend to solve SELinux restrictions
// See the issue: https://github.com/kubevirt/kubevirt/issues/3781
domain.Spec.MemoryBacking.Source = &MemoryBackingSource{Type: "memfd"}
@@ -844,8 +859,6 @@ func Convert_v1_VirtualMachine_To_api_Domain(vmi *v1.VirtualMachineInstance, dom
}
}
- }
-
volumeIndices := map[string]int{}
volumes := map[string]*v1.Volume{}
for i, volume := range vmi.Spec.Volumes {
