diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-09-21 12:04:03 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-11-02 18:34:59 +0100 |
commit | 5f0ebf1b4d58be0c0bb05beb195b6f42942eeee8 (patch) | |
tree | 7c5d4f98d91c04e7832ea62d49d62076c36f5d70 /savevm.c | |
parent | 4ba79505f43bd0ace35c3fe42197eb02e7e0478e (diff) |
migration: unify stdio-based QEMUFile operations
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.
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 19 |
1 files changed, 2 insertions, 17 deletions
@@ -343,21 +343,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; @@ -376,10 +361,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; |