All of lore.kernel.org
 help / color / mirror / Atom feed
From: Md Haris Iqbal <haris.phnx@gmail.com>
To: qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, Md Haris Iqbal <haris.phnx@gmail.com>
Subject: [Qemu-devel] [PATCH 6/6] Migration: Recovering pages lost due to n/w failure during pc migration (destination)
Date: Mon, 22 Aug 2016 02:28:52 +0530	[thread overview]
Message-ID: <1471813132-13836-7-git-send-email-haris.phnx@gmail.com> (raw)
In-Reply-To: <1471813132-13836-1-git-send-email-haris.phnx@gmail.com>

Signed-off-by: Md Haris Iqbal <haris.phnx@gmail.com>
---
 include/migration/migration.h |  1 +
 include/sysemu/sysemu.h       |  1 +
 migration/ram.c               | 35 +++++++++++++++++++++++++++++++++++
 migration/savevm.c            | 12 ++++++++++++
 4 files changed, 49 insertions(+)

diff --git a/include/migration/migration.h b/include/migration/migration.h
index 5533832..cda5ece 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -366,6 +366,7 @@ int qemu_migrate_postcopy_incoming_recovery(QEMUFile **f,MigrationIncomingState*
 void migrate_incoming_ram_bitmap_init(void);
 void migrate_incoming_ram_bitmap_update(RAMBlock *rb, ram_addr_t addr);
 void migrate_incoming_ram_bitmap_free(void);
+void *migrate_incoming_ram_req_pages(void *opaque);
 
 PostcopyState postcopy_state_get(void);
 /* Set the state and return the old state */
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ee7c760..af5630c 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -100,6 +100,7 @@ enum qemu_vm_cmd {
                                       were previously sent during
                                       precopy but are dirty. */
     MIG_CMD_PACKAGED,          /* Send a wrapped stream within this stream */
+    MIG_CMD_POSTCOPY_RECOVERY,  /* Send pages lost due to n/w failure */
     MIG_CMD_MAX
 };
 
diff --git a/migration/ram.c b/migration/ram.c
index ea1382b..28381b6 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2649,6 +2649,41 @@ void migrate_incoming_ram_bitmap_free(void)
     }
 }
 
+void *migrate_incoming_ram_req_pages(void* opaque)
+{
+    MigrationIncomingState *mis = opaque;
+    struct RAMBlock *rb;
+    size_t hostpagesize = getpagesize();
+    uint64_t addr;
+    unsigned long base;
+    unsigned long nr;
+    unsigned long rb_end;
+    unsigned long next;
+    unsigned long *not_received;
+
+    not_received = atomic_rcu_read(&migration_bitmap_rcu)->not_received;
+    QLIST_FOREACH_RCU(rb, &ram_list.blocks, next) {
+        addr = 0;
+        base = rb->offset >> TARGET_PAGE_BITS;
+        rb_end = base + (rb->used_length >> TARGET_PAGE_BITS);
+        while (true) {
+            nr = base + (addr >> TARGET_PAGE_BITS);
+            next = find_next_bit(not_received, rb_end, nr);
+            addr = (next - base) << TARGET_PAGE_BITS;
+
+            if (addr >= rb->used_length) {
+                break;
+            }
+            else {
+                migrate_send_rp_req_pages(mis, qemu_ram_get_idstr(rb),
+                                     addr, hostpagesize);
+                addr++;
+            }
+        }
+    }
+    return NULL;
+}
+
 static SaveVMHandlers savevm_ram_handlers = {
     .save_live_setup = ram_save_setup,
     .save_live_iterate = ram_save_iterate,
diff --git a/migration/savevm.c b/migration/savevm.c
index aa4f777..2301b74 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1621,6 +1621,7 @@ static int loadvm_process_command(QEMUFile *f)
     uint16_t cmd;
     uint16_t len;
     uint32_t tmp32;
+    QemuThread req_pages_not_received;
 
     cmd = qemu_get_be16(f);
     len = qemu_get_be16(f);
@@ -1677,6 +1678,17 @@ static int loadvm_process_command(QEMUFile *f)
 
     case MIG_CMD_POSTCOPY_RAM_DISCARD:
         return loadvm_postcopy_ram_handle_discard(mis, len);
+
+    case MIG_CMD_POSTCOPY_RECOVERY:
+        /*
+         * This case will only be used when migration recovers from a
+         * network failure during a postcopy migration.
+         * Now, send the requests for pages that were lost due to the
+         * network failure.
+         */
+        qemu_thread_create(&req_pages_not_received, "pc/recovery",
+                       migrate_incoming_ram_req_pages, mis, QEMU_THREAD_DETACHED);
+            break;
     }
 
     return 0;
-- 
2.7.4

  parent reply	other threads:[~2016-08-21 20:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-21 20:58 [Qemu-devel] [PATCH 0/6] Recovery from network failure during Postcopy Migration Md Haris Iqbal
2016-08-21 20:58 ` [Qemu-devel] [PATCH 1/6] Migration: Reconnect network in case of network failure during pc migration (source) Md Haris Iqbal
2016-08-21 20:58 ` [Qemu-devel] [PATCH 2/6] migration : General additions for migration recovery Md Haris Iqbal
2016-08-21 20:58 ` [Qemu-devel] [PATCH 3/6] Migration: Reconnect network in case of network failure during pc migration (destination) Md Haris Iqbal
2016-08-21 20:58 ` [Qemu-devel] [PATCH 4/6] Migration: New bitmap for postcopy migration failure Md Haris Iqbal
2016-08-21 20:58 ` [Qemu-devel] [PATCH 5/6] Migration: Recovering pages lost due to n/w failure during pc migration (source) Md Haris Iqbal
2016-08-21 20:58 ` Md Haris Iqbal [this message]
2016-08-21 21:10 ` [Qemu-devel] [PATCH 0/6] Recovery from network failure during Postcopy Migration no-reply

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=1471813132-13836-7-git-send-email-haris.phnx@gmail.com \
    --to=haris.phnx@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.