cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From d1c34ff41de0ece966991adb6aef6f2bce2ccfc4 Mon Sep 17 00:00:00 2001
958e1b
From: Kevin Wolf <kwolf@redhat.com>
958e1b
Date: Wed, 10 Sep 2014 11:06:08 +0200
958e1b
Subject: [PATCH 09/12] ide-test: Add FLUSH CACHE test case
958e1b
958e1b
Message-id: <1410347169-4368-3-git-send-email-kwolf@redhat.com>
958e1b
Patchwork-id: 60954
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 2/3] ide-test: Add FLUSH CACHE test case
958e1b
Bugzilla: 1123372
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
RH-Acked-by: Fam Zheng <famz@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
958e1b
This checks in particular that BSY is set while the flush request is in
958e1b
flight.
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
(cherry picked from commit bd07684aacfb61668ae2c25b7dd00b64f3d7c7f3)
958e1b
958e1b
RHEL: Whitelist the blkdebug driver so that the new qtest can succeed.
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 redhat/qemu-kvm.spec.template |    4 ++--
958e1b
 tests/ide-test.c              |   40 ++++++++++++++++++++++++++++++++++++++++
958e1b
 2 files changed, 42 insertions(+), 2 deletions(-)
958e1b
958e1b
diff --git a/tests/ide-test.c b/tests/ide-test.c
958e1b
index ac59259..739d2bf 100644
958e1b
--- a/tests/ide-test.c
958e1b
+++ b/tests/ide-test.c
958e1b
@@ -77,6 +77,7 @@ enum {
958e1b
 enum {
958e1b
     CMD_READ_DMA    = 0xc8,
958e1b
     CMD_WRITE_DMA   = 0xca,
958e1b
+    CMD_FLUSH_CACHE = 0xe7,
958e1b
     CMD_IDENTIFY    = 0xec,
958e1b
 
958e1b
     CMDF_ABORT      = 0x100,
958e1b
@@ -424,6 +425,43 @@ static void test_identify(void)
958e1b
     ide_test_quit();
958e1b
 }
958e1b
 
958e1b
+static void test_flush(void)
958e1b
+{
958e1b
+    uint8_t data;
958e1b
+
958e1b
+    ide_test_start(
958e1b
+        "-vnc none "
958e1b
+        "-drive file=blkdebug::%s,if=ide,cache=writeback",
958e1b
+        tmp_path);
958e1b
+
958e1b
+    /* Delay the completion of the flush request until we explicitly do it */
958e1b
+    qmp("{'execute':'human-monitor-command', 'arguments': { "
958e1b
+        "'command-line': 'qemu-io ide0-hd0 \"break flush_to_os A\"'} }");
958e1b
+
958e1b
+    /* FLUSH CACHE command on device 0*/
958e1b
+    outb(IDE_BASE + reg_device, 0);
958e1b
+    outb(IDE_BASE + reg_command, CMD_FLUSH_CACHE);
958e1b
+
958e1b
+    /* Check status while request is in flight*/
958e1b
+    data = inb(IDE_BASE + reg_status);
958e1b
+    assert_bit_set(data, BSY | DRDY);
958e1b
+    assert_bit_clear(data, DF | ERR | DRQ);
958e1b
+
958e1b
+    /* Complete the command */
958e1b
+    qmp("{'execute':'human-monitor-command', 'arguments': { "
958e1b
+        "'command-line': 'qemu-io ide0-hd0 \"resume A\"'} }");
958e1b
+
958e1b
+    /* Check registers */
958e1b
+    data = inb(IDE_BASE + reg_device);
958e1b
+    g_assert_cmpint(data & DEV, ==, 0);
958e1b
+
958e1b
+    data = inb(IDE_BASE + reg_status);
958e1b
+    assert_bit_set(data, DRDY);
958e1b
+    assert_bit_clear(data, BSY | DF | ERR | DRQ);
958e1b
+
958e1b
+    ide_test_quit();
958e1b
+}
958e1b
+
958e1b
 int main(int argc, char **argv)
958e1b
 {
958e1b
     const char *arch = qtest_get_arch();
958e1b
@@ -454,6 +492,8 @@ int main(int argc, char **argv)
958e1b
     qtest_add_func("/ide/bmdma/long_prdt", test_bmdma_long_prdt);
958e1b
     qtest_add_func("/ide/bmdma/teardown", test_bmdma_teardown);
958e1b
 
958e1b
+    qtest_add_func("/ide/flush", test_flush);
958e1b
+
958e1b
     ret = g_test_run();
958e1b
 
958e1b
     /* Cleanup */
958e1b
-- 
958e1b
1.7.1
958e1b