mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
qemu-img: use buffer-based io
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
f4326aefcf
commit
265a7e54ef
13
qemu-img.c
13
qemu-img.c
@ -1680,7 +1680,6 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num,
|
|||||||
int nb_sectors, uint8_t *buf)
|
int nb_sectors, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int n, ret;
|
int n, ret;
|
||||||
QEMUIOVector qiov;
|
|
||||||
|
|
||||||
assert(nb_sectors <= s->buf_sectors);
|
assert(nb_sectors <= s->buf_sectors);
|
||||||
while (nb_sectors > 0) {
|
while (nb_sectors > 0) {
|
||||||
@ -1696,11 +1695,10 @@ static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector_num,
|
|||||||
bs_sectors = s->src_sectors[src_cur];
|
bs_sectors = s->src_sectors[src_cur];
|
||||||
|
|
||||||
n = MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset));
|
n = MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset));
|
||||||
qemu_iovec_init_buf(&qiov, buf, n << BDRV_SECTOR_BITS);
|
|
||||||
|
|
||||||
ret = blk_co_preadv(
|
ret = blk_co_pread(
|
||||||
blk, (sector_num - src_cur_offset) << BDRV_SECTOR_BITS,
|
blk, (sector_num - src_cur_offset) << BDRV_SECTOR_BITS,
|
||||||
n << BDRV_SECTOR_BITS, &qiov, 0);
|
n << BDRV_SECTOR_BITS, buf, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1719,7 +1717,6 @@ static int coroutine_fn convert_co_write(ImgConvertState *s, int64_t sector_num,
|
|||||||
enum ImgConvertBlockStatus status)
|
enum ImgConvertBlockStatus status)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
QEMUIOVector qiov;
|
|
||||||
|
|
||||||
while (nb_sectors > 0) {
|
while (nb_sectors > 0) {
|
||||||
int n = nb_sectors;
|
int n = nb_sectors;
|
||||||
@ -1747,10 +1744,8 @@ static int coroutine_fn convert_co_write(ImgConvertState *s, int64_t sector_num,
|
|||||||
(s->compressed &&
|
(s->compressed &&
|
||||||
!buffer_is_zero(buf, n * BDRV_SECTOR_SIZE)))
|
!buffer_is_zero(buf, n * BDRV_SECTOR_SIZE)))
|
||||||
{
|
{
|
||||||
qemu_iovec_init_buf(&qiov, buf, n << BDRV_SECTOR_BITS);
|
ret = blk_co_pwrite(s->target, sector_num << BDRV_SECTOR_BITS,
|
||||||
|
n << BDRV_SECTOR_BITS, buf, flags);
|
||||||
ret = blk_co_pwritev(s->target, sector_num << BDRV_SECTOR_BITS,
|
|
||||||
n << BDRV_SECTOR_BITS, &qiov, flags);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user