From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Nico Boehr <nrb@linux.ibm.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, borntraeger@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH v2 2/2] s390x: add migration TOD clock test
Date: Tue, 11 Oct 2022 17:49:12 +0200 [thread overview]
Message-ID: <20221011174912.1495d8c7@p-imbrenda> (raw)
In-Reply-To: <20221011151433.886294-3-nrb@linux.ibm.com>
On Tue, 11 Oct 2022 17:14:33 +0200
Nico Boehr <nrb@linux.ibm.com> wrote:
> On migration, we expect the guest clock value to be preserved. Add a
> test to verify this:
> - advance the guest TOD by much more than we need to migrate
> - migrate the guest
> - get the guest TOD
>
> After migration, assert the guest TOD value is at least the value we set
> before migration.
>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
> s390x/Makefile | 1 +
> s390x/migration-sck.c | 44 +++++++++++++++++++++++++++++++++++++++++++
> s390x/unittests.cfg | 4 ++++
> 3 files changed, 49 insertions(+)
> create mode 100644 s390x/migration-sck.c
>
> diff --git a/s390x/Makefile b/s390x/Makefile
> index 649486f2d4a0..fba09bc2df3a 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -36,6 +36,7 @@ tests += $(TEST_DIR)/migration-cmm.elf
> tests += $(TEST_DIR)/migration-skey.elf
> tests += $(TEST_DIR)/panic-loop-extint.elf
> tests += $(TEST_DIR)/panic-loop-pgm.elf
> +tests += $(TEST_DIR)/migration-sck.elf
>
> pv-tests += $(TEST_DIR)/pv-diags.elf
>
> diff --git a/s390x/migration-sck.c b/s390x/migration-sck.c
> new file mode 100644
> index 000000000000..286a693b4858
> --- /dev/null
> +++ b/s390x/migration-sck.c
> @@ -0,0 +1,44 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * SET CLOCK migration tests
> + *
> + * Copyright IBM Corp. 2022
> + *
> + * Authors:
> + * Nico Boehr <nrb@linux.ibm.com>
> + */
> +
> +#include <libcflat.h>
> +#include <asm/time.h>
> +
> +static void test_sck_migration(void)
> +{
> + uint64_t now_before_set = 0, now_after_migration, time_to_set, time_to_advance;
> + int cc;
> +
> + stckf(&now_before_set);
> +
> + /* Advance the clock by a lot more than we might ever need to migrate (600s) */
> + time_to_advance = (600ULL * 1000000) << STCK_SHIFT_US;
> + time_to_set = now_before_set + time_to_advance;
> +
> + cc = sck(&time_to_set);
> + report(!cc, "setting clock succeeded");
I would also check here that the clock is set. This way we can
differentiate between a migration issue or a more general (and more
severe) clock issue. Even if we have this test somewhere else, this
makes it easier when debugging to narrow down the issue to migration.
> +
> + puts("Please migrate me, then press return\n");
> + (void)getchar();
> +
> + cc = stckf(&now_after_migration);
> + report(!cc, "clock still set");
> +
> + report(now_after_migration >= time_to_set, "TOD clock value preserved");
> +}
> +
> +int main(void)
> +{
> + report_prefix_push("migration-sck");
> +
> + test_sck_migration();
> + report_prefix_pop();
> + return report_summary();
> +}
> diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
> index f9f102abfa89..2c04ae7c7c15 100644
> --- a/s390x/unittests.cfg
> +++ b/s390x/unittests.cfg
> @@ -197,3 +197,7 @@ file = panic-loop-pgm.elf
> groups = panic
> accel = kvm
> timeout = 5
> +
> +[migration-sck]
> +file = migration-sck.elf
> +groups = migration
next prev parent reply other threads:[~2022-10-11 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 15:14 [kvm-unit-tests PATCH v2 0/2] s390x: Add migration test for guest TOD clock Nico Boehr
2022-10-11 15:14 ` [kvm-unit-tests PATCH v2 1/2] lib/s390x: move TOD clock related functions to library Nico Boehr
2022-10-11 15:41 ` Claudio Imbrenda
2022-10-11 15:14 ` [kvm-unit-tests PATCH v2 2/2] s390x: add migration TOD clock test Nico Boehr
2022-10-11 15:49 ` Claudio Imbrenda [this message]
2022-10-11 15:58 ` [kvm-unit-tests PATCH v2 0/2] s390x: Add migration test for guest TOD clock Christian Borntraeger
2022-10-11 16:10 ` Claudio Imbrenda
2022-10-11 16:15 ` Christian Borntraeger
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=20221011174912.1495d8c7@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=nrb@linux.ibm.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