All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Michael R. Hines" <mrhines@linux.vnet.ibm.com>
Cc: amit.shah@redhat.com, quintela@redhat.com,
	arei.gonglei@huawei.com, qemu-devel@nongnu.org,
	mrhines@us.ibm.com
Subject: Re: [Qemu-devel] [PATCH 05/10] Rework ram_control_load_hook to hook during block load
Date: Tue, 19 May 2015 19:49:39 +0100	[thread overview]
Message-ID: <20150519184938.GH2127@work-vm> (raw)
In-Reply-To: <555B8262.7040805@linux.vnet.ibm.com>

* Michael R. Hines (mrhines@linux.vnet.ibm.com) wrote:
> On 04/20/2015 10:57 AM, Dr. David Alan Gilbert (git) wrote:
> >From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> >We need the names of RAMBlocks as they're loaded for RDMA,
> >reuse an existing QEMUFile hook with some small mods.
> >
> >Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> >---
> >  arch_init.c                   |  4 +++-
> >  include/migration/migration.h |  2 +-
> >  include/migration/qemu-file.h | 14 +++++++++-----
> >  migration/qemu-file.c         |  8 ++++----
> >  migration/rdma.c              | 28 ++++++++++++++++++++++------
> >  trace-events                  |  2 +-
> >  6 files changed, 40 insertions(+), 18 deletions(-)
> >
> >diff --git a/arch_init.c b/arch_init.c
> >index 4c8fcee..6c0b355 100644
> >--- a/arch_init.c
> >+++ b/arch_init.c
> >@@ -1164,6 +1164,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
> >                                  error_report_err(local_err);
> >                              }
> >                          }
> >+                        ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG,
> >+                                              block->idstr);
> >                          break;
> >                      }
> >                  }
> >@@ -1215,7 +1217,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
> >              break;
> >          default:
> >              if (flags & RAM_SAVE_FLAG_HOOK) {
> >-                ram_control_load_hook(f, flags);
> >+                ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL);
> >              } else {
> >                  error_report("Unknown combination of migration flags: %#x",
> >                               flags);
> >diff --git a/include/migration/migration.h b/include/migration/migration.h
> >index bf09968..3c2f91a 100644
> >--- a/include/migration/migration.h
> >+++ b/include/migration/migration.h
> >@@ -154,7 +154,7 @@ int64_t xbzrle_cache_resize(int64_t new_size);
> >
> >  void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
> >  void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
> >-void ram_control_load_hook(QEMUFile *f, uint64_t flags);
> >+void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data);
> >
> >  /* Whenever this is found in the data stream, the flags
> >   * will be passed to ram_control_load_hook in the incoming-migration
> >diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
> >index 745a850..a3ceb3b 100644
> >--- a/include/migration/qemu-file.h
> >+++ b/include/migration/qemu-file.h
> >@@ -63,16 +63,20 @@ typedef ssize_t (QEMUFileWritevBufferFunc)(void *opaque, struct iovec *iov,
> >  /*
> >   * This function provides hooks around different
> >   * stages of RAM migration.
> >+ * 'opaque' is the backend specific data in QEMUFile
> >+ * 'data' is call specific data associated with the 'flags' value
> >   */
> 
> What data is this exactly?

In the case of the RAM_CONTROL_BLOCK_REG case we're passing the name of the block.

> >-typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque, uint64_t flags);
> >+typedef int (QEMURamHookFunc)(QEMUFile *f, void *opaque, uint64_t flags,
> >+                              void *data);
> >
> >  /*
> >   * Constants used by ram_control_* hooks
> >   */
> >-#define RAM_CONTROL_SETUP    0
> >-#define RAM_CONTROL_ROUND    1
> >-#define RAM_CONTROL_HOOK     2
> >-#define RAM_CONTROL_FINISH   3
> >+#define RAM_CONTROL_SETUP     0
> >+#define RAM_CONTROL_ROUND     1
> >+#define RAM_CONTROL_HOOK      2
> >+#define RAM_CONTROL_FINISH    3
> >+#define RAM_CONTROL_BLOCK_REG 4
> >
> >  /*
> >   * This function allows override of where the RAM page
> >diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> >index 1a4f986..4986e05 100644
> >--- a/migration/qemu-file.c
> >+++ b/migration/qemu-file.c
> >@@ -127,7 +127,7 @@ 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);
> >+        ret = f->ops->before_ram_iterate(f, f->opaque, flags, NULL);
> >          if (ret < 0) {
> >              qemu_file_set_error(f, ret);
> >          }
> >@@ -139,19 +139,19 @@ 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);
> >+        ret = f->ops->after_ram_iterate(f, f->opaque, flags, NULL);
> >          if (ret < 0) {
> >              qemu_file_set_error(f, ret);
> >          }
> >      }
> >  }
> >
> >-void ram_control_load_hook(QEMUFile *f, uint64_t flags)
> >+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);
> >+        ret = f->ops->hook_ram_load(f, f->opaque, flags, data);
> >          if (ret < 0) {
> >              qemu_file_set_error(f, ret);
> >          }
> >diff --git a/migration/rdma.c b/migration/rdma.c
> >index 2c0d11b..e43fae4 100644
> >--- a/migration/rdma.c
> >+++ b/migration/rdma.c
> >@@ -2906,8 +2906,7 @@ err_rdma_dest_wait:
> >   *
> >   * Keep doing this until the source tells us to stop.
> >   */
> >-static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque,
> >-                                         uint64_t flags)
> >+static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque)
> >  {
> >      RDMAControlHeader reg_resp = { .len = sizeof(RDMARegisterResult),
> >                                 .type = RDMA_CONTROL_REGISTER_RESULT,
> >@@ -2937,7 +2936,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque,
> >      CHECK_ERROR_STATE();
> >
> >      do {
> >-        trace_qemu_rdma_registration_handle_wait(flags);
> >+        trace_qemu_rdma_registration_handle_wait();
> >
> >          ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE);
> >
> >@@ -3125,8 +3124,25 @@ out:
> >      return ret;
> >  }
> >
> >+static int rdma_load_hook(QEMUFile *f, void *opaque, uint64_t flags, void *data)
> >+{
> >+    switch (flags) {
> >+    case RAM_CONTROL_BLOCK_REG:
> >+        /* TODO A later patch */
> >+        return -1;
> >+        break;
> >+
> >+    case RAM_CONTROL_HOOK:
> >+        return qemu_rdma_registration_handle(f, opaque);
> >+
> >+    default:
> >+        /* Shouldn't be called with any other values */
> >+        abort();
> >+    }
> >+}
> >+
> 
> Rename this to qemu_rdma_load_hook()

I've been trying to remove the qemu_'s generally on static
functions - there's no need to uniqueify the names if they're static.

Dave

> >  static int qemu_rdma_registration_start(QEMUFile *f, void *opaque,
> >-                                        uint64_t flags)
> >+                                        uint64_t flags, void *data)
> >  {
> >      QEMUFileRDMA *rfile = opaque;
> >      RDMAContext *rdma = rfile->rdma;
> >@@ -3145,7 +3161,7 @@ static int qemu_rdma_registration_start(QEMUFile *f, void *opaque,
> >   * First, flush writes, if any.
> >   */
> >  static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque,
> >-                                       uint64_t flags)
> >+                                       uint64_t flags, void *data)
> >  {
> >      Error *local_err = NULL, **errp = &local_err;
> >      QEMUFileRDMA *rfile = opaque;
> >@@ -3267,7 +3283,7 @@ static const QEMUFileOps rdma_read_ops = {
> >      .get_buffer    = qemu_rdma_get_buffer,
> >      .get_fd        = qemu_rdma_get_fd,
> >      .close         = qemu_rdma_close,
> >-    .hook_ram_load = qemu_rdma_registration_handle,
> >+    .hook_ram_load = rdma_load_hook,
> >  };
> >
> >  static const QEMUFileOps rdma_write_ops = {
> >diff --git a/trace-events b/trace-events
> >index 07f15da..baf8647 100644
> >--- a/trace-events
> >+++ b/trace-events
> >@@ -1416,7 +1416,7 @@ qemu_rdma_registration_handle_register_rkey(int rkey) "%x"
> >  qemu_rdma_registration_handle_unregister(int requests) "%d requests"
> >  qemu_rdma_registration_handle_unregister_loop(int count, int index, uint64_t chunk) "Unregistration request (%d): index %d, chunk %" PRIu64
> >  qemu_rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64
> >-qemu_rdma_registration_handle_wait(uint64_t flags) "Waiting for next request %" PRIu64
> >+qemu_rdma_registration_handle_wait(void) ""
> >  qemu_rdma_registration_start(uint64_t flags) "%" PRIu64
> >  qemu_rdma_registration_stop(uint64_t flags) "%" PRIu64
> >  qemu_rdma_registration_stop_ram(void) ""
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2015-05-19 18:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 15:57 [Qemu-devel] [PATCH 00/10] Remove RDMA migration dependence on RAMBlock offset Dr. David Alan Gilbert (git)
2015-04-20 15:57 ` [Qemu-devel] [PATCH 01/10] Rename RDMA structures to make destination clear Dr. David Alan Gilbert (git)
2015-05-19 17:52   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 02/10] qemu_ram_foreach_block: pass up error value, and down the ramblock name Dr. David Alan Gilbert (git)
2015-05-19 17:56   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 03/10] Store block name in local blocks structure Dr. David Alan Gilbert (git)
2015-05-19 18:00   ` Michael R. Hines
2015-05-19 18:46     ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 04/10] Translate offsets to destination address space Dr. David Alan Gilbert (git)
2015-05-19 18:28   ` Michael R. Hines
2015-05-19 18:44     ` Dr. David Alan Gilbert
2015-05-19 18:57       ` Michael R. Hines
2015-05-19 19:02         ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 05/10] Rework ram_control_load_hook to hook during block load Dr. David Alan Gilbert (git)
2015-05-19 18:35   ` Michael R. Hines
2015-05-19 18:49     ` Dr. David Alan Gilbert [this message]
2015-04-20 15:57 ` [Qemu-devel] [PATCH 06/10] Remove unneeded memset Dr. David Alan Gilbert (git)
2015-05-19 18:35   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 07/10] Simplify rdma_delete_block and remove it's dependence on the hash Dr. David Alan Gilbert (git)
2015-05-19 18:44   ` Michael R. Hines
2015-04-20 15:57 ` [Qemu-devel] [PATCH 08/10] Rework ram block hash Dr. David Alan Gilbert (git)
2015-05-19 18:49   ` Michael R. Hines
2015-05-19 18:55     ` Dr. David Alan Gilbert
2015-05-19 19:02       ` Michael R. Hines
2015-05-19 19:07         ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 09/10] Sort destination RAMBlocks to be the same as the source Dr. David Alan Gilbert (git)
2015-05-19 18:51   ` Michael R. Hines
2015-06-01 11:53     ` Dr. David Alan Gilbert
2015-04-20 15:57 ` [Qemu-devel] [PATCH 10/10] Sanity check RDMA remote data Dr. David Alan Gilbert (git)
2015-05-19 18:52   ` Michael R. Hines
2015-05-18 22:01 ` [Qemu-devel] [PATCH 00/10] Remove RDMA migration dependence on RAMBlock offset Michael R. Hines

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=20150519184938.GH2127@work-vm \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=mrhines@linux.vnet.ibm.com \
    --cc=mrhines@us.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.