mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-23 05:58:04 +00:00
virtcontainers: handle persistent memory volumes
A persistent memory volume MUST meet the following conditions: * A loop device must be mounted in the directory passed as volume * The loop device must have a backing file * The backing file must have the PFN signature at offset 4k [1][2] The backing file is used as backend file for a NVDIMM device in the guest fixes #2262 [1] - https://github.com/kata-containers/osbuilder/blob/master/image-builder /nsdax.gpl.c [2] - https://github.com/torvalds/linux/blob/master/drivers/nvdimm/pfn.h Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
434b30255e
commit
2c310fecd4
@ -1099,6 +1099,13 @@ func (k *kataAgent) appendBlockDevice(dev ContainerDevice, c *Container) *grpc.D
|
||||
return nil
|
||||
}
|
||||
|
||||
if d.Pmem {
|
||||
// block drive is a persistent memory device that
|
||||
// was passed as volume (-v) not as device (--device).
|
||||
// It shouldn't be visible in the container
|
||||
return nil
|
||||
}
|
||||
|
||||
kataDevice := &grpc.Device{
|
||||
ContainerPath: dev.ContainerPath,
|
||||
}
|
||||
@ -1461,6 +1468,12 @@ func (k *kataAgent) handleDeviceBlockVolume(c *Container, device api.Device) (*g
|
||||
return nil, fmt.Errorf("malformed block drive")
|
||||
}
|
||||
switch {
|
||||
// pmem volumes case
|
||||
case blockDrive.Pmem:
|
||||
vol.Driver = kataNvdimmDevType
|
||||
vol.Source = fmt.Sprintf("/dev/pmem%s", blockDrive.NvdimmID)
|
||||
vol.Fstype = blockDrive.Format
|
||||
vol.Options = []string{"dax"}
|
||||
case c.sandbox.config.HypervisorConfig.BlockDeviceDriver == config.VirtioBlockCCW:
|
||||
vol.Driver = kataBlkCCWDevType
|
||||
vol.Source = blockDrive.DevNo
|
||||
@ -1538,8 +1551,12 @@ func (k *kataAgent) handleBlockVolumes(c *Container) ([]*grpc.Storage, error) {
|
||||
}
|
||||
|
||||
vol.MountPoint = m.Destination
|
||||
if vol.Fstype == "" {
|
||||
vol.Fstype = "bind"
|
||||
}
|
||||
if len(vol.Options) == 0 {
|
||||
vol.Options = []string{"bind"}
|
||||
}
|
||||
|
||||
volumeStorages = append(volumeStorages, vol)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user