On 01.10.18 17:43, Vladimir Sementsov-Ogievskiy wrote: > 28.09.2018 17:23, Max Reitz wrote: >> On 07.08.18 19:43, Vladimir Sementsov-Ogievskiy wrote: >>> Split out block which will be reused in async scheme. >>> >>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> >>> --- >>> block/qcow2.c | 138 >>> ++++++++++++++++++++++++++++++++++++---------------------- >>> 1 file changed, 86 insertions(+), 52 deletions(-) >>> >>> diff --git a/block/qcow2.c b/block/qcow2.c >>> index a0df8d4e50..4d669432d1 100644 >>> --- a/block/qcow2.c >>> +++ b/block/qcow2.c >>> @@ -2210,6 +2210,85 @@ static bool merge_cow(uint64_t offset, >>> unsigned bytes, >>> return false; >>> } >>> +/* qcow2_co_do_pwritev >>> + * Called without s->lock unlocked >>> + * hd_qiov - temp qiov for any use. It is initialized so it is empty >>> and >>> + * support adding up to qiov->niov + 2 elements >>> + * l2meta - if not NULL, qcow2_co_do_pwritev() will consume it. >>> Caller must not >>> + * use it somehow after qcow2_co_do_pwritev() call >>> + */ >>> +static coroutine_fn int qcow2_co_do_pwritev(BlockDriverState *bs, >>> + uint64_t >>> file_cluster_offset, >>> + uint64_t offset, >>> + uint64_t bytes, >>> + QEMUIOVector *qiov, >>> + uint64_t qiov_offset, >>> + QCowL2Meta *l2meta) >>> +{ >>> + int ret; >>> + BDRVQcow2State *s = bs->opaque; >>> + void *crypt_buf = NULL; >>> + QEMUIOVector hd_qiov; >>> + int offset_in_cluster = offset_into_cluster(s, offset); >>> + >>> + qemu_iovec_reset(&hd_qiov); >> This shouldn't be here. >> >>> + qemu_iovec_init(&hd_qiov, qiov->niov); >>> + >>> + if (bs->encrypted) { >>> + assert(s->crypto); >>> + assert(bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); >>> + crypt_buf = qemu_try_blockalign(bs->file->bs, bytes); >>> + qemu_iovec_to_buf(qiov, qiov_offset, crypt_buf, bytes); >>> + >>> + if (qcrypto_block_encrypt(s->crypto, >>> + (s->crypt_physical_offset ? >>> + file_cluster_offset + >>> offset_in_cluster : >>> + offset), >>> + crypt_buf, >>> + bytes, NULL) < 0) { >> Same question as in the read case: Can't we make do without the bounce >> buffer? > > I think, we should not modify guest buffers..
Hmm, yes, agreed. O:-) Max
signature.asc
Description: OpenPGP digital signature