mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
qemu: pass guest image file readonly
So that we fobid guest from making changes to it. Fixes: #2476 Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
63fdf5328f
commit
46392945c6
@ -153,6 +153,9 @@ type BlockDrive struct {
|
||||
|
||||
// ShareRW enables multiple qemu instances to share the File
|
||||
ShareRW bool
|
||||
|
||||
// ReadOnly sets the device file readonly
|
||||
ReadOnly bool
|
||||
}
|
||||
|
||||
// VFIODeviceType indicates VFIO device type
|
||||
|
@ -343,10 +343,11 @@ func genericImage(path string) (config.BlockDrive, error) {
|
||||
id := utils.MakeNameID("image", hex.EncodeToString(randBytes), maxDevIDSize)
|
||||
|
||||
drive := config.BlockDrive{
|
||||
File: path,
|
||||
Format: "raw",
|
||||
ID: id,
|
||||
ShareRW: true,
|
||||
File: path,
|
||||
Format: "raw",
|
||||
ID: id,
|
||||
ShareRW: true,
|
||||
ReadOnly: true,
|
||||
}
|
||||
|
||||
return drive, nil
|
||||
@ -603,6 +604,7 @@ func genericBlockDevice(drive config.BlockDrive, nestedRun bool) (govmmQemu.Bloc
|
||||
Interface: "none",
|
||||
DisableModern: nestedRun,
|
||||
ShareRW: drive.ShareRW,
|
||||
ReadOnly: drive.ReadOnly,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,7 @@ func TestQemuArchBaseAppendImage(t *testing.T) {
|
||||
Format: "raw",
|
||||
Interface: "none",
|
||||
ShareRW: true,
|
||||
ReadOnly: true,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user