mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent
qemu_iovec_concat() is currently a wrapper for qemu_iovec_copy(), use the former (with extra "0" arg) in a few places where it is used. Change skip argument of qemu_iovec_copy() from uint64_t to size_t, since size of qiov itself is size_t, so there's no way to skip larger sizes. Rename it to soffset, to make it clear that the offset is applied to src. Also change the only usage of uint64_t in hw/9pfs/virtio-9p.c, in v9fs_init_qiov_from_pdu() - all callers of it actually uses size_t too, not uint64_t. One added restriction: as for all other iovec-related functions, soffset must point inside src. Order of argumens is already good: qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int c, size_t bytes) vs: qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes) (note soffset is after _src_ not dst, since it applies to src; for memset it applies to qiov). Note that in many places where this function is used, the previous call is qemu_iovec_reset(), which means many callers actually want copy (replacing dst content), not concat. So we may want to add a wrapper like qemu_iovec_copy() with the same arguments but which calls qemu_iovec_reset() before _concat(). Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
03396148bc
commit
1b093c480a
6 changed files with 33 additions and 48 deletions
|
@ -1648,7 +1648,7 @@ out:
|
|||
* with qemu_iovec_destroy().
|
||||
*/
|
||||
static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
|
||||
uint64_t skip, size_t size,
|
||||
size_t skip, size_t size,
|
||||
bool is_write)
|
||||
{
|
||||
QEMUIOVector elem;
|
||||
|
@ -1665,7 +1665,7 @@ static void v9fs_init_qiov_from_pdu(QEMUIOVector *qiov, V9fsPDU *pdu,
|
|||
|
||||
qemu_iovec_init_external(&elem, iov, niov);
|
||||
qemu_iovec_init(qiov, niov);
|
||||
qemu_iovec_copy(qiov, &elem, skip, size);
|
||||
qemu_iovec_concat(qiov, &elem, skip, size);
|
||||
}
|
||||
|
||||
static void v9fs_read(void *opaque)
|
||||
|
@ -1715,7 +1715,7 @@ static void v9fs_read(void *opaque)
|
|||
qemu_iovec_init(&qiov, qiov_full.niov);
|
||||
do {
|
||||
qemu_iovec_reset(&qiov);
|
||||
qemu_iovec_copy(&qiov, &qiov_full, count, qiov_full.size - count);
|
||||
qemu_iovec_concat(&qiov, &qiov_full, count, qiov_full.size - count);
|
||||
if (0) {
|
||||
print_sg(qiov.iov, qiov.niov);
|
||||
}
|
||||
|
@ -1970,7 +1970,7 @@ static void v9fs_write(void *opaque)
|
|||
qemu_iovec_init(&qiov, qiov_full.niov);
|
||||
do {
|
||||
qemu_iovec_reset(&qiov);
|
||||
qemu_iovec_copy(&qiov, &qiov_full, total, qiov_full.size - total);
|
||||
qemu_iovec_concat(&qiov, &qiov_full, total, qiov_full.size - total);
|
||||
if (0) {
|
||||
print_sg(qiov.iov, qiov.niov);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue