Skip to contentSkip to conversation

spapr: Fix stale HTAB during live migration

PATCH Superseded Samuel Mendoza-Jonas 2 participants 2 messages Aug 18, 2014

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: Fix stale HTAB during live migration

If a guest reboots during a running migration, changes to the hash page table are not necessarily updated on the destination. Opening a new file descriptor to the HTAB forces the migration handler to resend the entire table.

---
 hw/ppc/spapr.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/ppc/spapr.c +6 -0
index 3a6d26d..7733b37 100644
@@ -997,6 +997,12 @@ static void spapr_reset_htab(sPAPREnvironment *spapr)
         /* Kernel handles htab, we don't need to allocate one */
         spapr->htab_shift = shift;
         kvmppc_kern_htab = true;
+
+        /* Make sure readers are aware of the reset */
+        if (spapr->htab_fd > 0) {
+            close(spapr->htab_fd);
+            spapr->htab_fd = kvmppc_get_htab_fd(false);
+        }
     } else {
         if (!spapr->htab) {
             /* Allocate an htab if we don't yet have one */
Signature · 1 line
1.9.3
#1 lore raw
Quoted 15 lines · * Samuel Mendoza-Jonas ([email protected]) wrote:

If a guest reboots during a running migration, changes to the hash page table are not necessarily updated on the destination. Opening a new file descriptor to the HTAB forces the migration handler to resend the entire table.

---
 hw/ppc/spapr.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/ppc/spapr.c +0 -0
index 3a6d26d..7733b37 100644

hw/ppc/spapr.c static void spapr_reset_htab(sPAPREnvironment *spapr) · line 1005

Quoted 9 lines
hw/ppc/spapr.c +6 -0
@@ -997,6 +997,12 @@ static void spapr_reset_htab(sPAPREnvironment *spapr)
         /* Kernel handles htab, we don't need to allocate one */
         spapr->htab_shift = shift;
         kvmppc_kern_htab = true;
+
+        /* Make sure readers are aware of the reset */
+        if (spapr->htab_fd > 0) {
+            close(spapr->htab_fd);
+            spapr->htab_fd = kvmppc_get_htab_fd(false);
+        }

If this function can be called during migration, then
if we're unlucky can't that happen during a call to htab_save_iterate from the migration thread?
If so what would happen if that htab_save_iterate call was made just between the close() and the reopen?

Dave

Quoted 7 lines
hw/ppc/spapr.c +0 -0
     } else {
         if (!spapr->htab) {
             /* Allocate an htab if we don't yet have one */
Signature · 1 line
1.9.3

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK