diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2009-08-18 15:56:25 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-08-27 19:33:15 -0500 |
commit | 5ac1fad324d869ab6971256aa56188ebac784e46 (patch) | |
tree | d1bcd758198eb80441a7cedaa5602fffa4d229a5 /savevm.c | |
parent | dfffc65398e102bb01535d15b0e017fc73cbcf80 (diff) | |
download | qemu-5ac1fad324d869ab6971256aa56188ebac784e46.zip qemu-5ac1fad324d869ab6971256aa56188ebac784e46.tar.gz qemu-5ac1fad324d869ab6971256aa56188ebac784e46.tar.bz2 |
add file descriptor migration
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'savevm.c')
-rw-r--r-- | savevm.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -285,6 +285,34 @@ int qemu_stdio_fd(QEMUFile *f) return fd; } +QEMUFile *qemu_fdopen(int fd, const char *mode) +{ + QEMUFileStdio *s; + + if (mode == NULL || + (mode[0] != 'r' && mode[0] != 'w') || + mode[1] != 'b' || mode[2] != 0) { + fprintf(stderr, "qemu_fdopen: Argument validity check failed\n"); + return NULL; + } + + s = qemu_mallocz(sizeof(QEMUFileStdio)); + s->stdio_file = fdopen(fd, mode); + if (!s->stdio_file) + goto fail; + + if(mode[0] == 'r') { + s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose, NULL, NULL); + } else { + s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose, NULL, NULL); + } + return s->file; + +fail: + qemu_free(s); + return NULL; +} + QEMUFile *qemu_fopen_socket(int fd) { QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket)); |