qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>,
	Zhenzhong Duan <zhenzhong.duan@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Cedric Le Goater <clg@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
	Philippe Mathieu-Daude <philmd@linaro.org>,
	David Hildenbrand <david@redhat.com>,
	Steve Sistare <steven.sistare@oracle.com>
Subject: [RFC V1 10/12] migration/ram: old host address
Date: Sat, 20 Jul 2024 12:15:35 -0700	[thread overview]
Message-ID: <1721502937-87102-11-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1721502937-87102-1-git-send-email-steven.sistare@oracle.com>

Remember the RAMBlock host address as host_old during migration, for use
by CPR.  The iommufd interface to update the virtual address of DMA
mappings requires it.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 hw/core/machine.c       | 6 ++++++
 include/exec/ramblock.h | 1 +
 migration/migration.h   | 2 ++
 migration/options.c     | 2 ++
 migration/ram.c         | 7 +++++++
 5 files changed, 18 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 9676953..0ac16b8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -35,6 +35,12 @@
 #include "hw/virtio/virtio-iommu.h"
 #include "audio/audio.h"
 
+/* TBD: register hw_compat_9_1 with machines */
+GlobalProperty hw_compat_9_1[] = {
+    { "migration", "send-host-old", "off"},
+};
+const size_t hw_compat_9_1_len = G_N_ELEMENTS(hw_compat_9_1);
+
 GlobalProperty hw_compat_9_0[] = {
     {"arm-cpu", "backcompat-cntfrq", "true" },
     {"scsi-disk-base", "migrate-emulated-scsi-request", "false" },
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h
index 64484cd..8f1c535 100644
--- a/include/exec/ramblock.h
+++ b/include/exec/ramblock.h
@@ -28,6 +28,7 @@ struct RAMBlock {
     struct rcu_head rcu;
     struct MemoryRegion *mr;
     uint8_t *host;
+    uint64_t host_old;
     uint8_t *colo_cache; /* For colo, VM's ram cache */
     ram_addr_t offset;
     ram_addr_t used_length;
diff --git a/migration/migration.h b/migration/migration.h
index 38aa140..b5e3151 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -442,6 +442,8 @@ struct MigrationState {
      */
     uint8_t clear_bitmap_shift;
 
+    bool send_host_old;
+
     /*
      * This save hostname when out-going migration starts
      */
diff --git a/migration/options.c b/migration/options.c
index 7526f9f..197cb86 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -92,6 +92,8 @@ Property migration_properties[] = {
                       clear_bitmap_shift, CLEAR_BITMAP_SHIFT_DEFAULT),
     DEFINE_PROP_BOOL("x-preempt-pre-7-2", MigrationState,
                      preempt_pre_7_2, false),
+    DEFINE_PROP_BOOL("send-host-old", MigrationState,
+                     send_host_old, true),
 
     /* Migration parameters */
     DEFINE_PROP_UINT8("x-throttle-trigger-threshold", MigrationState,
diff --git a/migration/ram.c b/migration/ram.c
index 1e1e05e..8644917 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -3030,6 +3030,9 @@ static int ram_save_setup(QEMUFile *f, void *opaque, Error **errp)
             qemu_put_byte(f, strlen(block->idstr));
             qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
             qemu_put_be64(f, block->used_length);
+            if (migrate_get_current()->send_host_old) {
+                qemu_put_be64(f, (uint64_t)block->host);
+            }
             if (migrate_postcopy_ram() &&
                 block->page_size != max_hg_page_size) {
                 qemu_put_be64(f, block->page_size);
@@ -4021,6 +4024,10 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
 
     assert(block);
 
+    if (migrate_get_current()->send_host_old) {
+        block->host_old = qemu_get_be64(f);
+    }
+
     if (migrate_mapped_ram()) {
         parse_ramblock_mapped_ram(f, block, length, &local_err);
         if (local_err) {
-- 
1.8.3.1



  parent reply	other threads:[~2024-07-20 19:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-20 19:15 [RFC V1 00/12] Live update: iommufd Steve Sistare
2024-07-20 19:15 ` [RFC V1 01/12] vfio: move cpr_exec_notifier Steve Sistare
2024-07-20 19:15 ` [RFC V1 02/12] iommufd: no DMA to BARs Steve Sistare
2024-08-12 22:05   ` Alex Williamson
2024-08-13  1:39   ` Yi Liu
2024-08-13 14:53     ` Steven Sistare
2024-07-20 19:15 ` [RFC V1 03/12] iommufd: pass name to connect Steve Sistare
2024-07-20 19:15 ` [RFC V1 04/12] migration: cpr_find_fd_any Steve Sistare
2024-07-20 19:15 ` [RFC V1 05/12] iommufd: preserve device fd Steve Sistare
2024-07-20 19:15 ` [RFC V1 06/12] iommufd: export iommufd_cdev_get_info_iova_range Steve Sistare
2024-07-20 19:15 ` [RFC V1 07/12] iommufd: change_process kernel interface Steve Sistare
2024-07-20 19:15 ` [RFC V1 08/12] vfio/iommufd: register container for cpr Steve Sistare
2024-07-20 19:15 ` [RFC V1 09/12] vfio/iommufd: rebuild device Steve Sistare
2024-07-20 19:15 ` Steve Sistare [this message]
2024-08-16 17:57   ` [RFC V1 10/12] migration/ram: old host address Fabiano Rosas
2024-08-16 18:13     ` Steven Sistare
2024-07-20 19:15 ` [RFC V1 11/12] iommufd: update DMA virtual addresses Steve Sistare
2024-07-20 19:15 ` [RFC V1 12/12] vfio: mdev blocker Steve Sistare

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=1721502937-87102-11-git-send-email-steven.sistare@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=david@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=farosas@suse.de \
    --cc=mst@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yi.l.liu@intel.com \
    --cc=zhenzhong.duan@intel.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).