mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-18 06:44:23 +01:00
qemu: add block device readonly support
So that we can attach it readonly. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
@@ -971,6 +971,9 @@ type BlockDevice struct {
|
||||
// ShareRW enables multiple qemu instances to share the File
|
||||
ShareRW bool
|
||||
|
||||
// ReadOnly sets the block device in readonly mode
|
||||
ReadOnly bool
|
||||
|
||||
// Transport is the virtio transport for this device.
|
||||
Transport VirtioTransport
|
||||
}
|
||||
@@ -1029,6 +1032,10 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
|
||||
blkParams = append(blkParams, fmt.Sprintf(",format=%s", blkdev.Format))
|
||||
blkParams = append(blkParams, fmt.Sprintf(",if=%s", blkdev.Interface))
|
||||
|
||||
if blkdev.ReadOnly {
|
||||
blkParams = append(blkParams, ",readonly")
|
||||
}
|
||||
|
||||
qemuParams = append(qemuParams, "-device")
|
||||
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user