[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/9] migration: unify stdio-based QEMUFile operation
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 1/9] migration: unify stdio-based QEMUFile operations |
Date: |
Fri, 21 Sep 2012 19:04:58 +0200 |
Now that qemu_fseek does not exist anymore, there is no reason to do
an fseek before fread/fwrite when operating on an stdio file.
Thus, unify the get/put_buffer callbacks used by qemu_fopen
with those used for pipes.
Signed-off-by: Paolo Bonzini <address@hidden>
---
savevm.c | 19 ++-----------------
1 file modificato, 2 inserzioni(+), 17 rimozioni(-)
diff --git a/savevm.c b/savevm.c
index 2ea1fa6..5cd4432 100644
--- a/savevm.c
+++ b/savevm.c
@@ -342,21 +342,6 @@ QEMUFile *qemu_fopen_socket(int fd)
return s->file;
}
-static int file_put_buffer(void *opaque, const uint8_t *buf,
- int64_t pos, int size)
-{
- QEMUFileStdio *s = opaque;
- fseek(s->stdio_file, pos, SEEK_SET);
- return fwrite(buf, 1, size, s->stdio_file);
-}
-
-static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
-{
- QEMUFileStdio *s = opaque;
- fseek(s->stdio_file, pos, SEEK_SET);
- return fread(buf, 1, size, s->stdio_file);
-}
-
QEMUFile *qemu_fopen(const char *filename, const char *mode)
{
QEMUFileStdio *s;
@@ -375,10 +360,10 @@ QEMUFile *qemu_fopen(const char *filename, const char
*mode)
goto fail;
if(mode[0] == 'w') {
- s->file = qemu_fopen_ops(s, file_put_buffer, NULL, stdio_fclose,
+ s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose,
NULL, NULL, NULL);
} else {
- s->file = qemu_fopen_ops(s, NULL, file_get_buffer, stdio_fclose,
+ s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose,
NULL, NULL, NULL);
}
return s->file;
--
1.7.12
- [Qemu-devel] [PATCH 0/9] Incoming migration coroutine, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 1/9] migration: unify stdio-based QEMUFile operations,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 3/9] migration: add qemu_get_fd, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 2/9] migration: consolidate QEMUFile methods in a single QEMUFileOps struct, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 4/9] migration: replace qemu_stdio_fd with qemu_get_fd, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 5/9] migration: clean up server sockets and handlers before invoking process_incoming_migration, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 6/9] migration: close socket QEMUFile from socket_close, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 7/9] migration: move qemu_fclose to process_incoming_migration, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 8/9] migration: handle EAGAIN while reading QEMUFile, Paolo Bonzini, 2012/09/21
- [Qemu-devel] [PATCH 9/9] migration: move process_incoming_migration to a coroutine, Paolo Bonzini, 2012/09/21