On 2/7/19 4:24 AM, Vladimir Sementsov-Ogievskiy wrote: > Use new qemu_iovec_init_buf() instead of > qemu_iovec_init_external( ... , 1), which simplifies the code. > > While being here, use qemu_try_blockalign0 as well. > > Signed-off-by: Vladimir Sementsov-Ogievskiy > --- > block/io.c | 89 ++++++++++++------------------------------------------ > 1 file changed, 20 insertions(+), 69 deletions(-) > > @@ -1477,7 +1456,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, > { > BlockDriver *drv = bs->drv; > QEMUIOVector qiov; > - struct iovec iov = {0}; > + void *buf = NULL; > int ret = 0; > bool need_flush = false; > int head = 0; > @@ -1547,16 +1526,14 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, > need_flush = true; > } > num = MIN(num, max_transfer); > - iov.iov_len = num; > - if (iov.iov_base == NULL) { > - iov.iov_base = qemu_try_blockalign(bs, num); > - if (iov.iov_base == NULL) { > + if (buf == NULL) { > + buf = qemu_try_blockalign0(bs, num); > + if (buf == NULL) { > ret = -ENOMEM; > goto fail; > } > - memset(iov.iov_base, 0, num); > } > - qemu_iovec_init_external(&qiov, &iov, 1); > + qemu_iovec_init_buf(&qiov, buf, num); The use of qemu_try_blockalign0() is new to this revision, but fits in well enough that I don't think you need to split the patch. Reviewed-by: Eric Blake -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org