From abbdf078cd5aaf328f5cccf2dfc33730e92d8dc7 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 28 Feb 2020 21:14:07 +0000 Subject: [PATCH] virtcontainers: add Pmem attribute to BlockDrive A `BlockDrive` can be used as pmem device, since they both are similar and can be mounted in the same way in the guest. The `Pmem` attribute helps kata to identify a pmem device and how it has to be hotplugged in the guest. Signed-off-by: Julio Montes --- virtcontainers/device/drivers/block.go | 7 +++++++ virtcontainers/persist/api/device.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/virtcontainers/device/drivers/block.go b/virtcontainers/device/drivers/block.go index 62d55f649..671134557 100644 --- a/virtcontainers/device/drivers/block.go +++ b/virtcontainers/device/drivers/block.go @@ -65,6 +65,11 @@ func (device *BlockDevice) Attach(devReceiver api.DeviceReceiver) (err error) { Format: "raw", ID: utils.MakeNameID("drive", device.DeviceInfo.ID, maxDevIDSize), Index: index, + Pmem: device.DeviceInfo.Pmem, + } + + if fs, ok := device.DeviceInfo.DriverOptions["fstype"]; ok { + drive.Format = fs } customOptions := device.DeviceInfo.DriverOptions @@ -169,6 +174,7 @@ func (device *BlockDevice) Save() persistapi.DeviceState { NvdimmID: drive.NvdimmID, VirtPath: drive.VirtPath, DevNo: drive.DevNo, + Pmem: drive.Pmem, } } return ds @@ -194,6 +200,7 @@ func (device *BlockDevice) Load(ds persistapi.DeviceState) { NvdimmID: bd.NvdimmID, VirtPath: bd.VirtPath, DevNo: bd.DevNo, + Pmem: bd.Pmem, } } diff --git a/virtcontainers/persist/api/device.go b/virtcontainers/persist/api/device.go index 67226542a..34916ed0b 100644 --- a/virtcontainers/persist/api/device.go +++ b/virtcontainers/persist/api/device.go @@ -41,6 +41,10 @@ type BlockDrive struct { // DevNo DevNo string + + // Pmem enabled persistent memory. Use File as backing file + // for a nvdimm device in the guest. + Pmem bool } // VFIODev represents a VFIO drive used for hotplugging