|
|
9ae3a8 |
From 31ce74359a069be69af0f6ba2f7867ed2083317a Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 8 Dec 2015 20:30:59 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 21/27] ide-test: fix failure for test_flush
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1449606659-23710-1-git-send-email-jsnow@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 68521
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v3 21/21] ide-test: fix failure for test_flush
|
|
|
9ae3a8 |
Bugzilla: 1272523
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This patch is a combination of two patches:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(1) Revert "qtest/ide-test: disable flush-test"
|
|
|
9ae3a8 |
(2) ide-test: fix failure for test_flush
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
First, the downstream-only revert:
|
|
|
9ae3a8 |
This reverts commit 228e49fabffa644ab7a6a03e98205f293115dc89.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Second, the backported fix:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3 added a test to ensure BSY
|
|
|
9ae3a8 |
flag is set when a flush request is in flight. It does this by setting
|
|
|
9ae3a8 |
a blkdebug breakpoint on flush_to_os before issuing a CMD_FLUSH_CACHE.
|
|
|
9ae3a8 |
It then resumes CMD_FLUSH_CACHE operation and checks that BSY is unset.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The actual unsetting of BSY does not occur until ide_flush_cb gets
|
|
|
9ae3a8 |
called in a bh, however, so in some cases this check will race with
|
|
|
9ae3a8 |
the actual completion.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Fix this by polling the ide status register until BSY flag gets unset
|
|
|
9ae3a8 |
before we do our final sanity checks. According to
|
|
|
9ae3a8 |
f68ec8379e88502b4841a110c070e9b118d3151c this is in line with how a guest
|
|
|
9ae3a8 |
would determine whether or not the device is still busy.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
|
9ae3a8 |
(cherry picked from commit 22bfa16ed3d4c9d534dcfe6f2381a654f32296b9)
|
|
|
9ae3a8 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/ide-test.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 41 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/ide-test.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 41 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/tests/ide-test.c b/tests/ide-test.c
|
|
|
9ae3a8 |
index 43b7fd6..92dd0e5 100644
|
|
|
9ae3a8 |
--- a/tests/ide-test.c
|
|
|
9ae3a8 |
+++ b/tests/ide-test.c
|
|
|
9ae3a8 |
@@ -425,6 +425,46 @@ static void test_identify(void)
|
|
|
9ae3a8 |
ide_test_quit();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static void test_flush(void)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ uint8_t data;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ide_test_start(
|
|
|
9ae3a8 |
+ "-vnc none "
|
|
|
9ae3a8 |
+ "-drive file=blkdebug::%s,if=ide,cache=writeback",
|
|
|
9ae3a8 |
+ tmp_path);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Delay the completion of the flush request until we explicitly do it */
|
|
|
9ae3a8 |
+ qmp("{'execute':'human-monitor-command', 'arguments': { "
|
|
|
9ae3a8 |
+ "'command-line': 'qemu-io ide0-hd0 \"break flush_to_os A\"'} }");
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* FLUSH CACHE command on device 0*/
|
|
|
9ae3a8 |
+ outb(IDE_BASE + reg_device, 0);
|
|
|
9ae3a8 |
+ outb(IDE_BASE + reg_command, CMD_FLUSH_CACHE);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Check status while request is in flight*/
|
|
|
9ae3a8 |
+ data = inb(IDE_BASE + reg_status);
|
|
|
9ae3a8 |
+ assert_bit_set(data, BSY | DRDY);
|
|
|
9ae3a8 |
+ assert_bit_clear(data, DF | ERR | DRQ);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Complete the command */
|
|
|
9ae3a8 |
+ qmp("{'execute':'human-monitor-command', 'arguments': { "
|
|
|
9ae3a8 |
+ "'command-line': 'qemu-io ide0-hd0 \"resume A\"'} }");
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Check registers */
|
|
|
9ae3a8 |
+ data = inb(IDE_BASE + reg_device);
|
|
|
9ae3a8 |
+ g_assert_cmpint(data & DEV, ==, 0);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ do {
|
|
|
9ae3a8 |
+ data = inb(IDE_BASE + reg_status);
|
|
|
9ae3a8 |
+ } while (data & BSY);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ assert_bit_set(data, DRDY);
|
|
|
9ae3a8 |
+ assert_bit_clear(data, BSY | DF | ERR | DRQ);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ide_test_quit();
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void test_flush_nodev(void)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
ide_test_start("");
|
|
|
9ae3a8 |
@@ -468,6 +508,7 @@ int main(int argc, char **argv)
|
|
|
9ae3a8 |
qtest_add_func("/ide/bmdma/long_prdt", test_bmdma_long_prdt);
|
|
|
9ae3a8 |
qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ qtest_add_func("/ide/flush", test_flush);
|
|
|
9ae3a8 |
qtest_add_func("/ide/flush_nodev", test_flush_nodev);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = g_test_run();
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|