All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests
@ 2015-03-10 20:14 John Snow
  2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 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-03-10 20:14 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

This series is based on:
"[Qemu-devel] [PATCH 0/2] ahci: test varying sector offsets"

There appear to be some upstream issues for iotests 051 and 061,
but this series does not appear to alter the existing bad behavior
of those 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.

v1 got bounced due to a prerequisite failing a test during a pull req,
so v2 is nearly unchanged:

v2:
 - Rebased to master
 - Fixed an include issue for patch 5.

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 v2 1/6] qtest/ahci: Add simple flush test
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
@ 2015-03-10 20:14 ` John Snow
  2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 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-03-10 20:14 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 fb4739f..b344121 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                                           */
 
@@ -1151,6 +1183,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 v2 2/6] qtest/ahci: Allow override of default CLI options
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 1/6] qtest/ahci: Add simple flush test John Snow
@ 2015-03-10 20:14 ` John Snow
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 3/6] libqtest: add qmp_eventwait John Snow
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-10 20:14 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 b344121..6c99f19 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 v2 3/6] libqtest: add qmp_eventwait
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 1/6] qtest/ahci: Add simple flush test John Snow
  2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 2/6] qtest/ahci: Allow override of default CLI options John Snow
@ 2015-03-10 20:15 ` John Snow
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 4/6] libqtest: add qmp_async John Snow
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-10 20:15 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 v2 4/6] libqtest: add qmp_async
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (2 preceding siblings ...)
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 3/6] libqtest: add qmp_eventwait John Snow
@ 2015-03-10 20:15 ` John Snow
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 5/6] libqos: add blkdebug_prepare_script John Snow
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-10 20:15 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 v2 5/6] libqos: add blkdebug_prepare_script
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (3 preceding siblings ...)
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 4/6] libqtest: add qmp_async John Snow
@ 2015-03-10 20:15 ` John Snow
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 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-03-10 20:15 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 c5c97bc..8805986 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -102,3 +102,25 @@ void mkqcow2(const char *file, unsigned size_mb)
 {
     return mkimg(file, "qcow2", size_mb);
 }
+
+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 8cb2987..f57362b 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -21,6 +21,7 @@ QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
 void qtest_shutdown(QOSState *qs);
 void mkimg(const char *file, const char *fmt, unsigned size_mb);
 void 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 v2 6/6] qtest/ahci: add flush retry test
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (4 preceding siblings ...)
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 5/6] libqos: add blkdebug_prepare_script John Snow
@ 2015-03-10 20:15 ` John Snow
  2015-03-13 19:35 ` [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
  2015-03-25 22:29 ` John Snow
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-10 20:15 UTC (permalink / raw)
  To: qemu-block
  Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini, John Snow

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 6c99f19..64dff8d 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;
 
@@ -1186,6 +1223,11 @@ int main(int argc, char **argv)
     close(mkstemp(tmp_path));
     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);
@@ -1207,11 +1249,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 v2 0/6] ahci: rerror/werror=stop resume tests
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (5 preceding siblings ...)
  2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 6/6] qtest/ahci: add flush retry test John Snow
@ 2015-03-13 19:35 ` John Snow
  2015-03-25 22:29 ` John Snow
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-13 19:35 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini

Ping: The series this is based on has been bumped to v2, but it does not 
change the context for this patchset.

Requires: <1426274523-22661-1-git-send-email-jsnow@redhat.com>

On 03/10/2015 04:14 PM, John Snow wrote:
> This series is based on:
> "[Qemu-devel] [PATCH 0/2] ahci: test varying sector offsets"
>
> There appear to be some upstream issues for iotests 051 and 061,
> but this series does not appear to alter the existing bad behavior
> of those 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.
>
> v1 got bounced due to a prerequisite failing a test during a pull req,
> so v2 is nearly unchanged:
>
> v2:
>   - Rebased to master
>   - Fixed an include issue for patch 5.
>
> 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(-)
>

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

* Re: [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests
  2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
                   ` (6 preceding siblings ...)
  2015-03-13 19:35 ` [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
@ 2015-03-25 22:29 ` John Snow
  7 siblings, 0 replies; 9+ messages in thread
From: John Snow @ 2015-03-25 22:29 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, marc.mari.barcelo, qemu-devel, stefanha, pbonzini


On 03/10/2015 04:14 PM, John Snow wrote:
> This series is based on:
> "[Qemu-devel] [PATCH 0/2] ahci: test varying sector offsets"
>
> There appear to be some upstream issues for iotests 051 and 061,
> but this series does not appear to alter the existing bad behavior
> of those 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.
>
> v1 got bounced due to a prerequisite failing a test during a pull req,
> so v2 is nearly unchanged:
>
> v2:
>   - Rebased to master
>   - Fixed an include issue for patch 5.
>
> 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(-)
>

After fixing the series this depends upon after it was booted from a 2.3 
pullreq for glib issues, I am staging this for 2.4.

Thanks!

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

end of thread, other threads:[~2015-03-25 22:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-10 20:14 [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 1/6] qtest/ahci: Add simple flush test John Snow
2015-03-10 20:14 ` [Qemu-devel] [PATCH v2 2/6] qtest/ahci: Allow override of default CLI options John Snow
2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 3/6] libqtest: add qmp_eventwait John Snow
2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 4/6] libqtest: add qmp_async John Snow
2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 5/6] libqos: add blkdebug_prepare_script John Snow
2015-03-10 20:15 ` [Qemu-devel] [PATCH v2 6/6] qtest/ahci: add flush retry test John Snow
2015-03-13 19:35 ` [Qemu-devel] [PATCH v2 0/6] ahci: rerror/werror=stop resume tests John Snow
2015-03-25 22:29 ` John Snow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.