From: Orit Wasserman <owasserm@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 03/12] migration: add qemu_get_fd
Date: Sun, 28 Oct 2012 13:27:54 +0200 [thread overview]
Message-ID: <508D16BA.2040101@redhat.com> (raw)
In-Reply-To: <1350555758-29988-4-git-send-email-pbonzini@redhat.com>
On 10/18/2012 12:22 PM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> buffered_file.c | 8 ++++++++
> qemu-file.h | 6 ++++++
> savevm.c | 27 +++++++++++++++++++++++++++
> 3 file modificati, 41 inserzioni(+)
>
> diff --git a/buffered_file.c b/buffered_file.c
> index a5c0b12..bd0f61d 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -174,6 +174,13 @@ static int buffered_close(void *opaque)
> * 1: Time to stop
> * negative: There has been an error
> */
> +static int buffered_get_fd(void *opaque)
> +{
> + QEMUFileBuffered *s = opaque;
> +
> + return qemu_get_fd(s->file);
> +}
> +
> static int buffered_rate_limit(void *opaque)
> {
> QEMUFileBuffered *s = opaque;
> @@ -235,6 +242,7 @@ static void buffered_rate_tick(void *opaque)
> }
>
> static const QEMUFileOps buffered_file_ops = {
> + .get_fd = buffered_get_fd,
> .put_buffer = buffered_put_buffer,
> .close = buffered_close,
> .rate_limit = buffered_rate_limit,
> diff --git a/qemu-file.h b/qemu-file.h
> index c89e8e0..d552f5d 100644
> --- a/qemu-file.h
> +++ b/qemu-file.h
> @@ -47,6 +47,10 @@ typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf,
> */
> typedef int (QEMUFileCloseFunc)(void *opaque);
>
> +/* Called to return the OS file descriptor associated to the QEMUFile.
> + */
> +typedef int (QEMUFileGetFD)(void *opaque);
> +
> /* Called to determine if the file has exceeded its bandwidth allocation. The
> * bandwidth capping is a soft limit, not a hard limit.
> */
> @@ -63,6 +67,7 @@ typedef struct QEMUFileOps {
> QEMUFilePutBufferFunc *put_buffer;
> QEMUFileGetBufferFunc *get_buffer;
> QEMUFileCloseFunc *close;
> + QEMUFileGetFD *get_fd;
> QEMUFileRateLimit *rate_limit;
> QEMUFileSetRateLimit *set_rate_limit;
> QEMUFileGetRateLimit *get_rate_limit;
> @@ -74,6 +79,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode);
> QEMUFile *qemu_fopen_socket(int fd);
> QEMUFile *qemu_popen(FILE *popen_file, const char *mode);
> QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
> +int qemu_get_fd(QEMUFile *f);
> int qemu_stdio_fd(QEMUFile *f);
> int qemu_fclose(QEMUFile *f);
> void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
> diff --git a/savevm.c b/savevm.c
> index c3ce00a..5c0a756 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -187,6 +187,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;
> @@ -209,6 +216,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;
> @@ -252,11 +266,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
> };
> @@ -306,11 +322,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
> };
> @@ -344,6 +362,7 @@ fail:
> }
>
> static const QEMUFileOps socket_read_ops = {
> + .get_fd = socket_get_fd,
> .get_buffer = socket_get_buffer,
> .close = socket_close
> };
> @@ -491,6 +510,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
>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
next prev parent reply other threads:[~2012-10-28 9:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 10:22 [Qemu-devel] [PATCH 0/9] Incoming migration coroutine Paolo Bonzini
2012-10-18 10:22 ` [Qemu-devel] [PATCH 01/12] migration: unify stdio-based QEMUFile operations Paolo Bonzini
2012-10-28 11:20 ` Orit Wasserman
2012-10-30 12:19 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 02/12] migration: consolidate QEMUFile methods in a single QEMUFileOps struct Paolo Bonzini
2012-10-28 11:24 ` Orit Wasserman
2012-10-30 12:26 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 03/12] migration: add qemu_get_fd Paolo Bonzini
2012-10-28 11:27 ` Orit Wasserman [this message]
2012-10-30 12:27 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 04/12] migration: replace qemu_stdio_fd with qemu_get_fd Paolo Bonzini
2012-10-28 9:29 ` Orit Wasserman
2012-10-30 12:28 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 05/12] migration: clean up server sockets and handlers before invoking process_incoming_migration Paolo Bonzini
2012-10-28 9:35 ` Orit Wasserman
2012-10-30 12:29 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd_cleanup Paolo Bonzini
2012-10-28 9:47 ` Orit Wasserman
2012-10-28 15:05 ` Paolo Bonzini
2012-10-18 10:22 ` [Qemu-devel] [PATCH 07/12] migration: use closesocket, not close Paolo Bonzini
2012-10-28 9:49 ` Orit Wasserman
2012-10-30 12:32 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 08/12] migration: xxx_close will only be called once Paolo Bonzini
2012-10-28 9:53 ` Orit Wasserman
2012-10-30 12:35 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 09/12] migration: close socket QEMUFile from socket_close Paolo Bonzini
2012-10-28 9:55 ` Orit Wasserman
2012-10-30 12:40 ` Juan Quintela
2012-10-18 10:22 ` [Qemu-devel] [PATCH 10/12] migration: move qemu_fclose to process_incoming_migration Paolo Bonzini
2012-10-28 9:56 ` Orit Wasserman
2012-10-18 10:22 ` [Qemu-devel] [PATCH 11/12] migration: handle EAGAIN while reading QEMUFile Paolo Bonzini
2012-10-28 10:01 ` Orit Wasserman
2012-10-18 10:22 ` [Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine Paolo Bonzini
2012-10-28 10:07 ` Orit Wasserman
-- strict thread matches above, loose matches on Subject: below --
2012-11-02 17:50 [Qemu-devel] [PULL 00/12] Incoming migration coroutine Paolo Bonzini
2012-11-02 17:50 ` [Qemu-devel] [PATCH 03/12] migration: add qemu_get_fd Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=508D16BA.2040101@redhat.com \
--to=owasserm@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).