From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org
Cc: marc.mari.barcelo@gmail.com, pbonzini@redhat.com,
John Snow <jsnow@redhat.com>,
qemu-devel@nongnu.org, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 5/9] qtest/ahci: Add migration test
Date: Thu, 30 Apr 2015 14:07:18 -0400 [thread overview]
Message-ID: <1430417242-11859-6-git-send-email-jsnow@redhat.com> (raw)
In-Reply-To: <1430417242-11859-1-git-send-email-jsnow@redhat.com>
Notes:
* The migration is performed on QOSState objects.
* The migration is performed in such a way that it does not assume
consistency between the allocators attached to each. That is to say,
you can use each QOSState object completely independently and then at
an arbitrary point decide to migrate, and the destination object will
now be consistent with the memory within the source guest. The source
object that was migrated from will have a completely blank allocator.
ahci-test.c:
- verify_state is added
- ahci_migrate is added as a frontend to migrate
- test_migrate_sanity test case is added.
Signed-off-by: John Snow <jsnow@redhat.com>
---
tests/ahci-test.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 7c23bb2..2656b37 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -97,6 +97,70 @@ static void generate_pattern(void *buffer, size_t len, size_t cycle_len)
}
}
+/**
+ * Verify that the transfer did not corrupt our state at all.
+ */
+static void verify_state(AHCIQState *ahci)
+{
+ int i, j;
+ uint32_t ahci_fingerprint;
+ uint64_t hba_base;
+ AHCICommandHeader cmd;
+
+ ahci_fingerprint = qpci_config_readl(ahci->dev, PCI_VENDOR_ID);
+ g_assert_cmphex(ahci_fingerprint, ==, ahci->fingerprint);
+
+ /* If we haven't initialized, this is as much as can be validated. */
+ if (!ahci->hba_base) {
+ return;
+ }
+
+ hba_base = qpci_config_readl(ahci->dev, PCI_BASE_ADDRESS_5);
+ g_assert_cmphex(hba_base, ==, (uint64_t)ahci->hba_base);
+
+ g_assert_cmphex(ahci_rreg(ahci, AHCI_CAP), ==, ahci->cap);
+ g_assert_cmphex(ahci_rreg(ahci, AHCI_CAP2), ==, ahci->cap2);
+
+ for (i = 0; i < 32; i++) {
+ g_assert_cmphex(ahci_px_rreg(ahci, i, AHCI_PX_FB), ==,
+ ahci->port[i].fb);
+ g_assert_cmphex(ahci_px_rreg(ahci, i, AHCI_PX_CLB), ==,
+ ahci->port[i].clb);
+ for (j = 0; j < 32; j++) {
+ ahci_get_command_header(ahci, i, j, &cmd);
+ g_assert_cmphex(cmd.prdtl, ==, ahci->port[i].prdtl[j]);
+ g_assert_cmphex(cmd.ctba, ==, ahci->port[i].ctba[j]);
+ }
+ }
+}
+
+static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
+{
+ QOSState *tmp = to->parent;
+ QPCIDevice *dev = to->dev;
+ if (uri == NULL) {
+ uri = "tcp:127.0.0.1:1234";
+ }
+
+ /* context will be 'to' after completion. */
+ migrate(from->parent, to->parent, uri);
+
+ /* We'd like for the AHCIState objects to still point
+ * to information specific to its specific parent
+ * instance, but otherwise just inherit the new data. */
+ memcpy(to, from, sizeof(AHCIQState));
+ to->parent = tmp;
+ to->dev = dev;
+
+ tmp = from->parent;
+ dev = from->dev;
+ memset(from, 0x00, sizeof(AHCIQState));
+ from->parent = tmp;
+ from->dev = dev;
+
+ verify_state(to);
+}
+
/*** Test Setup & Teardown ***/
/**
@@ -146,6 +210,8 @@ static AHCIQState *ahci_boot(const char *cli, ...)
static void ahci_shutdown(AHCIQState *ahci)
{
QOSState *qs = ahci->parent;
+
+ set_context(qs);
ahci_clean_mem(ahci);
free_ahci_device(ahci->dev);
g_free(ahci);
@@ -1022,6 +1088,26 @@ static void test_flush_retry(void)
ahci_shutdown(ahci);
}
+/**
+ * Basic sanity test to boot a machine, find an AHCI device, and shutdown.
+ */
+static void test_migrate_sanity(void)
+{
+ AHCIQState *src, *dst;
+ const char *uri = "tcp:127.0.0.1:1234";
+
+ src = ahci_boot("-m 1024 -M q35 "
+ "-hda %s ", tmp_path);
+ dst = ahci_boot("-m 1024 -M q35 "
+ "-hda %s "
+ "-incoming %s", tmp_path, uri);
+
+ ahci_migrate(src, dst, uri);
+
+ ahci_shutdown(src);
+ ahci_shutdown(dst);
+}
+
/******************************************************************************/
/* AHCI I/O Test Matrix Definitions */
@@ -1271,6 +1357,8 @@ int main(int argc, char **argv)
qtest_add_func("/ahci/flush/simple", test_flush);
qtest_add_func("/ahci/flush/retry", test_flush_retry);
+ qtest_add_func("/ahci/migrate/sanity", test_migrate_sanity);
+
ret = g_test_run();
/* Cleanup */
--
2.1.0
next prev parent reply other threads:[~2015-04-30 18:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 18:07 [Qemu-devel] [PATCH v3 0/9] ahci: enable migration John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 1/9] libqos/ahci: Add halted command helpers John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 2/9] libqos/ahci: Fix sector set method John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 3/9] libqos: Add migration helpers John Snow
2015-05-04 12:07 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2015-05-04 17:52 ` John Snow
2015-05-05 11:35 ` Kevin Wolf
2015-05-05 15:50 ` John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 4/9] ich9/ahci: Enable Migration John Snow
2015-04-30 18:07 ` John Snow [this message]
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 6/9] qtest/ahci: add migrate dma test John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 7/9] qtest/ahci: add flush migrate test John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 8/9] qtest/ahci: add halted dma test John Snow
2015-04-30 18:07 ` [Qemu-devel] [PATCH v3 9/9] qtest/ahci: add migrate " John Snow
2015-05-04 12:29 ` [Qemu-devel] [Qemu-block] [PATCH v3 0/9] ahci: enable migration Kevin Wolf
2015-05-04 15:40 ` John Snow
2015-05-05 22:45 ` [Qemu-devel] " John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430417242-11859-6-git-send-email-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=marc.mari.barcelo@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).