mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
hw/block: Request permissions
This makes all device emulations with a qdev drive property request permissions on their BlockBackend. The only thing we block at this point is resizing images for some devices that can't support it. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Fam Zheng <famz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
39829a01ae
commit
a17c17a274
17 changed files with 142 additions and 27 deletions
|
@ -632,6 +632,19 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
|
|||
vmstate_register_ram(&pfl->orig_mem, DEVICE(pfl));
|
||||
pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);
|
||||
pfl->chip_len = chip_len;
|
||||
|
||||
if (pfl->blk) {
|
||||
uint64_t perm;
|
||||
pfl->ro = blk_is_read_only(pfl->blk);
|
||||
perm = BLK_PERM_CONSISTENT_READ | (pfl->ro ? 0 : BLK_PERM_WRITE);
|
||||
ret = blk_set_perm(pfl->blk, perm, BLK_PERM_ALL, errp);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pfl->ro = 0;
|
||||
}
|
||||
|
||||
if (pfl->blk) {
|
||||
/* read the initial flash content */
|
||||
ret = blk_pread(pfl->blk, 0, pfl->storage, chip_len);
|
||||
|
@ -646,12 +659,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
|
|||
pfl->rom_mode = 1;
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
|
||||
|
||||
if (pfl->blk) {
|
||||
pfl->ro = blk_is_read_only(pfl->blk);
|
||||
} else {
|
||||
pfl->ro = 0;
|
||||
}
|
||||
|
||||
pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl);
|
||||
pfl->wcycle = 0;
|
||||
pfl->cmd = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue