mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
blk-dev: hotplug readonly if applicable
If a block based volume is read only, let's make sure we add as a RO device Fixes: #1246 Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
This commit is contained in:
parent
12777b26e4
commit
789fd7c1c6
@ -669,6 +669,7 @@ func (c *Container) createBlockDevices() error {
|
|||||||
DevType: "b",
|
DevType: "b",
|
||||||
Major: int64(unix.Major(stat.Rdev)),
|
Major: int64(unix.Major(stat.Rdev)),
|
||||||
Minor: int64(unix.Minor(stat.Rdev)),
|
Minor: int64(unix.Minor(stat.Rdev)),
|
||||||
|
ReadOnly: m.ReadOnly,
|
||||||
}
|
}
|
||||||
// check whether source can be used as a pmem device
|
// check whether source can be used as a pmem device
|
||||||
} else if di, err = config.PmemDeviceInfo(m.Source, m.Destination); err != nil {
|
} else if di, err = config.PmemDeviceInfo(m.Source, m.Destination); err != nil {
|
||||||
|
@ -114,6 +114,9 @@ type DeviceInfo struct {
|
|||||||
// for a nvdimm device in the guest.
|
// for a nvdimm device in the guest.
|
||||||
Pmem bool
|
Pmem bool
|
||||||
|
|
||||||
|
// If applicable, should this device be considered RO
|
||||||
|
ReadOnly bool
|
||||||
|
|
||||||
// ColdPlug specifies whether the device must be cold plugged (true)
|
// ColdPlug specifies whether the device must be cold plugged (true)
|
||||||
// or hot plugged (false).
|
// or hot plugged (false).
|
||||||
ColdPlug bool
|
ColdPlug bool
|
||||||
|
@ -61,11 +61,12 @@ func (device *BlockDevice) Attach(devReceiver api.DeviceReceiver) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drive := &config.BlockDrive{
|
drive := &config.BlockDrive{
|
||||||
File: device.DeviceInfo.HostPath,
|
File: device.DeviceInfo.HostPath,
|
||||||
Format: "raw",
|
Format: "raw",
|
||||||
ID: utils.MakeNameID("drive", device.DeviceInfo.ID, maxDevIDSize),
|
ID: utils.MakeNameID("drive", device.DeviceInfo.ID, maxDevIDSize),
|
||||||
Index: index,
|
Index: index,
|
||||||
Pmem: device.DeviceInfo.Pmem,
|
Pmem: device.DeviceInfo.Pmem,
|
||||||
|
ReadOnly: device.DeviceInfo.ReadOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
if fs, ok := device.DeviceInfo.DriverOptions["fstype"]; ok {
|
if fs, ok := device.DeviceInfo.DriverOptions["fstype"]; ok {
|
||||||
|
@ -1233,9 +1233,9 @@ func (q *qemu) hotplugAddBlockDevice(drive *config.BlockDrive, op operation, dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
if q.config.BlockDeviceCacheSet {
|
if q.config.BlockDeviceCacheSet {
|
||||||
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithCache(q.qmpMonitorCh.ctx, drive.File, drive.ID, q.config.BlockDeviceCacheDirect, q.config.BlockDeviceCacheNoflush, false)
|
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAddWithCache(q.qmpMonitorCh.ctx, drive.File, drive.ID, q.config.BlockDeviceCacheDirect, q.config.BlockDeviceCacheNoflush, drive.ReadOnly)
|
||||||
} else {
|
} else {
|
||||||
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAdd(q.qmpMonitorCh.ctx, drive.File, drive.ID, false)
|
err = q.qmpMonitorCh.qmp.ExecuteBlockdevAdd(q.qmpMonitorCh.ctx, drive.File, drive.ID, drive.ReadOnly)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user