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 <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2020-02-28 21:14:07 +00:00
parent ee941e5c56
commit abbdf078cd
2 changed files with 11 additions and 0 deletions

View File

@ -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,
}
}

View File

@ -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