Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: add Pmem attribute to BlockDrive
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Julio Montes committed Mar 20, 2020
1 parent ee941e5 commit abbdf07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions virtcontainers/device/drivers/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -169,6 +174,7 @@ func (device *BlockDevice) Save() persistapi.DeviceState {
NvdimmID: drive.NvdimmID,
VirtPath: drive.VirtPath,
DevNo: drive.DevNo,
Pmem: drive.Pmem,
}
}
return ds
Expand All @@ -194,6 +200,7 @@ func (device *BlockDevice) Load(ds persistapi.DeviceState) {
NvdimmID: bd.NvdimmID,
VirtPath: bd.VirtPath,
DevNo: bd.DevNo,
Pmem: bd.Pmem,
}
}

Expand Down
4 changes: 4 additions & 0 deletions virtcontainers/persist/api/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abbdf07

Please sign in to comment.