Fixes around qemu_vfree()
v2 cover Fixes around qemu_vfree()
v2: Fix silly mistake in 4/4; the other three patches are unchanged
Markus Armbruster (4):
w32: Make qemu_vfree() accept NULL like the POSIX implementation
scsi-disk: qemu_vfree(NULL) is fine, simplify
win32-aio: Fix how win32_aio_process_completion() frees buffer
block: Fix how mirror_run() frees its buffer
block/mirror.c | 2 +- block/win32-aio.c | 2 +- hw/scsi-disk.c | 4 +--- util/oslib-win32.c | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.11.7
PATCH v2 3/4 win32-aio: Fix how win32_aio_process_completion() frees buffer
win32_aio_submit() allocates it with qemu_blockalign(), therefore it must be freed with qemu_vfree(), not g_free().
--- block/win32-aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/win32-aio.c +1 -1
@@ -87,7 +87,7 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,memcpy (p, qiov->iov[i].iov_base, qiov->iov[i].iov_len); p += qiov->iov[i].iov_len; } -g_free (waiocb->buf); +qemu_vfree (waiocb->buf); } }
Signature · 1 line
1.7.11.7
PATCH v2 4/4 block: Fix how mirror_run() frees its buffer
In reply to Markus ArmbrusterIt allocates with qemu_blockalign(), therefore it must free with qemu_vfree(), not g_free().
--- block/mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/mirror.c +1 -1
@@ -225,7 +225,7 @@ static void coroutine_fn mirror_run(void *opaque) } immediate_exit: -g_free (s->buf); +qemu_vfree (s->buf);bdrv_set_dirty_tracking (bs, false);bdrv_iostatus_disable (s->target);if (s->should_complete && ret ==0 ) {
Signature · 1 line
1.7.11.7
PATCH v2 2/4 scsi-disk: qemu_vfree(NULL) is fine, simplify
In reply to Markus Armbruster--- hw/scsi-disk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/scsi-disk.c +1 -3
@@ -85,9 +85,7 @@ static void scsi_free_request(SCSIRequest *req) {SCSIDiskReq *r =DO_UPCAST (SCSIDiskReq, req, req); -if (r->iov.iov_base) { -qemu_vfree (r->iov.iov_base); - } +qemu_vfree (r->iov.iov_base); }/* Helper function for command completion with sense. */
Signature · 1 line
1.7.11.7
PATCH v2 1/4 w32: Make qemu_vfree() accept NULL like the POSIX implementation
In reply to Markus ArmbrusterOn POSIX, qemu_vfree() accepts NULL, because it's merely wrapper around free(). As far as I can tell, the Windows implementation doesn't. Breeds bugs that bite only under Windows.
Make the Windows implementation behave like the POSIX implementation.
--- util/oslib-win32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
util/oslib-win32.c +3 -1
@@ -71,7 +71,9 @@ void *qemu_vmalloc(size_t size)void qemu_vfree (void *ptr) {trace_qemu_vfree (ptr); -VirtualFree (ptr,0 ,MEM_RELEASE ); +if (ptr) { +VirtualFree (ptr,0 ,MEM_RELEASE ); + } }/* FIXME: add proper locking */
Signature · 1 line
1.7.11.7
Am 15.01.2013 15:29, schrieb Markus Armbruster:
Quoted 8 lines
v2: Fix silly mistake in 4/4; the other three patches are unchanged
Markus Armbruster (4):
w32: Makeqemu_vfree()accept NULL like the POSIX implementation
scsi-disk:qemu_vfree(NULL)is fine, simplify
win32-aio: Fix howwin32_aio_process_completion()frees buffer
block: Fix howmirror_run()frees its buffer
Quoted 5 lines
block/mirror.c | 2 +- block/win32-aio.c | 2 +- hw/scsi-disk.c | 4 +--- util/oslib-win32.c | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-)
Stefan Hajnoczi
AppliedQuoted 9 lines · Kevin Wolf
Am 15.01.2013 15:29, schrieb Markus Armbruster:
Quoted 8 lines
v2: Fix silly mistake in 4/4; the other three patches are unchanged
Markus Armbruster (4):
w32: Makeqemu_vfree()accept NULL like the POSIX implementation
scsi-disk:qemu_vfree(NULL)is fine, simplify
win32-aio: Fix howwin32_aio_process_completion()frees buffer
block: Fix howmirror_run()frees its buffer
Quoted 7 lines
Quoted 5 lines
block/mirror.c | 2 +- block/win32-aio.c | 2 +- hw/scsi-disk.c | 4 +--- util/oslib-win32.c | 4 +++- 4 files changed, 6 insertions(+), 6 deletions(-)Reviewed-by Kevin Wolf <[email protected]>
Thanks, applied Patch 4 to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan