mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
migration: add qemu_get_fd
Reviewed-by: Orit Wasserman <owasserm@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9229bf3c2d
commit
70eb633034
3 changed files with 41 additions and 0 deletions
27
savevm.c
27
savevm.c
|
@ -188,6 +188,13 @@ typedef struct QEMUFileSocket
|
|||
QEMUFile *file;
|
||||
} QEMUFileSocket;
|
||||
|
||||
static int socket_get_fd(void *opaque)
|
||||
{
|
||||
QEMUFileSocket *s = opaque;
|
||||
|
||||
return s->fd;
|
||||
}
|
||||
|
||||
static int socket_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
|
||||
{
|
||||
QEMUFileSocket *s = opaque;
|
||||
|
@ -210,6 +217,13 @@ static int socket_close(void *opaque)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int stdio_get_fd(void *opaque)
|
||||
{
|
||||
QEMUFileStdio *s = opaque;
|
||||
|
||||
return fileno(s->stdio_file);
|
||||
}
|
||||
|
||||
static int stdio_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int size)
|
||||
{
|
||||
QEMUFileStdio *s = opaque;
|
||||
|
@ -253,11 +267,13 @@ static int stdio_fclose(void *opaque)
|
|||
}
|
||||
|
||||
static const QEMUFileOps stdio_pipe_read_ops = {
|
||||
.get_fd = stdio_get_fd,
|
||||
.get_buffer = stdio_get_buffer,
|
||||
.close = stdio_pclose
|
||||
};
|
||||
|
||||
static const QEMUFileOps stdio_pipe_write_ops = {
|
||||
.get_fd = stdio_get_fd,
|
||||
.put_buffer = stdio_put_buffer,
|
||||
.close = stdio_pclose
|
||||
};
|
||||
|
@ -307,11 +323,13 @@ int qemu_stdio_fd(QEMUFile *f)
|
|||
}
|
||||
|
||||
static const QEMUFileOps stdio_file_read_ops = {
|
||||
.get_fd = stdio_get_fd,
|
||||
.get_buffer = stdio_get_buffer,
|
||||
.close = stdio_fclose
|
||||
};
|
||||
|
||||
static const QEMUFileOps stdio_file_write_ops = {
|
||||
.get_fd = stdio_get_fd,
|
||||
.put_buffer = stdio_put_buffer,
|
||||
.close = stdio_fclose
|
||||
};
|
||||
|
@ -345,6 +363,7 @@ fail:
|
|||
}
|
||||
|
||||
static const QEMUFileOps socket_read_ops = {
|
||||
.get_fd = socket_get_fd,
|
||||
.get_buffer = socket_get_buffer,
|
||||
.close = socket_close
|
||||
};
|
||||
|
@ -492,6 +511,14 @@ static void qemu_fill_buffer(QEMUFile *f)
|
|||
qemu_file_set_error(f, len);
|
||||
}
|
||||
|
||||
int qemu_get_fd(QEMUFile *f)
|
||||
{
|
||||
if (f->ops->get_fd) {
|
||||
return f->ops->get_fd(f->opaque);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Closes the file
|
||||
*
|
||||
* Returns negative error value if any error happened on previous operations or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue