From 16b2e839d32a8a3c41d5c5ba13a1576ae8b15ccc Mon Sep 17 00:00:00 2001
Message-Id: <16b2e839d32a8a3c41d5c5ba13a1576ae8b15ccc.1343915404.git.minovotn@redhat.com>
In-Reply-To: <5b3bcf18e866636f24ca1c23eb94d5caf23c6dd6.1343915404.git.minovotn@redhat.com>
References: <5b3bcf18e866636f24ca1c23eb94d5caf23c6dd6.1343915404.git.minovotn@redhat.com>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 16 Jul 2012 16:14:53 +0200
Subject: [PATCH 4/7] fdc: fix implied seek while there is no media in drive

RH-Author: Pavel Hrdina <phrdina@redhat.com>
Message-id: <64c7270592548f3e961cfebc5d1977be59d4cf98.1342446805.git.phrdina@redhat.com>
Patchwork-id: 40339
O-Subject: [RHEL-6.4 qemu-kvm PATCH v6 4/6] fdc: fix implied seek while there is no media in drive
Bugzilla: 729244
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: Michal Novotny <minovotn@redhat.com>

The Windows uses 'READ' command at the start of an instalation
without checking the 'dir' register. We have to abort the transfer
with an abnormal termination if there is no media in the drive.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit c52acf60b6c12ff5eb58eb6ac568c159ae0c8737)
---
 hw/fdc.c |    4 ++++
 1 file changed, 4 insertions(+)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/fdc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/fdc.c b/hw/fdc.c
index 8c5aa7f..084fbe9 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -165,6 +165,10 @@ static int fd_seek (fdrive_t *drv, uint8_t head, uint8_t track, uint8_t sect,
         drv->sect = sect;
     }
 
+    if (drv->bs == NULL || !bdrv_is_inserted(drv->bs)) {
+        ret = 2;
+    }
+
     return ret;
 }
 
-- 
1.7.10.4

