From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>,
qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 04/22] migration: split migration hooks out of QEMUFileOps
Date: Thu, 28 Jan 2016 17:57:08 +0000 [thread overview]
Message-ID: <20160128175708.GD2911@work-vm> (raw)
In-Reply-To: <1452599056-27357-5-git-send-email-berrange@redhat.com>
* Daniel P. Berrange (berrange@redhat.com) wrote:
> The QEMUFileOps struct contains the I/O subsystem callbacks
> and the migration stage hooks. Split the hooks out into a
> separate QEMUFileHooks struct to make it easier to refactor
> the I/O side of QEMUFile without affecting the hooks.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> include/migration/qemu-file.h | 10 +++++++---
> migration/qemu-file-internal.h | 1 +
> migration/qemu-file.c | 24 +++++++++++++++---------
> migration/rdma.c | 8 ++++++++
> 4 files changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
> index 5debe8c..ddffc6a 100644
> --- a/include/migration/qemu-file.h
> +++ b/include/migration/qemu-file.h
> @@ -109,13 +109,16 @@ typedef struct QEMUFileOps {
> QEMUFileCloseFunc *close;
> QEMUFileGetFD *get_fd;
> QEMUFileWritevBufferFunc *writev_buffer;
> + QEMURetPathFunc *get_return_path;
> + QEMUFileShutdownFunc *shut_down;
> +} QEMUFileOps;
> +
> +typedef struct QEMUFileHooks {
> QEMURamHookFunc *before_ram_iterate;
> QEMURamHookFunc *after_ram_iterate;
> QEMURamHookFunc *hook_ram_load;
> QEMURamSaveFunc *save_page;
> - QEMURetPathFunc *get_return_path;
> - QEMUFileShutdownFunc *shut_down;
> -} QEMUFileOps;
> +} QEMUFileHooks;
>
> struct QEMUSizedBuffer {
> struct iovec *iov;
> @@ -130,6 +133,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode);
> QEMUFile *qemu_fopen_socket(int fd, const char *mode);
> QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
> QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input);
> +void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
> int qemu_get_fd(QEMUFile *f);
> int qemu_fclose(QEMUFile *f);
> int64_t qemu_ftell(QEMUFile *f);
> diff --git a/migration/qemu-file-internal.h b/migration/qemu-file-internal.h
> index d95e853..8fdfa95 100644
> --- a/migration/qemu-file-internal.h
> +++ b/migration/qemu-file-internal.h
> @@ -33,6 +33,7 @@
>
> struct QEMUFile {
> const QEMUFileOps *ops;
> + const QEMUFileHooks *hooks;
> void *opaque;
>
> int64_t bytes_xfer;
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index f89e64e..337cb4c 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -79,6 +79,12 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
> return f;
> }
>
> +
> +void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks)
> +{
> + f->hooks = hooks;
> +}
> +
> /*
> * Get last error for stream f
> *
> @@ -148,8 +154,8 @@ void ram_control_before_iterate(QEMUFile *f, uint64_t flags)
> {
> int ret = 0;
>
> - if (f->ops->before_ram_iterate) {
> - ret = f->ops->before_ram_iterate(f, f->opaque, flags, NULL);
> + if (f->hooks && f->hooks->before_ram_iterate) {
> + ret = f->hooks->before_ram_iterate(f, f->opaque, flags, NULL);
> if (ret < 0) {
> qemu_file_set_error(f, ret);
> }
> @@ -160,8 +166,8 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
> {
> int ret = 0;
>
> - if (f->ops->after_ram_iterate) {
> - ret = f->ops->after_ram_iterate(f, f->opaque, flags, NULL);
> + if (f->hooks && f->hooks->after_ram_iterate) {
> + ret = f->hooks->after_ram_iterate(f, f->opaque, flags, NULL);
> if (ret < 0) {
> qemu_file_set_error(f, ret);
> }
> @@ -172,8 +178,8 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data)
> {
> int ret = -EINVAL;
>
> - if (f->ops->hook_ram_load) {
> - ret = f->ops->hook_ram_load(f, f->opaque, flags, data);
> + if (f->hooks && f->hooks->hook_ram_load) {
> + ret = f->hooks->hook_ram_load(f, f->opaque, flags, data);
> if (ret < 0) {
> qemu_file_set_error(f, ret);
> }
> @@ -192,9 +198,9 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
> ram_addr_t offset, size_t size,
> uint64_t *bytes_sent)
> {
> - if (f->ops->save_page) {
> - int ret = f->ops->save_page(f, f->opaque, block_offset,
> - offset, size, bytes_sent);
> + if (f->hooks && f->hooks->save_page) {
> + int ret = f->hooks->save_page(f, f->opaque, block_offset,
> + offset, size, bytes_sent);
>
> if (ret != RAM_SAVE_CONTROL_DELAYED) {
> if (bytes_sent && *bytes_sent > 0) {
> diff --git a/migration/rdma.c b/migration/rdma.c
> index dcabb91..bffbfaf 100644
> --- a/migration/rdma.c
> +++ b/migration/rdma.c
> @@ -3380,12 +3380,18 @@ static const QEMUFileOps rdma_read_ops = {
> .get_buffer = qemu_rdma_get_buffer,
> .get_fd = qemu_rdma_get_fd,
> .close = qemu_rdma_close,
> +};
> +
> +static const QEMUFileHooks rdma_read_hooks = {
> .hook_ram_load = rdma_load_hook,
> };
>
> static const QEMUFileOps rdma_write_ops = {
> .put_buffer = qemu_rdma_put_buffer,
> .close = qemu_rdma_close,
> +};
> +
> +static const QEMUFileHooks rdma_write_hooks = {
> .before_ram_iterate = qemu_rdma_registration_start,
> .after_ram_iterate = qemu_rdma_registration_stop,
> .save_page = qemu_rdma_save_page,
> @@ -3404,8 +3410,10 @@ static void *qemu_fopen_rdma(RDMAContext *rdma, const char *mode)
>
> if (mode[0] == 'w') {
> r->file = qemu_fopen_ops(r, &rdma_write_ops);
> + qemu_file_set_hooks(r->file, &rdma_write_hooks);
> } else {
> r->file = qemu_fopen_ops(r, &rdma_read_ops);
> + qemu_file_set_hooks(r->file, &rdma_read_hooks);
> }
>
> return r->file;
> --
> 2.5.0
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2016-01-28 17:57 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 11:43 [Qemu-devel] [PATCH v1 00/22] Convert migration to QIOChannel & support TLS Daniel P. Berrange
2016-01-12 11:43 ` [Qemu-devel] [PATCH v1 01/22] s390: use FILE instead of QEMUFile for creating text file Daniel P. Berrange
2016-01-12 11:58 ` Cornelia Huck
2016-01-12 12:01 ` Daniel P. Berrange
2016-01-12 12:05 ` Cornelia Huck
2016-02-12 17:19 ` Dr. David Alan Gilbert
2016-01-12 11:43 ` [Qemu-devel] [PATCH v1 02/22] migration: remove use of qemu_bufopen from vmstate tests Daniel P. Berrange
2016-01-28 17:45 ` Dr. David Alan Gilbert
2016-01-12 11:43 ` [Qemu-devel] [PATCH v1 03/22] migration: ensure qemu_fflush() always writes full data amount Daniel P. Berrange
2016-01-28 17:53 ` Dr. David Alan Gilbert
2016-02-03 13:31 ` Daniel P. Berrange
2016-01-12 11:43 ` [Qemu-devel] [PATCH v1 04/22] migration: split migration hooks out of QEMUFileOps Daniel P. Berrange
2016-01-28 17:57 ` Dr. David Alan Gilbert [this message]
2016-01-12 11:43 ` [Qemu-devel] [PATCH v1 05/22] migration: introduce set_blocking function in QEMUFileOps Daniel P. Berrange
2016-01-28 18:00 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 06/22] migration: force QEMUFile to blocking mode for outgoing migration Daniel P. Berrange
2016-01-28 18:17 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 07/22] migration: introduce a new QEMUFile impl based on QIOChannel Daniel P. Berrange
2016-02-02 17:06 ` Dr. David Alan Gilbert
2016-02-03 13:37 ` Daniel P. Berrange
2016-02-12 17:16 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 08/22] migration: convert post-copy to use QIOChannelBuffer Daniel P. Berrange
2016-01-25 19:38 ` Dr. David Alan Gilbert
2016-01-25 22:15 ` Daniel P. Berrange
2016-01-26 18:59 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 09/22] migration: convert unix socket protocol to use QIOChannel Daniel P. Berrange
2016-02-02 18:02 ` Dr. David Alan Gilbert
2016-02-03 11:25 ` Daniel P. Berrange
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 10/22] migration: convert tcp " Daniel P. Berrange
2016-02-02 18:19 ` Dr. David Alan Gilbert
2016-02-03 10:02 ` Daniel P. Berrange
2016-02-03 10:33 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 11/22] migration: convert fd " Daniel P. Berrange
2016-02-02 18:46 ` Dr. David Alan Gilbert
2016-02-03 10:05 ` Daniel P. Berrange
2016-02-03 10:29 ` Dr. David Alan Gilbert
2016-02-03 10:39 ` Daniel P. Berrange
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 12/22] migration: convert exec " Daniel P. Berrange
2016-02-02 18:53 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 13/22] migration: convert RDMA to use QIOChannel interface Daniel P. Berrange
2016-02-02 20:01 ` Dr. David Alan Gilbert
2016-02-03 11:37 ` Daniel P. Berrange
2016-02-03 13:23 ` Dr. David Alan Gilbert
2016-02-03 13:25 ` Daniel P. Berrange
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 14/22] migration: convert savevm to use QIOChannel for writing to files Daniel P. Berrange
2016-02-03 9:52 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 15/22] migration: delete QEMUFile buffer implementation Daniel P. Berrange
2016-02-03 9:54 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 16/22] migration: delete QEMUSizedBuffer struct Daniel P. Berrange
2016-02-03 9:55 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 17/22] migration: delete QEMUFile sockets implementation Daniel P. Berrange
2016-02-03 9:56 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 18/22] migration: delete QEMUFile stdio implementation Daniel P. Berrange
2016-02-03 9:58 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 19/22] migration: move definition of struct QEMUFile back into qemu-file.c Daniel P. Berrange
2016-02-05 18:32 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 20/22] migration: support TLS encryption with TCP migration backend Daniel P. Berrange
2016-02-12 17:09 ` Dr. David Alan Gilbert
2016-02-12 17:25 ` Daniel P. Berrange
2016-02-15 11:00 ` Daniel P. Berrange
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 21/22] migration: remove support for non-iovec based write handlers Daniel P. Berrange
2016-02-12 15:48 ` Dr. David Alan Gilbert
2016-01-12 11:44 ` [Qemu-devel] [PATCH v1 22/22] migration: remove qemu_get_fd method from QEMUFile Daniel P. Berrange
2016-02-12 15:51 ` Dr. David Alan Gilbert
2016-01-12 11:59 ` [Qemu-devel] [PATCH v1 00/22] Convert migration to QIOChannel & support TLS Daniel P. Berrange
2016-01-20 18:01 ` Daniel P. Berrange
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=20160128175708.GD2911@work-vm \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=berrange@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).