cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From b18d89c56aa26e86fb6194f77a15a72244d5ff88 Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Fri, 26 Jun 2015 16:19:47 +0200
Subject: Migration compat for fdc

Patchwork-id: 66534
O-Subject: [RHEL-7.2 qemu-kvm-rhev PATCH 1/1] Migration compat for fdc
Bugzilla: 1215091
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

2.2 added some sections into the fdc and floppy drive, this patch
disables those new sections for reverse migration compatibility.

There are three pieces of data added to the migration:
   1) 'perpendicular mode' on the drive - i.e. 2.88MB mode, that
      was rare as hens teeth and the flag isn't actually used anywhere.

   2) fdc_reset_sensei
      This relates to the state of the fdc just after a reset command;
      the fdc produces four 'sense' states internally (corresponding to
      one external interrupt) that is there for backwards compatibility
      to an older fdc (and to 8" drives!!).  This compatibility code
      was added to qemu to fix SCO Openserver floppy problems, ~2009.
      Migration just after an fdc-reset would get the initial interrupt
      but lose the extra 3 sense states.  Print a log message since
      that's guest visible, but it's not knowingly caused us a problem
      so don't fail migration.

   3) result-timer
      The emulation models a delay after the 'read id' command which
      is handled by a timer; if we migrate before the timer goes off
      we probably wont complete the command.
      I'm worried that the most likely time that a 'read id' would be
      used would be in a background probe to see if there's a floppy
      present, so again, don't fail the migrate, but do print a log
      message.  With any luck any sane floppy driver will have a
      timeout; if we hit problems then a work around would be to
      make the pre-save mark the command as finished with error.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
(cherry picked from commit 9a8a0a1bc3c15bc85aadc713280f37a13f6a3ba6)
(cherry picked from commit c58ef850bbb33ee9be2d0b1e1b10cfe3cc9ae4a1)
---
 hw/block/fdc.c | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index f4f038d..45927a3 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -36,6 +36,7 @@
 #include "hw/isa/isa.h"
 #include "hw/sysbus.h"
 #include "hw/block/block.h"
+#include "migration/migration.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/sysemu.h"
@@ -1042,6 +1043,10 @@ static bool fdrive_perpendicular_needed(void *opaque)
 {
     FDrive *drive = opaque;
 
+    if (migrate_pre_2_2) {
+        return false;
+    }
+
     return drive->perpendicular != 0;
 }
 
@@ -1134,8 +1139,20 @@ static int fdc_post_load(void *opaque, int version_id)
 static bool fdc_reset_sensei_needed(void *opaque)
 {
     FDCtrl *s = opaque;
+    bool needed = s->reset_sensei != 0;
+
+    if (migrate_pre_2_2) {
+        /*
+         * This probably wont matter for most OSs, but it's good to log
+         * it just incase we find it causes problems.
+         */
+        if (needed) {
+            error_report("INFO: fdc migration just after reset (sensei!=0)");
+        }
+        return false;
+    }
 
-    return s->reset_sensei != 0;
+    return needed;
 }
 
 static const VMStateDescription vmstate_fdc_reset_sensei = {
@@ -1152,8 +1169,26 @@ static const VMStateDescription vmstate_fdc_reset_sensei = {
 static bool fdc_result_timer_needed(void *opaque)
 {
     FDCtrl *s = opaque;
+    bool needed = timer_pending(s->result_timer);
+
+    if (migrate_pre_2_2) {
+        /*
+         * This could upset some OSs if their read-id command doesn't
+         * complete, so lets log something.
+         */
+        if (needed) {
+            error_report("INFO: fdc migration just after read-id (timer!=0)");
+        }
+        /*
+         * However, since it's not apparently caused us problems for many
+         * years, don't fail the migration, especially as this could
+         * happen as part of a background drive-probe which if it fails
+         * won't be a problem.
+         */
+        return false;
+    }
 
-    return timer_pending(s->result_timer);
+    return needed;
 }
 
 static const VMStateDescription vmstate_fdc_result_timer = {
-- 
1.8.3.1