aboutsummaryrefslogtreecommitdiff
path: root/tests/ide-test.c
diff options
context:
space:
mode:
authorEvgeny Yakovlev <eyakovlev@virtuozzo.com>2016-07-18 22:39:51 +0300
committerJohn Snow <jsnow@redhat.com>2016-07-18 18:19:01 -0400
commit2dd7e10d7c6ec6edbe610345cadd6ec82ee3e65f (patch)
tree0111cd8e3dafc516f9e9354aa96b4fda792b788d /tests/ide-test.c
parent35f78ab469b1d4ea4ff7ad4ffa997ae9ad3d4120 (diff)
tests: in IDE and AHCI tests perform DMA write before flushing
Due to changes in flush behaviour clean disks stopped generating flush_to_disk events and IDE and AHCI tests that test flush commands started to fail. This change adds additional DMA writes to affected tests before sending flush commands so that bdrv_flush actually generates flush_to_disk event. Signed-off-by: Evgeny Yakovlev <eyakovlev@virtuozzo.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1468870792-7411-4-git-send-email-den@openvz.org CC: Kevin Wolf <kwolf@redhat.com> CC: Max Reitz <mreitz@redhat.com> CC: Stefan Hajnoczi <stefanha@redhat.com> CC: Fam Zheng <famz@redhat.com> CC: John Snow <jsnow@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'tests/ide-test.c')
-rw-r--r--tests/ide-test.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ide-test.c b/tests/ide-test.c
index fed1b2ec2e..1e51af2a94 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -499,6 +499,39 @@ static void test_identify(void)
ide_test_quit();
}
+/*
+ * Write sector 1 with random data to make IDE storage dirty
+ * Needed for flush tests so that flushes actually go though the block layer
+ */
+static void make_dirty(uint8_t device)
+{
+ uint8_t status;
+ size_t len = 512;
+ uintptr_t guest_buf;
+ void* buf;
+
+ guest_buf = guest_alloc(guest_malloc, len);
+ buf = g_malloc(len);
+ g_assert(guest_buf);
+ g_assert(buf);
+
+ memwrite(guest_buf, buf, len);
+
+ PrdtEntry prdt[] = {
+ {
+ .addr = cpu_to_le32(guest_buf),
+ .size = cpu_to_le32(len | PRDT_EOT),
+ },
+ };
+
+ status = send_dma_request(CMD_WRITE_DMA, 1, 1, prdt,
+ ARRAY_SIZE(prdt), NULL);
+ g_assert_cmphex(status, ==, BM_STS_INTR);
+ assert_bit_clear(inb(IDE_BASE + reg_status), DF | ERR);
+
+ g_free(buf);
+}
+
static void test_flush(void)
{
uint8_t data;
@@ -507,6 +540,11 @@ static void test_flush(void)
"-drive file=blkdebug::%s,if=ide,cache=writeback,format=raw",
tmp_path);
+ qtest_irq_intercept_in(global_qtest, "ioapic");
+
+ /* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */
+ make_dirty(0);
+
/* Delay the completion of the flush request until we explicitly do it */
g_free(hmp("qemu-io ide0-hd0 \"break flush_to_os A\""));
@@ -549,6 +587,11 @@ static void test_retry_flush(const char *machine)
"rerror=stop,werror=stop",
debug_path, tmp_path);
+ qtest_irq_intercept_in(global_qtest, "ioapic");
+
+ /* Dirty media so that CMD_FLUSH_CACHE will actually go to disk */
+ make_dirty(0);
+
/* FLUSH CACHE command on device 0*/
outb(IDE_BASE + reg_device, 0);
outb(IDE_BASE + reg_command, CMD_FLUSH_CACHE);