Blame SOURCES/0021-Migration-compat-for-fdc.patch

1bdc94
From 81b63caf259fac3ec0906f6d7712a831206d0dd5 Mon Sep 17 00:00:00 2001
4a2fec
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
4a2fec
Date: Fri, 26 Jun 2015 16:19:47 +0200
4a2fec
Subject: Migration compat for fdc
4a2fec
4a2fec
Patchwork-id: 66534
4a2fec
O-Subject: [RHEL-7.2 qemu-kvm-rhev PATCH 1/1] Migration compat for fdc
4a2fec
Bugzilla: 1215091
4a2fec
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Juan Quintela <quintela@redhat.com>
4a2fec
4a2fec
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
4a2fec
4a2fec
2.2 added some sections into the fdc and floppy drive, this patch
4a2fec
disables those new sections for reverse migration compatibility.
4a2fec
4a2fec
There are three pieces of data added to the migration:
4a2fec
   1) 'perpendicular mode' on the drive - i.e. 2.88MB mode, that
4a2fec
      was rare as hens teeth and the flag isn't actually used anywhere.
4a2fec
4a2fec
   2) fdc_reset_sensei
4a2fec
      This relates to the state of the fdc just after a reset command;
4a2fec
      the fdc produces four 'sense' states internally (corresponding to
4a2fec
      one external interrupt) that is there for backwards compatibility
4a2fec
      to an older fdc (and to 8" drives!!).  This compatibility code
4a2fec
      was added to qemu to fix SCO Openserver floppy problems, ~2009.
4a2fec
      Migration just after an fdc-reset would get the initial interrupt
4a2fec
      but lose the extra 3 sense states.  Print a log message since
4a2fec
      that's guest visible, but it's not knowingly caused us a problem
4a2fec
      so don't fail migration.
4a2fec
4a2fec
   3) result-timer
4a2fec
      The emulation models a delay after the 'read id' command which
4a2fec
      is handled by a timer; if we migrate before the timer goes off
4a2fec
      we probably wont complete the command.
4a2fec
      I'm worried that the most likely time that a 'read id' would be
4a2fec
      used would be in a background probe to see if there's a floppy
4a2fec
      present, so again, don't fail the migrate, but do print a log
4a2fec
      message.  With any luck any sane floppy driver will have a
4a2fec
      timeout; if we hit problems then a work around would be to
4a2fec
      make the pre-save mark the command as finished with error.
4a2fec
4a2fec
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
(cherry picked from commit b18d89c56aa26e86fb6194f77a15a72244d5ff88)
1bdc94
(cherry picked from commit 50613448205a2e85e90a488be1c83d0f2b5f2d52)
1bdc94
(cherry picked from commit 5bdbc1fe6b4574c78c80e664c539c51d7719f84d)
1bdc94
(cherry picked from commit 069889e404721c5439ee7d69aa90f9d4580f4f21)
1bdc94
(cherry picked from commit fd31805201e8da37645c5a34f7990a281afce10f)
4a2fec
---
4a2fec
 hw/block/fdc.c | 39 +++++++++++++++++++++++++++++++++++++--
4a2fec
 1 file changed, 37 insertions(+), 2 deletions(-)
4a2fec
4a2fec
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
1bdc94
index 3964096..6943263 100644
4a2fec
--- a/hw/block/fdc.c
4a2fec
+++ b/hw/block/fdc.c
4a2fec
@@ -36,6 +36,7 @@
4a2fec
 #include "hw/isa/isa.h"
4a2fec
 #include "hw/sysbus.h"
4a2fec
 #include "hw/block/block.h"
4a2fec
+#include "migration/migration.h"
4a2fec
 #include "sysemu/block-backend.h"
4a2fec
 #include "sysemu/blockdev.h"
4a2fec
 #include "sysemu/sysemu.h"
1bdc94
@@ -1036,6 +1037,10 @@ static bool fdrive_perpendicular_needed(void *opaque)
4a2fec
 {
4a2fec
     FDrive *drive = opaque;
4a2fec
 
4a2fec
+    if (migrate_pre_2_2) {
4a2fec
+        return false;
4a2fec
+    }
4a2fec
+
4a2fec
     return drive->perpendicular != 0;
4a2fec
 }
4a2fec
 
1bdc94
@@ -1130,8 +1135,20 @@ static int fdc_post_load(void *opaque, int version_id)
4a2fec
 static bool fdc_reset_sensei_needed(void *opaque)
4a2fec
 {
4a2fec
     FDCtrl *s = opaque;
4a2fec
+    bool needed = s->reset_sensei != 0;
4a2fec
+
4a2fec
+    if (migrate_pre_2_2) {
4a2fec
+        /*
4a2fec
+         * This probably wont matter for most OSs, but it's good to log
4a2fec
+         * it just incase we find it causes problems.
4a2fec
+         */
4a2fec
+        if (needed) {
4a2fec
+            error_report("INFO: fdc migration just after reset (sensei!=0)");
4a2fec
+        }
4a2fec
+        return false;
4a2fec
+    }
4a2fec
 
4a2fec
-    return s->reset_sensei != 0;
4a2fec
+    return needed;
4a2fec
 }
4a2fec
 
4a2fec
 static const VMStateDescription vmstate_fdc_reset_sensei = {
1bdc94
@@ -1148,8 +1165,26 @@ static const VMStateDescription vmstate_fdc_reset_sensei = {
4a2fec
 static bool fdc_result_timer_needed(void *opaque)
4a2fec
 {
4a2fec
     FDCtrl *s = opaque;
4a2fec
+    bool needed = timer_pending(s->result_timer);
4a2fec
+
4a2fec
+    if (migrate_pre_2_2) {
4a2fec
+        /*
4a2fec
+         * This could upset some OSs if their read-id command doesn't
4a2fec
+         * complete, so lets log something.
4a2fec
+         */
4a2fec
+        if (needed) {
4a2fec
+            error_report("INFO: fdc migration just after read-id (timer!=0)");
4a2fec
+        }
4a2fec
+        /*
4a2fec
+         * However, since it's not apparently caused us problems for many
4a2fec
+         * years, don't fail the migration, especially as this could
4a2fec
+         * happen as part of a background drive-probe which if it fails
4a2fec
+         * won't be a problem.
4a2fec
+         */
4a2fec
+        return false;
4a2fec
+    }
4a2fec
 
4a2fec
-    return timer_pending(s->result_timer);
4a2fec
+    return needed;
4a2fec
 }
4a2fec
 
4a2fec
 static const VMStateDescription vmstate_fdc_result_timer = {
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec