mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2024-11-05 05:52:15 +03:00
block: Change blk_{pread,pwrite}() param order
Swap 'buf' and 'bytes' around for consistency with blk_co_{pread,pwrite}(), and in preparation to implement these functions using generated_co_wrapper. Callers were updated using this Coccinelle script: @@ expression blk, offset, buf, bytes, flags; @@ - blk_pread(blk, offset, buf, bytes, flags) + blk_pread(blk, offset, bytes, buf, flags) @@ expression blk, offset, buf, bytes, flags; @@ - blk_pwrite(blk, offset, buf, bytes, flags) + blk_pwrite(blk, offset, bytes, buf, flags) It had no effect on hw/block/nand.c, presumably due to the #if, so that file was updated manually. Overly-long lines were then fixed by hand. Signed-off-by: Alberto Faria <afaria@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20220705161527.1054072-4-afaria@redhat.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
parent
3b35d4542c
commit
a9262f551e
2
block.c
2
block.c
@ -1037,7 +1037,7 @@ static int find_image_format(BlockBackend *file, const char *filename,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = blk_pread(file, 0, buf, sizeof(buf), 0);
|
||||
ret = blk_pread(file, 0, sizeof(buf), buf, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not read image for determining its "
|
||||
"format");
|
||||
|
@ -1563,7 +1563,7 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
|
||||
flags | BDRV_REQ_ZERO_WRITE, cb, opaque);
|
||||
}
|
||||
|
||||
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes,
|
||||
int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
int ret;
|
||||
@ -1577,7 +1577,7 @@ int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int bytes,
|
||||
int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *buf,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
|
||||
|
@ -527,12 +527,12 @@ int bdrv_commit(BlockDriverState *bs)
|
||||
goto ro_cleanup;
|
||||
}
|
||||
if (ret) {
|
||||
ret = blk_pread(src, offset, buf, n, 0);
|
||||
ret = blk_pread(src, offset, n, buf, 0);
|
||||
if (ret < 0) {
|
||||
goto ro_cleanup;
|
||||
}
|
||||
|
||||
ret = blk_pwrite(backing, offset, buf, n, 0);
|
||||
ret = blk_pwrite(backing, offset, n, buf, 0);
|
||||
if (ret < 0) {
|
||||
goto ro_cleanup;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ static int block_crypto_create_write_func(QCryptoBlock *block,
|
||||
struct BlockCryptoCreateData *data = opaque;
|
||||
ssize_t ret;
|
||||
|
||||
ret = blk_pwrite(data->blk, offset, buf, buflen, 0);
|
||||
ret = blk_pwrite(data->blk, offset, buflen, buf, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not write encryption header");
|
||||
return ret;
|
||||
|
@ -554,7 +554,7 @@ static void fuse_read(fuse_req_t req, fuse_ino_t inode,
|
||||
return;
|
||||
}
|
||||
|
||||
ret = blk_pread(exp->common.blk, offset, buf, size, 0);
|
||||
ret = blk_pread(exp->common.blk, offset, size, buf, 0);
|
||||
if (ret >= 0) {
|
||||
fuse_reply_buf(req, buf, size);
|
||||
} else {
|
||||
@ -607,7 +607,7 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inode, const char *buf,
|
||||
}
|
||||
}
|
||||
|
||||
ret = blk_pwrite(exp->common.blk, offset, buf, size, 0);
|
||||
ret = blk_pwrite(exp->common.blk, offset, size, buf, 0);
|
||||
if (ret >= 0) {
|
||||
fuse_reply_write(req, size);
|
||||
} else {
|
||||
|
@ -599,7 +599,7 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
memcpy(tmp, &header, sizeof(header));
|
||||
|
||||
ret = blk_pwrite(blk, 0, tmp, BDRV_SECTOR_SIZE, 0);
|
||||
ret = blk_pwrite(blk, 0, BDRV_SECTOR_SIZE, tmp, 0);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -890,14 +890,14 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
|
||||
}
|
||||
|
||||
/* write all the data */
|
||||
ret = blk_pwrite(qcow_blk, 0, &header, sizeof(header), 0);
|
||||
ret = blk_pwrite(qcow_blk, 0, sizeof(header), &header, 0);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (qcow_opts->has_backing_file) {
|
||||
ret = blk_pwrite(qcow_blk, sizeof(header),
|
||||
qcow_opts->backing_file, backing_filename_len, 0);
|
||||
ret = blk_pwrite(qcow_blk, sizeof(header), backing_filename_len,
|
||||
qcow_opts->backing_file, 0);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
@ -907,7 +907,7 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
|
||||
for (i = 0; i < DIV_ROUND_UP(sizeof(uint64_t) * l1_size, BDRV_SECTOR_SIZE);
|
||||
i++) {
|
||||
ret = blk_pwrite(qcow_blk, header_size + BDRV_SECTOR_SIZE * i,
|
||||
tmp, BDRV_SECTOR_SIZE, 0);
|
||||
BDRV_SECTOR_SIZE, tmp, 0);
|
||||
if (ret < 0) {
|
||||
g_free(tmp);
|
||||
goto exit;
|
||||
|
@ -3666,7 +3666,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
cpu_to_be64(QCOW2_INCOMPAT_EXTL2);
|
||||
}
|
||||
|
||||
ret = blk_pwrite(blk, 0, header, cluster_size, 0);
|
||||
ret = blk_pwrite(blk, 0, cluster_size, header, 0);
|
||||
g_free(header);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not write qcow2 header");
|
||||
@ -3676,7 +3676,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
/* Write a refcount table with one refcount block */
|
||||
refcount_table = g_malloc0(2 * cluster_size);
|
||||
refcount_table[0] = cpu_to_be64(2 * cluster_size);
|
||||
ret = blk_pwrite(blk, cluster_size, refcount_table, 2 * cluster_size, 0);
|
||||
ret = blk_pwrite(blk, cluster_size, 2 * cluster_size, refcount_table, 0);
|
||||
g_free(refcount_table);
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -705,18 +705,18 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCreateOptions *opts,
|
||||
}
|
||||
|
||||
qed_header_cpu_to_le(&header, &le_header);
|
||||
ret = blk_pwrite(blk, 0, &le_header, sizeof(le_header), 0);
|
||||
ret = blk_pwrite(blk, 0, sizeof(le_header), &le_header, 0);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
ret = blk_pwrite(blk, sizeof(le_header), qed_opts->backing_file,
|
||||
header.backing_filename_size, 0);
|
||||
ret = blk_pwrite(blk, sizeof(le_header), header.backing_filename_size,
|
||||
qed_opts->backing_file, 0);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
l1_table = g_malloc0(l1_size);
|
||||
ret = blk_pwrite(blk, header.l1_table_offset, l1_table, l1_size, 0);
|
||||
ret = blk_pwrite(blk, header.l1_table_offset, l1_size, l1_table, 0);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
@ -845,7 +845,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
|
||||
vdi_header_print(&header);
|
||||
}
|
||||
vdi_header_to_le(&header);
|
||||
ret = blk_pwrite(blk, offset, &header, sizeof(header), 0);
|
||||
ret = blk_pwrite(blk, offset, sizeof(header), &header, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "Error writing header");
|
||||
goto exit;
|
||||
@ -866,7 +866,7 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreateOptions *create_options,
|
||||
bmap[i] = VDI_UNALLOCATED;
|
||||
}
|
||||
}
|
||||
ret = blk_pwrite(blk, offset, bmap, bmap_size, 0);
|
||||
ret = blk_pwrite(blk, offset, bmap_size, bmap, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "Error writing bmap");
|
||||
goto exit;
|
||||
|
20
block/vhdx.c
20
block/vhdx.c
@ -1665,13 +1665,13 @@ static int vhdx_create_new_metadata(BlockBackend *blk,
|
||||
VHDX_META_FLAGS_IS_VIRTUAL_DISK;
|
||||
vhdx_metadata_entry_le_export(&md_table_entry[4]);
|
||||
|
||||
ret = blk_pwrite(blk, metadata_offset, buffer, VHDX_HEADER_BLOCK_SIZE, 0);
|
||||
ret = blk_pwrite(blk, metadata_offset, VHDX_HEADER_BLOCK_SIZE, buffer, 0);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = blk_pwrite(blk, metadata_offset + (64 * KiB), entry_buffer,
|
||||
VHDX_METADATA_ENTRY_BUFFER_SIZE, 0);
|
||||
ret = blk_pwrite(blk, metadata_offset + (64 * KiB),
|
||||
VHDX_METADATA_ENTRY_BUFFER_SIZE, entry_buffer, 0);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
@ -1756,7 +1756,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s,
|
||||
s->bat[sinfo.bat_idx] = cpu_to_le64(s->bat[sinfo.bat_idx]);
|
||||
sector_num += s->sectors_per_block;
|
||||
}
|
||||
ret = blk_pwrite(blk, file_offset, s->bat, length, 0);
|
||||
ret = blk_pwrite(blk, file_offset, length, s->bat, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Failed to write the BAT");
|
||||
goto exit;
|
||||
@ -1860,15 +1860,15 @@ static int vhdx_create_new_region_table(BlockBackend *blk,
|
||||
}
|
||||
|
||||
/* Now write out the region headers to disk */
|
||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, buffer,
|
||||
VHDX_HEADER_BLOCK_SIZE, 0);
|
||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, VHDX_HEADER_BLOCK_SIZE,
|
||||
buffer, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Failed to write first region table");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, buffer,
|
||||
VHDX_HEADER_BLOCK_SIZE, 0);
|
||||
ret = blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, VHDX_HEADER_BLOCK_SIZE,
|
||||
buffer, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Failed to write second region table");
|
||||
goto exit;
|
||||
@ -2012,7 +2012,7 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
|
||||
creator = g_utf8_to_utf16("QEMU v" QEMU_VERSION, -1, NULL,
|
||||
&creator_items, NULL);
|
||||
signature = cpu_to_le64(VHDX_FILE_SIGNATURE);
|
||||
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature),
|
||||
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, sizeof(signature), &signature,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Failed to write file signature");
|
||||
@ -2020,7 +2020,7 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
|
||||
}
|
||||
if (creator) {
|
||||
ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature),
|
||||
creator, creator_items * sizeof(gunichar2), 0);
|
||||
creator_items * sizeof(gunichar2), creator, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Failed to write creator field");
|
||||
goto delete_and_exit;
|
||||
|
10
block/vmdk.c
10
block/vmdk.c
@ -2236,12 +2236,12 @@ static int vmdk_init_extent(BlockBackend *blk,
|
||||
header.check_bytes[3] = 0xa;
|
||||
|
||||
/* write all the data */
|
||||
ret = blk_pwrite(blk, 0, &magic, sizeof(magic), 0);
|
||||
ret = blk_pwrite(blk, 0, sizeof(magic), &magic, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, QERR_IO_ERROR);
|
||||
goto exit;
|
||||
}
|
||||
ret = blk_pwrite(blk, sizeof(magic), &header, sizeof(header), 0);
|
||||
ret = blk_pwrite(blk, sizeof(magic), sizeof(header), &header, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, QERR_IO_ERROR);
|
||||
goto exit;
|
||||
@ -2261,7 +2261,7 @@ static int vmdk_init_extent(BlockBackend *blk,
|
||||
gd_buf[i] = cpu_to_le32(tmp);
|
||||
}
|
||||
ret = blk_pwrite(blk, le64_to_cpu(header.rgd_offset) * BDRV_SECTOR_SIZE,
|
||||
gd_buf, gd_buf_size, 0);
|
||||
gd_buf_size, gd_buf, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, QERR_IO_ERROR);
|
||||
goto exit;
|
||||
@ -2273,7 +2273,7 @@ static int vmdk_init_extent(BlockBackend *blk,
|
||||
gd_buf[i] = cpu_to_le32(tmp);
|
||||
}
|
||||
ret = blk_pwrite(blk, le64_to_cpu(header.gd_offset) * BDRV_SECTOR_SIZE,
|
||||
gd_buf, gd_buf_size, 0);
|
||||
gd_buf_size, gd_buf, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, QERR_IO_ERROR);
|
||||
}
|
||||
@ -2584,7 +2584,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
|
||||
desc_offset = 0x200;
|
||||
}
|
||||
|
||||
ret = blk_pwrite(blk, desc_offset, desc, desc_len, 0);
|
||||
ret = blk_pwrite(blk, desc_offset, desc_len, desc, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not write description");
|
||||
goto exit;
|
||||
|
12
block/vpc.c
12
block/vpc.c
@ -834,13 +834,13 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFooter *footer,
|
||||
block_size = 0x200000;
|
||||
num_bat_entries = DIV_ROUND_UP(total_sectors, block_size / 512);
|
||||
|
||||
ret = blk_pwrite(blk, offset, footer, sizeof(*footer), 0);
|
||||
ret = blk_pwrite(blk, offset, sizeof(*footer), footer, 0);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
offset = 1536 + ((num_bat_entries * 4 + 511) & ~511);
|
||||
ret = blk_pwrite(blk, offset, footer, sizeof(*footer), 0);
|
||||
ret = blk_pwrite(blk, offset, sizeof(*footer), footer, 0);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
@ -850,7 +850,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFooter *footer,
|
||||
|
||||
memset(bat_sector, 0xFF, 512);
|
||||
for (i = 0; i < DIV_ROUND_UP(num_bat_entries * 4, 512); i++) {
|
||||
ret = blk_pwrite(blk, offset, bat_sector, 512, 0);
|
||||
ret = blk_pwrite(blk, offset, 512, bat_sector, 0);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
@ -878,7 +878,7 @@ static int create_dynamic_disk(BlockBackend *blk, VHDFooter *footer,
|
||||
/* Write the header */
|
||||
offset = 512;
|
||||
|
||||
ret = blk_pwrite(blk, offset, &dyndisk_header, sizeof(dyndisk_header), 0);
|
||||
ret = blk_pwrite(blk, offset, sizeof(dyndisk_header), &dyndisk_header, 0);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
@ -901,8 +901,8 @@ static int create_fixed_disk(BlockBackend *blk, VHDFooter *footer,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = blk_pwrite(blk, total_size - sizeof(*footer),
|
||||
footer, sizeof(*footer), 0);
|
||||
ret = blk_pwrite(blk, total_size - sizeof(*footer), sizeof(*footer),
|
||||
footer, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Unable to write VHD header");
|
||||
return ret;
|
||||
|
@ -174,7 +174,7 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk)
|
||||
const int64_t rom_size = 32 * KiB;
|
||||
g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
|
||||
|
||||
if (blk_pread(blk, 8 * KiB, buffer, rom_size, 0) < 0) {
|
||||
if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
|
||||
error_setg(&error_fatal, "%s: failed to read BlockBackend data",
|
||||
__func__);
|
||||
return;
|
||||
|
@ -253,7 +253,7 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
|
||||
}
|
||||
|
||||
storage = g_malloc0(rom_size);
|
||||
if (blk_pread(blk, 0, storage, rom_size, 0) < 0) {
|
||||
if (blk_pread(blk, 0, rom_size, storage, 0) < 0) {
|
||||
error_setg(errp, "failed to read the initial flash content");
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
|
||||
* block device and read only on demand.
|
||||
*/
|
||||
assert(size <= BDRV_REQUEST_MAX_BYTES);
|
||||
ret = blk_pread(blk, 0, buf, size, 0);
|
||||
ret = blk_pread(blk, 0, size, buf, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "can't read block backend");
|
||||
return false;
|
||||
|
@ -1628,8 +1628,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_len)
|
||||
if (fdctrl->data_dir != FD_DIR_WRITE ||
|
||||
len < FD_SECTOR_LEN || rel_pos != 0) {
|
||||
/* READ & SCAN commands and realign to a sector for WRITE */
|
||||
if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
|
||||
fdctrl->fifo, 0) < 0) {
|
||||
FLOPPY_DPRINTF("Floppy: error getting sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
/* Sure, image size is too small... */
|
||||
@ -1656,8 +1656,8 @@ int fdctrl_transfer_handler(void *opaque, int nchan, int dma_pos, int dma_len)
|
||||
|
||||
k->read_memory(fdctrl->dma, nchan, fdctrl->fifo + rel_pos,
|
||||
fdctrl->data_pos, len);
|
||||
if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv),
|
||||
fdctrl->fifo, BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
|
||||
fdctrl->fifo, 0) < 0) {
|
||||
FLOPPY_DPRINTF("error writing sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
|
||||
@ -1740,8 +1740,8 @@ static uint32_t fdctrl_read_data(FDCtrl *fdctrl)
|
||||
fd_sector(cur_drv));
|
||||
return 0;
|
||||
}
|
||||
if (blk_pread(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
|
||||
BDRV_SECTOR_SIZE, 0)
|
||||
if (blk_pread(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
|
||||
fdctrl->fifo, 0)
|
||||
< 0) {
|
||||
FLOPPY_DPRINTF("error getting sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
@ -1820,8 +1820,8 @@ static void fdctrl_format_sector(FDCtrl *fdctrl)
|
||||
}
|
||||
memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
|
||||
if (cur_drv->blk == NULL ||
|
||||
blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
|
||||
fdctrl->fifo, 0) < 0) {
|
||||
FLOPPY_DPRINTF("error formatting sector %d\n", fd_sector(cur_drv));
|
||||
fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00);
|
||||
} else {
|
||||
@ -2244,8 +2244,8 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
|
||||
if (pos == FD_SECTOR_LEN - 1 ||
|
||||
fdctrl->data_pos == fdctrl->data_len) {
|
||||
cur_drv = get_cur_drv(fdctrl);
|
||||
if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), fdctrl->fifo,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(cur_drv->blk, fd_offset(cur_drv), BDRV_SECTOR_SIZE,
|
||||
fdctrl->fifo, 0) < 0) {
|
||||
FLOPPY_DPRINTF("error writing sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
break;
|
||||
|
@ -63,7 +63,7 @@ static int guess_disk_lchs(BlockBackend *blk,
|
||||
|
||||
blk_get_geometry(blk, &nb_sectors);
|
||||
|
||||
if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(blk, 0, BDRV_SECTOR_SIZE, buf, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
/* test msdos magic */
|
||||
|
@ -1532,7 +1532,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)
|
||||
trace_m25p80_binding(s);
|
||||
s->storage = blk_blockalign(s->blk, s->size);
|
||||
|
||||
if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) {
|
||||
if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) {
|
||||
error_setg(errp, "failed to read the initial flash content");
|
||||
return;
|
||||
}
|
||||
|
@ -666,8 +666,8 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
sector = SECTOR(s->addr);
|
||||
off = (s->addr & PAGE_MASK) + s->offset;
|
||||
soff = SECTOR_OFFSET(s->addr);
|
||||
if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
|
||||
return;
|
||||
}
|
||||
@ -679,24 +679,24 @@ static void glue(nand_blk_write_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
MIN(OOB_SIZE, off + s->iolen - NAND_PAGE_SIZE));
|
||||
}
|
||||
|
||||
if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n", __func__, sector);
|
||||
}
|
||||
} else {
|
||||
off = PAGE_START(s->addr) + (s->addr & PAGE_MASK) + s->offset;
|
||||
sector = off >> 9;
|
||||
soff = off & 0x1ff;
|
||||
if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pread(s->blk, sector << BDRV_SECTOR_BITS,
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n", __func__, sector);
|
||||
return;
|
||||
}
|
||||
|
||||
mem_and(iobuf + soff, s->io, s->iolen);
|
||||
|
||||
if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS, iobuf,
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, sector << BDRV_SECTOR_BITS,
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n", __func__, sector);
|
||||
}
|
||||
}
|
||||
@ -723,20 +723,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
i = SECTOR(addr);
|
||||
page = SECTOR(addr + (1 << (ADDR_SHIFT + s->erase_shift)));
|
||||
for (; i < page; i ++)
|
||||
if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS, iobuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, i << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n", __func__, i);
|
||||
}
|
||||
} else {
|
||||
addr = PAGE_START(addr);
|
||||
page = addr >> 9;
|
||||
if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(s->blk, page << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n", __func__, page);
|
||||
}
|
||||
memset(iobuf + (addr & 0x1ff), 0xff, (~addr & 0x1ff) + 1);
|
||||
if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n", __func__, page);
|
||||
}
|
||||
|
||||
@ -744,20 +744,20 @@ static void glue(nand_blk_erase_, NAND_PAGE_SIZE)(NANDFlashState *s)
|
||||
i = (addr & ~0x1ff) + 0x200;
|
||||
for (addr += ((NAND_PAGE_SIZE + OOB_SIZE) << s->erase_shift) - 0x200;
|
||||
i < addr; i += 0x200) {
|
||||
if (blk_pwrite(s->blk, i, iobuf, BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, i, BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n",
|
||||
__func__, i >> 9);
|
||||
}
|
||||
}
|
||||
|
||||
page = i >> 9;
|
||||
if (blk_pread(s->blk, page << BDRV_SECTOR_BITS, iobuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(s->blk, page << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n", __func__, page);
|
||||
}
|
||||
memset(iobuf, 0xff, ((addr - 1) & 0x1ff) + 1);
|
||||
if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS, iobuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, page << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, iobuf, 0) < 0) {
|
||||
printf("%s: write error in sector %" PRIu64 "\n", __func__, page);
|
||||
}
|
||||
}
|
||||
@ -772,8 +772,8 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
|
||||
|
||||
if (s->blk) {
|
||||
if (s->mem_oob) {
|
||||
if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS, s->io,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pread(s->blk, SECTOR(addr) << BDRV_SECTOR_BITS,
|
||||
PAGE_SECTORS << BDRV_SECTOR_BITS, s->io, 0) < 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n",
|
||||
__func__, SECTOR(addr));
|
||||
}
|
||||
@ -782,8 +782,9 @@ static void glue(nand_blk_load_, NAND_PAGE_SIZE)(NANDFlashState *s,
|
||||
OOB_SIZE);
|
||||
s->ioaddr = s->io + SECTOR_OFFSET(s->addr) + offset;
|
||||
} else {
|
||||
if (blk_pread(s->blk, PAGE_START(addr), s->io,
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (blk_pread(s->blk, PAGE_START(addr),
|
||||
(PAGE_SECTORS + 2) << BDRV_SECTOR_BITS, s->io, 0)
|
||||
< 0) {
|
||||
printf("%s: read error in sector %" PRIu64 "\n",
|
||||
__func__, PAGE_START(addr) >> 9);
|
||||
}
|
||||
|
@ -229,8 +229,8 @@ static void onenand_reset(OneNANDState *s, int cold)
|
||||
/* Lock the whole flash */
|
||||
memset(s->blockwp, ONEN_LOCK_LOCKED, s->blocks);
|
||||
|
||||
if (s->blk_cur && blk_pread(s->blk_cur, 0, s->boot[0],
|
||||
8 << BDRV_SECTOR_BITS, 0) < 0) {
|
||||
if (s->blk_cur && blk_pread(s->blk_cur, 0, 8 << BDRV_SECTOR_BITS,
|
||||
s->boot[0], 0) < 0) {
|
||||
hw_error("%s: Loading the BootRAM failed.\n", __func__);
|
||||
}
|
||||
}
|
||||
@ -249,8 +249,8 @@ static inline int onenand_load_main(OneNANDState *s, int sec, int secn,
|
||||
assert(UINT32_MAX >> BDRV_SECTOR_BITS > sec);
|
||||
assert(UINT32_MAX >> BDRV_SECTOR_BITS > secn);
|
||||
if (s->blk_cur) {
|
||||
return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS, dest,
|
||||
secn << BDRV_SECTOR_BITS, 0) < 0;
|
||||
return blk_pread(s->blk_cur, sec << BDRV_SECTOR_BITS,
|
||||
secn << BDRV_SECTOR_BITS, dest, 0) < 0;
|
||||
} else if (sec + secn > s->secs_cur) {
|
||||
return 1;
|
||||
}
|
||||
@ -274,7 +274,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
|
||||
uint8_t *dp = 0;
|
||||
if (s->blk_cur) {
|
||||
dp = g_malloc(size);
|
||||
if (!dp || blk_pread(s->blk_cur, offset, dp, size, 0) < 0) {
|
||||
if (!dp || blk_pread(s->blk_cur, offset, size, dp, 0) < 0) {
|
||||
result = 1;
|
||||
}
|
||||
} else {
|
||||
@ -290,7 +290,7 @@ static inline int onenand_prog_main(OneNANDState *s, int sec, int secn,
|
||||
dp[i] &= sp[i];
|
||||
}
|
||||
if (s->blk_cur) {
|
||||
result = blk_pwrite(s->blk_cur, offset, dp, size, 0) < 0;
|
||||
result = blk_pwrite(s->blk_cur, offset, size, dp, 0) < 0;
|
||||
}
|
||||
}
|
||||
if (dp && s->blk_cur) {
|
||||
@ -308,7 +308,7 @@ static inline int onenand_load_spare(OneNANDState *s, int sec, int secn,
|
||||
|
||||
if (s->blk_cur) {
|
||||
uint32_t offset = (s->secs_cur + (sec >> 5)) << BDRV_SECTOR_BITS;
|
||||
if (blk_pread(s->blk_cur, offset, buf, BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, buf, 0) < 0) {
|
||||
return 1;
|
||||
}
|
||||
memcpy(dest, buf + ((sec & 31) << 4), secn << 4);
|
||||
@ -333,7 +333,7 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
|
||||
if (s->blk_cur) {
|
||||
dp = g_malloc(512);
|
||||
if (!dp
|
||||
|| blk_pread(s->blk_cur, offset, dp, BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
|| blk_pread(s->blk_cur, offset, BDRV_SECTOR_SIZE, dp, 0) < 0) {
|
||||
result = 1;
|
||||
} else {
|
||||
dpp = dp + ((sec & 31) << 4);
|
||||
@ -351,8 +351,8 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
|
||||
dpp[i] &= sp[i];
|
||||
}
|
||||
if (s->blk_cur) {
|
||||
result = blk_pwrite(s->blk_cur, offset, dp,
|
||||
BDRV_SECTOR_SIZE, 0) < 0;
|
||||
result = blk_pwrite(s->blk_cur, offset, BDRV_SECTOR_SIZE, dp,
|
||||
0) < 0;
|
||||
}
|
||||
}
|
||||
g_free(dp);
|
||||
@ -370,17 +370,17 @@ static inline int onenand_erase(OneNANDState *s, int sec, int num)
|
||||
for (; num > 0; num--, sec++) {
|
||||
if (s->blk_cur) {
|
||||
int erasesec = s->secs_cur + (sec >> 5);
|
||||
if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS, blankbuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk_cur, sec << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, blankbuf, 0) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pread(s->blk_cur, erasesec << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
memcpy(tmpbuf + ((sec & 31) << 4), blankbuf, 1 << 4);
|
||||
if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS, tmpbuf,
|
||||
BDRV_SECTOR_SIZE, 0) < 0) {
|
||||
if (blk_pwrite(s->blk_cur, erasesec << BDRV_SECTOR_BITS,
|
||||
BDRV_SECTOR_SIZE, tmpbuf, 0) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
|
@ -392,8 +392,8 @@ static void pflash_update(PFlashCFI01 *pfl, int offset,
|
||||
/* widen to sector boundaries */
|
||||
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
|
||||
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
|
||||
ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
|
||||
offset_end - offset, 0);
|
||||
ret = blk_pwrite(pfl->blk, offset, offset_end - offset,
|
||||
pfl->storage + offset, 0);
|
||||
if (ret < 0) {
|
||||
/* TODO set error bit in status */
|
||||
error_report("Could not update PFLASH: %s", strerror(-ret));
|
||||
|
@ -400,8 +400,8 @@ static void pflash_update(PFlashCFI02 *pfl, int offset, int size)
|
||||
/* widen to sector boundaries */
|
||||
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
|
||||
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
|
||||
ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
|
||||
offset_end - offset, 0);
|
||||
ret = blk_pwrite(pfl->blk, offset, offset_end - offset,
|
||||
pfl->storage + offset, 0);
|
||||
if (ret < 0) {
|
||||
/* TODO set error bit in status */
|
||||
error_report("Could not update PFLASH: %s", strerror(-ret));
|
||||
|
@ -98,11 +98,11 @@ cd_read_sector_sync(IDEState *s)
|
||||
switch (s->cd_sector_size) {
|
||||
case 2048:
|
||||
ret = blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS,
|
||||
s->io_buffer, ATAPI_SECTOR_SIZE, 0);
|
||||
ATAPI_SECTOR_SIZE, s->io_buffer, 0);
|
||||
break;
|
||||
case 2352:
|
||||
ret = blk_pread(s->blk, (int64_t)s->lba << ATAPI_SECTOR_BITS,
|
||||
s->io_buffer + 16, ATAPI_SECTOR_SIZE, 0);
|
||||
ATAPI_SECTOR_SIZE, s->io_buffer + 16, 0);
|
||||
if (ret >= 0) {
|
||||
cd_data_to_raw(s->io_buffer, s->lba);
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ static void via1_one_second(void *opaque)
|
||||
static void pram_update(MOS6522Q800VIA1State *v1s)
|
||||
{
|
||||
if (v1s->blk) {
|
||||
if (blk_pwrite(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0) < 0) {
|
||||
if (blk_pwrite(v1s->blk, 0, sizeof(v1s->PRAM), v1s->PRAM, 0) < 0) {
|
||||
qemu_log("pram_update: cannot write to file\n");
|
||||
}
|
||||
}
|
||||
@ -1029,7 +1029,7 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
ret = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0);
|
||||
ret = blk_pread(v1s->blk, 0, sizeof(v1s->PRAM), v1s->PRAM, 0);
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "can't read PRAM contents");
|
||||
return;
|
||||
|
@ -64,8 +64,8 @@ static uint64_t sifive_u_otp_read(void *opaque, hwaddr addr, unsigned int size)
|
||||
if (s->blk) {
|
||||
int32_t buf;
|
||||
|
||||
if (blk_pread(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD, &buf,
|
||||
SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
|
||||
if (blk_pread(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD,
|
||||
SIFIVE_U_OTP_FUSE_WORD, &buf, 0) < 0) {
|
||||
error_report("read error index<%d>", s->pa);
|
||||
return 0xff;
|
||||
}
|
||||
@ -167,8 +167,8 @@ static void sifive_u_otp_write(void *opaque, hwaddr addr,
|
||||
/* write to backend */
|
||||
if (s->blk) {
|
||||
if (blk_pwrite(s->blk, s->pa * SIFIVE_U_OTP_FUSE_WORD,
|
||||
&s->fuse[s->pa], SIFIVE_U_OTP_FUSE_WORD,
|
||||
0) < 0) {
|
||||
SIFIVE_U_OTP_FUSE_WORD, &s->fuse[s->pa], 0)
|
||||
< 0) {
|
||||
error_report("write error index<%d>", s->pa);
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (blk_pread(s->blk, 0, s->fuse, filesize, 0) < 0) {
|
||||
if (blk_pread(s->blk, 0, filesize, s->fuse, 0) < 0) {
|
||||
error_setg(errp, "failed to read the initial flash content");
|
||||
return;
|
||||
}
|
||||
@ -261,14 +261,14 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
|
||||
|
||||
serial_data = s->serial;
|
||||
if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD,
|
||||
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
|
||||
SIFIVE_U_OTP_FUSE_WORD, &serial_data, 0) < 0) {
|
||||
error_setg(errp, "failed to write index<%d>", index);
|
||||
return;
|
||||
}
|
||||
|
||||
serial_data = ~(s->serial);
|
||||
if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD,
|
||||
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
|
||||
SIFIVE_U_OTP_FUSE_WORD, &serial_data, 0) < 0) {
|
||||
error_setg(errp, "failed to write index<%d>", index + 1);
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
|
||||
case I2C_START_RECV:
|
||||
DPRINTK("clear\n");
|
||||
if (ee->blk && ee->changed) {
|
||||
int ret = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
|
||||
int ret = blk_pwrite(ee->blk, 0, ee->rsize, ee->mem, 0);
|
||||
if (ret < 0) {
|
||||
ERR(TYPE_AT24C_EE
|
||||
" : failed to write backing file\n");
|
||||
@ -165,7 +165,7 @@ void at24c_eeprom_reset(DeviceState *state)
|
||||
memset(ee->mem, 0, ee->rsize);
|
||||
|
||||
if (ee->blk) {
|
||||
int ret = blk_pread(ee->blk, 0, ee->mem, ee->rsize, 0);
|
||||
int ret = blk_pread(ee->blk, 0, ee->rsize, ee->mem, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
ERR(TYPE_AT24C_EE
|
||||
|
@ -130,7 +130,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
||||
|
||||
ret = 0;
|
||||
if (nvram->blk) {
|
||||
ret = blk_pwrite(nvram->blk, offset, membuf, len, 0);
|
||||
ret = blk_pwrite(nvram->blk, offset, len, membuf, 0);
|
||||
}
|
||||
|
||||
assert(nvram->buf);
|
||||
@ -179,7 +179,7 @@ static void spapr_nvram_realize(SpaprVioDevice *dev, Error **errp)
|
||||
}
|
||||
|
||||
if (nvram->blk) {
|
||||
ret = blk_pread(nvram->blk, 0, nvram->buf, nvram->size, 0);
|
||||
ret = blk_pread(nvram->blk, 0, nvram->size, nvram->buf, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
error_setg(errp, "can't read spapr-nvram contents");
|
||||
@ -224,7 +224,7 @@ static void postload_update_cb(void *opaque, bool running, RunState state)
|
||||
qemu_del_vm_change_state_handler(nvram->vmstate);
|
||||
nvram->vmstate = NULL;
|
||||
|
||||
blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0);
|
||||
blk_pwrite(nvram->blk, 0, nvram->size, nvram->buf, 0);
|
||||
}
|
||||
|
||||
static int spapr_nvram_post_load(void *opaque, int version_id)
|
||||
|
@ -124,7 +124,7 @@ static void bbram_bdrv_read(XlnxBBRam *s, Error **errp)
|
||||
blk_name(s->blk));
|
||||
}
|
||||
|
||||
if (blk_pread(s->blk, 0, ram, nr, 0) < 0) {
|
||||
if (blk_pread(s->blk, 0, nr, ram, 0) < 0) {
|
||||
error_setg(errp,
|
||||
"%s: Failed to read %u bytes from BBRAM backstore.",
|
||||
blk_name(s->blk), nr);
|
||||
@ -159,7 +159,7 @@ static void bbram_bdrv_sync(XlnxBBRam *s, uint64_t hwaddr)
|
||||
}
|
||||
|
||||
offset = hwaddr - A_BBRAM_0;
|
||||
rc = blk_pwrite(s->blk, offset, &le32, 4, 0);
|
||||
rc = blk_pwrite(s->blk, offset, 4, &le32, 0);
|
||||
if (rc < 0) {
|
||||
bbram_bdrv_error(s, rc, g_strdup_printf("write to offset %u", offset));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ static int efuse_bdrv_read(XlnxEFuse *s, Error **errp)
|
||||
blk_name(s->blk));
|
||||
}
|
||||
|
||||
if (blk_pread(s->blk, 0, ram, nr, 0) < 0) {
|
||||
if (blk_pread(s->blk, 0, nr, ram, 0) < 0) {
|
||||
error_setg(errp, "%s: Failed to read %u bytes from eFUSE backstore.",
|
||||
blk_name(s->blk), nr);
|
||||
return -1;
|
||||
@ -105,7 +105,7 @@ static void efuse_bdrv_sync(XlnxEFuse *s, unsigned int bit)
|
||||
le32 = cpu_to_le32(xlnx_efuse_get_row(s, bit));
|
||||
|
||||
row_offset = (bit / 32) * 4;
|
||||
if (blk_pwrite(s->blk, row_offset, &le32, 4, 0) < 0) {
|
||||
if (blk_pwrite(s->blk, row_offset, 4, &le32, 0) < 0) {
|
||||
error_report("%s: Failed to write offset %u of eFUSE backstore.",
|
||||
blk_name(s->blk), row_offset);
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int size)
|
||||
offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
|
||||
offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
|
||||
|
||||
ret = blk_pwrite(s->blk, offset, s->storage + offset,
|
||||
offset_end - offset, 0);
|
||||
ret = blk_pwrite(s->blk, offset, offset_end - offset, s->storage + offset,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
error_report("Could not update PNOR offset=0x%" PRIx32" : %s", offset,
|
||||
strerror(-ret));
|
||||
@ -99,7 +99,7 @@ static void pnv_pnor_realize(DeviceState *dev, Error **errp)
|
||||
|
||||
s->storage = blk_blockalign(s->blk, s->size);
|
||||
|
||||
if (blk_pread(s->blk, 0, s->storage, s->size, 0) < 0) {
|
||||
if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) {
|
||||
error_setg(errp, "failed to read the initial flash content");
|
||||
return;
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)
|
||||
static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)
|
||||
{
|
||||
trace_sdcard_read_block(addr, len);
|
||||
if (!sd->blk || blk_pread(sd->blk, addr, sd->data, len, 0) < 0) {
|
||||
if (!sd->blk || blk_pread(sd->blk, addr, len, sd->data, 0) < 0) {
|
||||
fprintf(stderr, "sd_blk_read: read error on host side\n");
|
||||
}
|
||||
}
|
||||
@ -760,7 +760,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)
|
||||
static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)
|
||||
{
|
||||
trace_sdcard_write_block(addr, len);
|
||||
if (!sd->blk || blk_pwrite(sd->blk, addr, sd->data, len, 0) < 0) {
|
||||
if (!sd->blk || blk_pwrite(sd->blk, addr, len, sd->data, 0) < 0) {
|
||||
fprintf(stderr, "sd_blk_write: write error on host side\n");
|
||||
}
|
||||
}
|
||||
|
@ -101,9 +101,9 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
|
||||
* the "I/O or GS" API.
|
||||
*/
|
||||
|
||||
int blk_pread(BlockBackend *blk, int64_t offset, void *buf, int bytes,
|
||||
int blk_pread(BlockBackend *blk, int64_t offset, int bytes, void *buf,
|
||||
BdrvRequestFlags flags);
|
||||
int blk_pwrite(BlockBackend *blk, int64_t offset, const void *buf, int bytes,
|
||||
int blk_pwrite(BlockBackend *blk, int64_t offset, int bytes, const void *buf,
|
||||
BdrvRequestFlags flags);
|
||||
int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
|
@ -569,7 +569,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
|
||||
blk_mig_unlock();
|
||||
} else {
|
||||
ret = blk_pread(bmds->blk, sector * BDRV_SECTOR_SIZE,
|
||||
blk->buf, nr_sectors * BDRV_SECTOR_SIZE, 0);
|
||||
nr_sectors * BDRV_SECTOR_SIZE, blk->buf, 0);
|
||||
if (ret < 0) {
|
||||
goto error;
|
||||
}
|
||||
@ -976,8 +976,8 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
|
||||
cluster_size,
|
||||
BDRV_REQ_MAY_UNMAP);
|
||||
} else {
|
||||
ret = blk_pwrite(blk, cur_addr, cur_buf,
|
||||
cluster_size, 0);
|
||||
ret = blk_pwrite(blk, cur_addr, cluster_size, cur_buf,
|
||||
0);
|
||||
}
|
||||
if (ret < 0) {
|
||||
break;
|
||||
|
@ -2039,8 +2039,8 @@ static int coroutine_fn nbd_co_send_sparse_read(NBDClient *client,
|
||||
stl_be_p(&chunk.length, pnum);
|
||||
ret = nbd_co_send_iov(client, iov, 1, errp);
|
||||
} else {
|
||||
ret = blk_pread(exp->common.blk, offset + progress,
|
||||
data + progress, pnum, 0);
|
||||
ret = blk_pread(exp->common.blk, offset + progress, pnum,
|
||||
data + progress, 0);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "reading from file failed");
|
||||
break;
|
||||
@ -2444,7 +2444,7 @@ static coroutine_fn int nbd_do_cmd_read(NBDClient *client, NBDRequest *request,
|
||||
data, request->len, errp);
|
||||
}
|
||||
|
||||
ret = blk_pread(exp->common.blk, request->from, data, request->len, 0);
|
||||
ret = blk_pread(exp->common.blk, request->from, request->len, data, 0);
|
||||
if (ret < 0) {
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
"reading from file failed", errp);
|
||||
@ -2511,7 +2511,7 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
|
||||
if (request->flags & NBD_CMD_FLAG_FUA) {
|
||||
flags |= BDRV_REQ_FUA;
|
||||
}
|
||||
ret = blk_pwrite(exp->common.blk, request->from, data, request->len,
|
||||
ret = blk_pwrite(exp->common.blk, request->from, request->len, data,
|
||||
flags);
|
||||
return nbd_send_generic_reply(client, request->handle, ret,
|
||||
"writing to file failed", errp);
|
||||
|
18
qemu-img.c
18
qemu-img.c
@ -1309,7 +1309,7 @@ static int check_empty_sectors(BlockBackend *blk, int64_t offset,
|
||||
int ret = 0;
|
||||
int64_t idx;
|
||||
|
||||
ret = blk_pread(blk, offset, buffer, bytes, 0);
|
||||
ret = blk_pread(blk, offset, bytes, buffer, 0);
|
||||
if (ret < 0) {
|
||||
error_report("Error while reading offset %" PRId64 " of %s: %s",
|
||||
offset, filename, strerror(-ret));
|
||||
@ -1526,7 +1526,7 @@ static int img_compare(int argc, char **argv)
|
||||
int64_t pnum;
|
||||
|
||||
chunk = MIN(chunk, IO_BUF_SIZE);
|
||||
ret = blk_pread(blk1, offset, buf1, chunk, 0);
|
||||
ret = blk_pread(blk1, offset, chunk, buf1, 0);
|
||||
if (ret < 0) {
|
||||
error_report("Error while reading offset %" PRId64
|
||||
" of %s: %s",
|
||||
@ -1534,7 +1534,7 @@ static int img_compare(int argc, char **argv)
|
||||
ret = 4;
|
||||
goto out;
|
||||
}
|
||||
ret = blk_pread(blk2, offset, buf2, chunk, 0);
|
||||
ret = blk_pread(blk2, offset, chunk, buf2, 0);
|
||||
if (ret < 0) {
|
||||
error_report("Error while reading offset %" PRId64
|
||||
" of %s: %s",
|
||||
@ -3779,7 +3779,7 @@ static int img_rebase(int argc, char **argv)
|
||||
n = old_backing_size - offset;
|
||||
}
|
||||
|
||||
ret = blk_pread(blk_old_backing, offset, buf_old, n, 0);
|
||||
ret = blk_pread(blk_old_backing, offset, n, buf_old, 0);
|
||||
if (ret < 0) {
|
||||
error_report("error while reading from old backing file");
|
||||
goto out;
|
||||
@ -3793,7 +3793,7 @@ static int img_rebase(int argc, char **argv)
|
||||
n = new_backing_size - offset;
|
||||
}
|
||||
|
||||
ret = blk_pread(blk_new_backing, offset, buf_new, n, 0);
|
||||
ret = blk_pread(blk_new_backing, offset, n, buf_new, 0);
|
||||
if (ret < 0) {
|
||||
error_report("error while reading from new backing file");
|
||||
goto out;
|
||||
@ -3812,8 +3812,8 @@ static int img_rebase(int argc, char **argv)
|
||||
if (buf_old_is_zero) {
|
||||
ret = blk_pwrite_zeroes(blk, offset + written, pnum, 0);
|
||||
} else {
|
||||
ret = blk_pwrite(blk, offset + |