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