qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests
@ 2015-02-24  0:45 John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 1/6] qtest/ahci: Add simple flush test John Snow
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

This series requires, in order:

ahci-preliminary-refactor (stefanha/block)
ahci-dma-test             (stefanha/block)
[PATCH v4 00/17] ide: rerror/werror migration fixes for IDE/ISA and AHCI
[PATCH 0/8] ahci: add more IO tests

This patchset brings us up to feature parity with the ide-test that
was checked in for the rerror/werror migration fixes series.

With the expanded functionality of libqos, we test error injection
and error recovery for the AHCI device.

John Snow (6):
  qtest/ahci: Add simple flush test
  qtest/ahci: Allow override of default CLI options
  libqtest: add qmp_eventwait
  libqtest: add qmp_async
  libqos: add blkdebug_prepare_script
  qtest/ahci: add flush retry test

 tests/ahci-test.c        | 143 ++++++++++++++++++++++++++++++++++++++++-------
 tests/ide-test.c         |  34 +----------
 tests/libqos/libqos-pc.c |   5 ++
 tests/libqos/libqos-pc.h |   1 +
 tests/libqos/libqos.c    |  22 ++++++++
 tests/libqos/libqos.h    |   1 +
 tests/libqtest.c         |  46 ++++++++++++++-
 tests/libqtest.h         |  47 ++++++++++++++++
 8 files changed, 245 insertions(+), 54 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 1/6] qtest/ahci: Add simple flush test
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 2/6] qtest/ahci: Allow override of default CLI options John Snow
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ahci-test.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index f536b19..378cfe5 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -774,6 +774,29 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,
     g_free(rx);
 }
 
+static void ahci_test_nondata(AHCIQState *ahci, uint8_t ide_cmd)
+{
+    uint8_t px;
+    AHCICommand *cmd;
+
+    /* Sanitize */
+    px = ahci_port_select(ahci);
+    ahci_port_clear(ahci, px);
+
+    /* Issue Command */
+    cmd = ahci_command_create(ide_cmd);
+    ahci_command_commit(ahci, cmd, px);
+    ahci_command_issue(ahci, cmd);
+    ahci_command_verify(ahci, cmd);
+    ahci_command_free(cmd);
+}
+
+static void ahci_test_flush(AHCIQState *ahci)
+{
+    ahci_test_nondata(ahci, CMD_FLUSH_CACHE);
+}
+
+
 /******************************************************************************/
 /* Test Interfaces                                                            */
 /******************************************************************************/
@@ -911,6 +934,15 @@ static void test_dma_fragmented(void)
     g_free(tx);
 }
 
+static void test_flush(void)
+{
+    AHCIQState *ahci;
+
+    ahci = ahci_boot_and_enable();
+    ahci_test_flush(ahci);
+    ahci_shutdown(ahci);
+}
+
 /******************************************************************************/
 /* AHCI I/O Test Matrix Definitions                                           */
 
@@ -1150,6 +1182,8 @@ int main(int argc, char **argv)
 
     qtest_add_func("/ahci/io/dma/lba28/fragmented", test_dma_fragmented);
 
+    qtest_add_func("/ahci/flush/simple", test_flush);
+
     ret = g_test_run();
 
     /* Cleanup */
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/6] qtest/ahci: Allow override of default CLI options
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 1/6] qtest/ahci: Add simple flush test John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 3/6] libqtest: add qmp_eventwait John Snow
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ahci-test.c        | 67 ++++++++++++++++++++++++++++++++----------------
 tests/libqos/libqos-pc.c |  5 ++++
 tests/libqos/libqos-pc.h |  1 +
 3 files changed, 51 insertions(+), 22 deletions(-)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 378cfe5..d43da45 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -75,19 +75,12 @@ static void string_bswap16(uint16_t *s, size_t bytes)
 /**
  * Start a Q35 machine and bookmark a handle to the AHCI device.
  */
-static AHCIQState *ahci_boot(void)
+static AHCIQState *ahci_vboot(const char *cli, va_list ap)
 {
     AHCIQState *s;
-    const char *cli;
 
     s = g_malloc0(sizeof(AHCIQState));
-
-    cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
-        ",format=qcow2"
-        " -M q35 "
-        "-device ide-hd,drive=drive0 "
-        "-global ide-hd.ver=%s";
-    s->parent = qtest_pc_boot(cli, tmp_path, "testdisk", "version");
+    s->parent = qtest_pc_vboot(cli, ap);
     alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);
 
     /* Verify that we have an AHCI device present. */
@@ -97,12 +90,35 @@ static AHCIQState *ahci_boot(void)
 }
 
 /**
+ * Start a Q35 machine and bookmark a handle to the AHCI device.
+ */
+static AHCIQState *ahci_boot(const char *cli, ...)
+{
+    AHCIQState *s;
+    va_list ap;
+
+    if (cli) {
+        va_start(ap, cli);
+        s = ahci_vboot(cli, ap);
+        va_end(ap);
+    } else {
+        cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
+            ",format=qcow2"
+            " -M q35 "
+            "-device ide-hd,drive=drive0 "
+            "-global ide-hd.ver=%s";
+        s = ahci_boot(cli, tmp_path, "testdisk", "version");
+    }
+
+    return s;
+}
+
+/**
  * Clean up the PCI device, then terminate the QEMU instance.
  */
 static void ahci_shutdown(AHCIQState *ahci)
 {
     QOSState *qs = ahci->parent;
-
     ahci_clean_mem(ahci);
     free_ahci_device(ahci->dev);
     g_free(ahci);
@@ -113,10 +129,18 @@ static void ahci_shutdown(AHCIQState *ahci)
  * Boot and fully enable the HBA device.
  * @see ahci_boot, ahci_pci_enable and ahci_hba_enable.
  */
-static AHCIQState *ahci_boot_and_enable(void)
+static AHCIQState *ahci_boot_and_enable(const char *cli, ...)
 {
     AHCIQState *ahci;
-    ahci = ahci_boot();
+    va_list ap;
+
+    if (cli) {
+        va_start(ap, cli);
+        ahci = ahci_vboot(cli, ap);
+        va_end(ap);
+    } else {
+        ahci = ahci_boot(NULL);
+    }
 
     ahci_pci_enable(ahci);
     ahci_hba_enable(ahci);
@@ -807,7 +831,7 @@ static void ahci_test_flush(AHCIQState *ahci)
 static void test_sanity(void)
 {
     AHCIQState *ahci;
-    ahci = ahci_boot();
+    ahci = ahci_boot(NULL);
     ahci_shutdown(ahci);
 }
 
@@ -818,7 +842,7 @@ static void test_sanity(void)
 static void test_pci_spec(void)
 {
     AHCIQState *ahci;
-    ahci = ahci_boot();
+    ahci = ahci_boot(NULL);
     ahci_test_pci_spec(ahci);
     ahci_shutdown(ahci);
 }
@@ -830,8 +854,7 @@ static void test_pci_spec(void)
 static void test_pci_enable(void)
 {
     AHCIQState *ahci;
-
-    ahci = ahci_boot();
+    ahci = ahci_boot(NULL);
     ahci_pci_enable(ahci);
     ahci_shutdown(ahci);
 }
@@ -844,7 +867,7 @@ static void test_hba_spec(void)
 {
     AHCIQState *ahci;
 
-    ahci = ahci_boot();
+    ahci = ahci_boot(NULL);
     ahci_pci_enable(ahci);
     ahci_test_hba_spec(ahci);
     ahci_shutdown(ahci);
@@ -858,7 +881,7 @@ static void test_hba_enable(void)
 {
     AHCIQState *ahci;
 
-    ahci = ahci_boot();
+    ahci = ahci_boot(NULL);
     ahci_pci_enable(ahci);
     ahci_hba_enable(ahci);
     ahci_shutdown(ahci);
@@ -872,7 +895,7 @@ static void test_identify(void)
 {
     AHCIQState *ahci;
 
-    ahci = ahci_boot_and_enable();
+    ahci = ahci_boot_and_enable(NULL);
     ahci_test_identify(ahci);
     ahci_shutdown(ahci);
 }
@@ -894,7 +917,7 @@ static void test_dma_fragmented(void)
     unsigned i;
     uint64_t ptr;
 
-    ahci = ahci_boot_and_enable();
+    ahci = ahci_boot_and_enable(NULL);
     px = ahci_port_select(ahci);
     ahci_port_clear(ahci, px);
 
@@ -938,7 +961,7 @@ static void test_flush(void)
 {
     AHCIQState *ahci;
 
-    ahci = ahci_boot_and_enable();
+    ahci = ahci_boot_and_enable(NULL);
     ahci_test_flush(ahci);
     ahci_shutdown(ahci);
 }
@@ -1053,7 +1076,7 @@ static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma,
 {
     AHCIQState *ahci;
 
-    ahci = ahci_boot_and_enable();
+    ahci = ahci_boot_and_enable(NULL);
     ahci_test_io_rw_simple(ahci, bufsize, sector,
                            io_cmds[dma][lba48][IO_READ],
                            io_cmds[dma][lba48][IO_WRITE]);
diff --git a/tests/libqos/libqos-pc.c b/tests/libqos/libqos-pc.c
index bbace89..1403699 100644
--- a/tests/libqos/libqos-pc.c
+++ b/tests/libqos/libqos-pc.c
@@ -6,6 +6,11 @@ static QOSOps qos_ops = {
     .uninit_allocator = pc_alloc_uninit
 };
 
+QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap)
+{
+    return qtest_vboot(&qos_ops, cmdline_fmt, ap);
+}
+
 QOSState *qtest_pc_boot(const char *cmdline_fmt, ...)
 {
     QOSState *qs;
diff --git a/tests/libqos/libqos-pc.h b/tests/libqos/libqos-pc.h
index 316857d..b1820c5 100644
--- a/tests/libqos/libqos-pc.h
+++ b/tests/libqos/libqos-pc.h
@@ -3,6 +3,7 @@
 
 #include "libqos/libqos.h"
 
+QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap);
 QOSState *qtest_pc_boot(const char *cmdline_fmt, ...);
 void qtest_pc_shutdown(QOSState *qs);
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 3/6] libqtest: add qmp_eventwait
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 1/6] qtest/ahci: Add simple flush test John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 2/6] qtest/ahci: Allow override of default CLI options John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 4/6] libqtest: add qmp_async John Snow
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Allow the user to poll until a desired interrupt occurs.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ide-test.c | 11 +----------
 tests/libqtest.c | 16 ++++++++++++++++
 tests/libqtest.h | 20 ++++++++++++++++++++
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index b28a302..1dae84f 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -520,7 +520,6 @@ static void test_retry_flush(const char *machine)
 {
     uint8_t data;
     const char *s;
-    QDict *response;
 
     prepare_blkdebug_script(debug_path, "flush_to_disk");
 
@@ -539,15 +538,7 @@ static void test_retry_flush(const char *machine)
     assert_bit_set(data, BSY | DRDY);
     assert_bit_clear(data, DF | ERR | DRQ);
 
-    for (;; response = NULL) {
-        response = qmp_receive();
-        if ((qdict_haskey(response, "event")) &&
-            (strcmp(qdict_get_str(response, "event"), "STOP") == 0)) {
-            QDECREF(response);
-            break;
-        }
-        QDECREF(response);
-    }
+    qmp_eventwait("STOP");
 
     /* Complete the command */
     s = "{'execute':'cont' }";
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 9a92aa7..a3ee8ae 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -450,6 +450,22 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
     QDECREF(response);
 }
 
+void qtest_qmp_eventwait(QTestState *s, const char *event)
+{
+    QDict *response;
+
+    for (;;) {
+        response = qtest_qmp_receive(s);
+        if ((qdict_haskey(response, "event")) &&
+            (strcmp(qdict_get_str(response, "event"), event) == 0)) {
+            QDECREF(response);
+            break;
+        }
+        QDECREF(response);
+    }
+}
+
+
 const char *qtest_get_arch(void)
 {
     const char *qemu = getenv("QTEST_QEMU_BINARY");
diff --git a/tests/libqtest.h b/tests/libqtest.h
index e7413d5..2aa2e6f 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -92,6 +92,15 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
 QDict *qtest_qmp_receive(QTestState *s);
 
 /**
+ * qtest_qmp_eventwait:
+ * @s: #QTestState instance to operate on.
+ * @s: #event event to wait for.
+ *
+ * Continuosly polls for QMP responses until it receives the desired event.
+ */
+void qtest_qmp_eventwait(QTestState *s, const char *event);
+
+/**
  * qtest_get_irq:
  * @s: #QTestState instance to operate on.
  * @num: Interrupt to observe.
@@ -397,6 +406,17 @@ static inline QDict *qmp_receive(void)
 }
 
 /**
+ * qmp_eventwait:
+ * @s: #event event to wait for.
+ *
+ * Continuosly polls for QMP responses until it receives the desired event.
+ */
+static inline void qmp_eventwait(const char *event)
+{
+    return qtest_qmp_eventwait(global_qtest, event);
+}
+
+/**
  * get_irq:
  * @num: Interrupt to observe.
  *
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 4/6] libqtest: add qmp_async
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (2 preceding siblings ...)
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 3/6] libqtest: add qmp_eventwait John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 5/6] libqos: add blkdebug_prepare_script John Snow
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Add qmp_async, which lets us send QMP commands asynchronously.
This is useful when we want to send commands that will trigger
event responses, but we don't know in what order to expect them.

Sometimes the event responses may arrive even before the command
confirmation will show up, so it is convenient to leave the responses
in the stream.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/libqtest.c | 30 +++++++++++++++++++++++++++++-
 tests/libqtest.h | 27 +++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index a3ee8ae..70a172e 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -388,7 +388,12 @@ QDict *qtest_qmp_receive(QTestState *s)
     return qmp.response;
 }
 
-QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+/**
+ * Allow users to send a message without waiting for the reply,
+ * in the case that they choose to discard all replies up until
+ * a particular EVENT is received.
+ */
+void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap)
 {
     va_list ap_copy;
     QObject *qobj;
@@ -417,6 +422,11 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
         QDECREF(qstr);
         qobject_decref(qobj);
     }
+}
+
+QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
+{
+    qtest_async_qmpv(s, fmt, ap);
 
     /* Receive reply */
     return qtest_qmp_receive(s);
@@ -433,6 +443,15 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
     return response;
 }
 
+void qtest_async_qmp(QTestState *s, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    qtest_async_qmpv(s, fmt, ap);
+    va_end(ap);
+}
+
 void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
 {
     QDict *response = qtest_qmpv(s, fmt, ap);
@@ -704,6 +723,15 @@ QDict *qmp(const char *fmt, ...)
     return response;
 }
 
+void qmp_async(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    qtest_async_qmpv(global_qtest, fmt, ap);
+    va_end(ap);
+}
+
 void qmp_discard_response(const char *fmt, ...)
 {
     va_list ap;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 2aa2e6f..cc57124 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -64,6 +64,15 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);
 QDict *qtest_qmp(QTestState *s, const char *fmt, ...);
 
 /**
+ * qtest_async_qmp:
+ * @s: #QTestState instance to operate on.
+ * @fmt...: QMP message to send to qemu
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qtest_async_qmp(QTestState *s, const char *fmt, ...);
+
+/**
  * qtest_qmpv_discard_response:
  * @s: #QTestState instance to operate on.
  * @fmt: QMP message to send to QEMU
@@ -84,6 +93,16 @@ void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);
 QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
 
 /**
+ * qtest_async_qmpv:
+ * @s: #QTestState instance to operate on.
+ * @fmt: QMP message to send to QEMU
+ * @ap: QMP message arguments
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap);
+
+/**
  * qtest_receive:
  * @s: #QTestState instance to operate on.
  *
@@ -388,6 +407,14 @@ static inline void qtest_end(void)
 QDict *qmp(const char *fmt, ...);
 
 /**
+ * qmp_async:
+ * @fmt...: QMP message to send to qemu
+ *
+ * Sends a QMP message to QEMU and leaves the response in the stream.
+ */
+void qmp_async(const char *fmt, ...);
+
+/**
  * qmp_discard_response:
  * @fmt...: QMP message to send to qemu
  *
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 5/6] libqos: add blkdebug_prepare_script
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (3 preceding siblings ...)
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 4/6] libqtest: add qmp_async John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 6/6] qtest/ahci: add flush retry test John Snow
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Pull this helper out of ide-test and into libqos,
to be shared with ahci-test.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ide-test.c      | 23 +----------------------
 tests/libqos/libqos.c | 22 ++++++++++++++++++++++
 tests/libqos/libqos.h |  1 +
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/tests/ide-test.c b/tests/ide-test.c
index 1dae84f..78382e9 100644
--- a/tests/ide-test.c
+++ b/tests/ide-test.c
@@ -29,6 +29,7 @@
 #include <glib.h>
 
 #include "libqtest.h"
+#include "libqos/libqos.h"
 #include "libqos/pci-pc.h"
 #include "libqos/malloc-pc.h"
 
@@ -494,28 +495,6 @@ static void test_flush(void)
     ide_test_quit();
 }
 
-static void prepare_blkdebug_script(const char *debug_fn, const char *event)
-{
-    FILE *debug_file = fopen(debug_fn, "w");
-    int ret;
-
-    fprintf(debug_file, "[inject-error]\n");
-    fprintf(debug_file, "event = \"%s\"\n", event);
-    fprintf(debug_file, "errno = \"5\"\n");
-    fprintf(debug_file, "state = \"1\"\n");
-    fprintf(debug_file, "immediately = \"off\"\n");
-    fprintf(debug_file, "once = \"on\"\n");
-
-    fprintf(debug_file, "[set-state]\n");
-    fprintf(debug_file, "event = \"%s\"\n", event);
-    fprintf(debug_file, "new_state = \"2\"\n");
-    fflush(debug_file);
-    g_assert(!ferror(debug_file));
-
-    ret = fclose(debug_file);
-    g_assert(ret == 0);
-}
-
 static void test_retry_flush(const char *machine)
 {
     uint8_t data;
diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 3577401..1a54a32 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -91,3 +91,25 @@ int mkqcow2(const char *file, unsigned size_mb)
 
     g_assert_not_reached();
 }
+
+void prepare_blkdebug_script(const char *debug_fn, const char *event)
+{
+    FILE *debug_file = fopen(debug_fn, "w");
+    int ret;
+
+    fprintf(debug_file, "[inject-error]\n");
+    fprintf(debug_file, "event = \"%s\"\n", event);
+    fprintf(debug_file, "errno = \"5\"\n");
+    fprintf(debug_file, "state = \"1\"\n");
+    fprintf(debug_file, "immediately = \"off\"\n");
+    fprintf(debug_file, "once = \"on\"\n");
+
+    fprintf(debug_file, "[set-state]\n");
+    fprintf(debug_file, "event = \"%s\"\n", event);
+    fprintf(debug_file, "new_state = \"2\"\n");
+    fflush(debug_file);
+    g_assert(!ferror(debug_file));
+
+    ret = fclose(debug_file);
+    g_assert(ret == 0);
+}
diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 5abd2bd..f459783 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -20,6 +20,7 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
 QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
 void qtest_shutdown(QOSState *qs);
 int mkqcow2(const char *file, unsigned size_mb);
+void prepare_blkdebug_script(const char *debug_fn, const char *event);
 
 static inline uint64_t qmalloc(QOSState *q, size_t bytes)
 {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 6/6] qtest/ahci: add flush retry test
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (4 preceding siblings ...)
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 5/6] libqos: add blkdebug_prepare_script John Snow
@ 2015-02-24  0:45 ` John Snow
  2015-02-24 17:56 ` [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-02-26 18:17 ` Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24  0:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, marc.mari.barcelo, stefanha, pbonzini, John Snow, afaerber

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/ahci-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index d43da45..f194cbc 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -46,6 +46,7 @@
 
 /*** Globals ***/
 static char tmp_path[] = "/tmp/qtest.XXXXXX";
+static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
 static bool ahci_pedantic;
 
 /*** Function Declarations ***/
@@ -966,6 +967,41 @@ static void test_flush(void)
     ahci_shutdown(ahci);
 }
 
+static void test_flush_retry(void)
+{
+    AHCIQState *ahci;
+    AHCICommand *cmd;
+    uint8_t port;
+    const char *s;
+
+    prepare_blkdebug_script(debug_path, "flush_to_disk");
+    ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
+                                "format=qcow2,cache=writeback,"
+                                "rerror=stop,werror=stop "
+                                "-M q35 "
+                                "-device ide-hd,drive=drive0 ",
+                                debug_path,
+                                tmp_path);
+
+    /* Issue Flush Command */
+    port = ahci_port_select(ahci);
+    ahci_port_clear(ahci, port);
+    cmd = ahci_command_create(CMD_FLUSH_CACHE);
+    ahci_command_commit(ahci, cmd, port);
+    ahci_command_issue_async(ahci, cmd);
+    qmp_eventwait("STOP");
+
+    /* Complete the command */
+    s = "{'execute':'cont' }";
+    qmp_async(s);
+    qmp_eventwait("RESUME");
+    ahci_command_wait(ahci, cmd);
+    ahci_command_verify(ahci, cmd);
+
+    ahci_command_free(cmd);
+    ahci_shutdown(ahci);
+}
+
 /******************************************************************************/
 /* AHCI I/O Test Matrix Definitions                                           */
 
@@ -1147,6 +1183,7 @@ int main(int argc, char **argv)
 {
     const char *arch;
     int ret;
+    int fd;
     int c;
     int i, j, k, m;
 
@@ -1185,6 +1222,11 @@ int main(int argc, char **argv)
     /* Create a temporary qcow2 image */
     mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB);
 
+    /* Create temporary blkdebug instructions */
+    fd = mkstemp(debug_path);
+    g_assert(fd >= 0);
+    close(fd);
+
     /* Run the tests */
     qtest_add_func("/ahci/sanity",     test_sanity);
     qtest_add_func("/ahci/pci_spec",   test_pci_spec);
@@ -1206,11 +1248,13 @@ int main(int argc, char **argv)
     qtest_add_func("/ahci/io/dma/lba28/fragmented", test_dma_fragmented);
 
     qtest_add_func("/ahci/flush/simple", test_flush);
+    qtest_add_func("/ahci/flush/retry", test_flush_retry);
 
     ret = g_test_run();
 
     /* Cleanup */
     unlink(tmp_path);
+    unlink(debug_path);
 
     return ret;
 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (5 preceding siblings ...)
  2015-02-24  0:45 ` [Qemu-devel] [PATCH 6/6] qtest/ahci: add flush retry test John Snow
@ 2015-02-24 17:56 ` John Snow
  2015-02-26 18:17 ` Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-02-24 17:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, marc.mari.barcelo, afaerber, stefanha, pbonzini



On 02/23/2015 07:45 PM, John Snow wrote:
> This series requires, in order:
>
> ahci-preliminary-refactor (stefanha/block)
> ahci-dma-test             (stefanha/block)

Update 2015-02-24: You can base off of master; but you still need the 
patches below:

> [PATCH v4 00/17] ide: rerror/werror migration fixes for IDE/ISA and AHCI
> [PATCH 0/8] ahci: add more IO tests
>
> This patchset brings us up to feature parity with the ide-test that
> was checked in for the rerror/werror migration fixes series.
>
> With the expanded functionality of libqos, we test error injection
> and error recovery for the AHCI device.
>
> John Snow (6):
>    qtest/ahci: Add simple flush test
>    qtest/ahci: Allow override of default CLI options
>    libqtest: add qmp_eventwait
>    libqtest: add qmp_async
>    libqos: add blkdebug_prepare_script
>    qtest/ahci: add flush retry test
>
>   tests/ahci-test.c        | 143 ++++++++++++++++++++++++++++++++++++++++-------
>   tests/ide-test.c         |  34 +----------
>   tests/libqos/libqos-pc.c |   5 ++
>   tests/libqos/libqos-pc.h |   1 +
>   tests/libqos/libqos.c    |  22 ++++++++
>   tests/libqos/libqos.h    |   1 +
>   tests/libqtest.c         |  46 ++++++++++++++-
>   tests/libqtest.h         |  47 ++++++++++++++++
>   8 files changed, 245 insertions(+), 54 deletions(-)
>

-- 
—js

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests
  2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (6 preceding siblings ...)
  2015-02-24 17:56 ` [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
@ 2015-02-26 18:17 ` Stefan Hajnoczi
  7 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2015-02-26 18:17 UTC (permalink / raw)
  To: John Snow
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini,
	afaerber

[-- Attachment #1: Type: text/plain, Size: 1363 bytes --]

On Mon, Feb 23, 2015 at 07:45:23PM -0500, John Snow wrote:
> This series requires, in order:
> 
> ahci-preliminary-refactor (stefanha/block)
> ahci-dma-test             (stefanha/block)
> [PATCH v4 00/17] ide: rerror/werror migration fixes for IDE/ISA and AHCI
> [PATCH 0/8] ahci: add more IO tests
> 
> This patchset brings us up to feature parity with the ide-test that
> was checked in for the rerror/werror migration fixes series.
> 
> With the expanded functionality of libqos, we test error injection
> and error recovery for the AHCI device.
> 
> John Snow (6):
>   qtest/ahci: Add simple flush test
>   qtest/ahci: Allow override of default CLI options
>   libqtest: add qmp_eventwait
>   libqtest: add qmp_async
>   libqos: add blkdebug_prepare_script
>   qtest/ahci: add flush retry test
> 
>  tests/ahci-test.c        | 143 ++++++++++++++++++++++++++++++++++++++++-------
>  tests/ide-test.c         |  34 +----------
>  tests/libqos/libqos-pc.c |   5 ++
>  tests/libqos/libqos-pc.h |   1 +
>  tests/libqos/libqos.c    |  22 ++++++++
>  tests/libqos/libqos.h    |   1 +
>  tests/libqtest.c         |  46 ++++++++++++++-
>  tests/libqtest.h         |  47 ++++++++++++++++
>  8 files changed, 245 insertions(+), 54 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-26 18:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24  0:45 [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 1/6] qtest/ahci: Add simple flush test John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 2/6] qtest/ahci: Allow override of default CLI options John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 3/6] libqtest: add qmp_eventwait John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 4/6] libqtest: add qmp_async John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 5/6] libqos: add blkdebug_prepare_script John Snow
2015-02-24  0:45 ` [Qemu-devel] [PATCH 6/6] qtest/ahci: add flush retry test John Snow
2015-02-24 17:56 ` [Qemu-devel] [PATCH 0/6] ahci: rerror/werror=stop resume tests John Snow
2015-02-26 18:17 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).