diff --git a/virtcontainers/pkg/annotations/annotations.go b/virtcontainers/pkg/annotations/annotations.go index fa580cc9d..e06b071ea 100644 --- a/virtcontainers/pkg/annotations/annotations.go +++ b/virtcontainers/pkg/annotations/annotations.go @@ -90,6 +90,9 @@ const ( // UseVSock is a sandbox annotation to specify use of vsock for agent communication. UseVSock = kataAnnotHypervisorPrefix + "use_vsock" + // DisableImageNvdimm is a sandbox annotation to specify use of nvdimm device for guest rootfs image. + DisableImageNvdimm = kataAnnotHypervisorPrefix + "disable_image_nvdimm" + // HotplugVFIOOnRootBus is a sandbox annotation used to indicate if devices need to be hotplugged on the // root bus instead of a bridge. HotplugVFIOOnRootBus = kataAnnotHypervisorPrefix + "hotplug_vfio_on_root_bus" diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index 98e2a843d..4cf6d5f10 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -429,6 +429,15 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) config.HypervisorConfig.UseVSock = useVsock } + if value, ok := ocispec.Annotations[vcAnnotations.DisableImageNvdimm]; ok { + disableNvdimm, err := strconv.ParseBool(value) + if err != nil { + return fmt.Errorf("Error parsing annotation for use_nvdimm: Please specify boolean value 'true|false'") + } + + config.HypervisorConfig.DisableImageNvdimm = disableNvdimm + } + if value, ok := ocispec.Annotations[vcAnnotations.HotplugVFIOOnRootBus]; ok { hotplugVFIOOnRootBus, err := strconv.ParseBool(value) if err != nil { diff --git a/virtcontainers/pkg/oci/utils_test.go b/virtcontainers/pkg/oci/utils_test.go index 5bd09b721..592cf67d5 100644 --- a/virtcontainers/pkg/oci/utils_test.go +++ b/virtcontainers/pkg/oci/utils_test.go @@ -745,6 +745,7 @@ func TestAddHypervisorAnnotations(t *testing.T) { ocispec.Annotations[vcAnnotations.DisableVhostNet] = "true" ocispec.Annotations[vcAnnotations.GuestHookPath] = "/usr/bin/" ocispec.Annotations[vcAnnotations.UseVSock] = "true" + ocispec.Annotations[vcAnnotations.DisableImageNvdimm] = "true" ocispec.Annotations[vcAnnotations.HotplugVFIOOnRootBus] = "true" ocispec.Annotations[vcAnnotations.EntropySource] = "/dev/urandom" @@ -773,6 +774,7 @@ func TestAddHypervisorAnnotations(t *testing.T) { assert.Equal(config.HypervisorConfig.DisableVhostNet, true) assert.Equal(config.HypervisorConfig.GuestHookPath, "/usr/bin/") assert.Equal(config.HypervisorConfig.UseVSock, true) + assert.Equal(config.HypervisorConfig.DisableImageNvdimm, true) assert.Equal(config.HypervisorConfig.HotplugVFIOOnRootBus, true) assert.Equal(config.HypervisorConfig.EntropySource, "/dev/urandom")