From: Igor Mammedov <imammedo@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [RFC PATCH] tests/qtest/migration: Add cpu hotplug test
Date: Wed, 15 Jan 2025 11:24:51 +0100 [thread overview]
Message-ID: <20250115112451.021e6aa2@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <20250113210833.1712-1-farosas@suse.de>
On Mon, 13 Jan 2025 18:08:33 -0300
Fabiano Rosas <farosas@suse.de> wrote:
> Bug #2594 is about a failure during migration after a cpu hotplug. Add
> a test that covers that scenario. Start the source with -smp 2 and
> destination with -smp 3, plug one extra cpu to match and migrate.
-smp on target should be the same as on source.
Instead use '-device hotplugged_cpu' with the same args as
in used device_add on target, to account for an extra cpu
>
> The issue seems to be a mismatch in the number of virtqueues between
> the source and destination due to the hotplug not changing the
> num_queues:
>
> get_pci_config_device: Bad config data: i=0x9a read: 4 device: 5
> cmask: ff wmask: 0 w1cmask:0
>
> Usage:
> $ QTEST_QEMU_IMG=./qemu-img QTEST_QEMU_BINARY=./qemu-system-x86_64 \
> ./tests/qtest/migration-test -p /x86_64/migration/hotplug/cpu
>
> References: https://gitlab.com/qemu-project/qemu/-/issues/2594
> References: https://issues.redhat.com/browse/RHEL-68302
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> As you can see there's no fix attached to this. I haven't reached that
> part yet, suggestions welcome =). Posting the test case if anyone
> wants to play with this.
>
> (if someone at RH is already working on this, that's fine. I'm just
> trying to get some upstream bugs to move)
> ---
> tests/qtest/migration/misc-tests.c | 76 ++++++++++++++++++++++++++++++
> 1 file changed, 76 insertions(+)
>
> diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/misc-tests.c
> index 6173430748..bde567b124 100644
> --- a/tests/qtest/migration/misc-tests.c
> +++ b/tests/qtest/migration/misc-tests.c
> @@ -251,6 +251,79 @@ static void test_validate_uri_channels_none_set(void)
> do_test_validate_uri_channel(&args);
> }
>
> +static void test_cpu_hotplug_virtqueues(void)
> +{
> + MigrateStart args = {
> + .hide_stderr = false,
> + };
> + QTestState *from, *to;
> + g_autofree char *device_virtio_scsi = NULL;
> + g_autofree char *device_virtio_blk = NULL;
> + g_autofree char *filename_scsi = g_strdup_printf("%s/qtest_disk0.qcow2", tmpfs);
> + g_autofree char *filename_blk = g_strdup_printf("%s/qtest_disk1.qcow2", tmpfs);
> +
> + /*
> + * Matching the queues between src/dst allows the test to pass.
> + * Defaults are:
> + * virtio-scsi-pci: #vcpus + 2 queues that are always present.
> + * virtio-blk-pci: same number of queues as vcpus.
> + * See virtio_pci_optimal_num_queues() for the exact computation.
> + */
> + bool match_queues = false;
> + const char *qs_scsi = "num_queues=5";
> + const char *qs_blk = "num-queues=3"; /* _ vs. - is not a mistake */
> +
> + g_assert(mkimg(filename_scsi, "qcow2", 1));
> + g_assert(mkimg(filename_blk, "qcow2", 1));
> +
> + device_virtio_scsi = g_strdup_printf(
> + "-drive id=drive0,if=none,format=qcow2,file=%s "
> + "-device virtio-scsi-pci,id=scsi0,%s "
> + "-device scsi-hd,drive=drive0,bus=scsi0.0 ",
> + filename_scsi, match_queues ? qs_scsi : "");
> +
> + device_virtio_blk = g_strdup_printf(
> + "-drive id=drive1,if=none,format=qcow2,file=%s "
> + "-device virtio-blk-pci,drive=drive1,id=blk0,%s ",
> + filename_blk, match_queues ? qs_blk : "");
> +
> + /* The missing cpu will be hotplugged before migration */
> + args.opts_source = g_strconcat("-smp 2,threads=1,sockets=1,maxcpus=4 ",
> + device_virtio_scsi,
> + device_virtio_blk, NULL);
> +
> + args.opts_target = g_strconcat("-smp 3,threads=1,sockets=1,maxcpus=4 ",
> + device_virtio_scsi,
> + device_virtio_blk, NULL);
> +
> + if (migrate_start(&from, &to, "defer", &args)) {
> + return;
> + }
> +
> + g_free((char *)args.opts_source);
> + g_free((char *)args.opts_target);
> +
> +
> + migrate_ensure_converge(from);
> + wait_for_serial("src_serial");
> +
> + qtest_qmp_assert_success(from, "{ 'execute': 'device_add',"
> + " 'arguments': { "
> + " 'node-id': 0, 'socket-id': 0,"
> + " 'core-id': 2, 'thread-id': 0,"
> + " 'id': {},"
> + " 'driver': 'qemu64-x86_64-cpu' } }");
> +
> + migrate_incoming_qmp(to, "tcp:127.0.0.1:0", "{}");
> +
> + migrate_qmp(from, to, NULL, NULL, "{}");
> + wait_for_migration_complete(from);
> +
> + migrate_end(from, to, true);
> + unlink(filename_scsi);
> + unlink(filename_blk);
> +}
> +
> void migration_test_add_misc(MigrationTestEnv *env)
> {
> tmpfs = env->tmpfs;
> @@ -279,4 +352,7 @@ void migration_test_add_misc(MigrationTestEnv *env)
> test_validate_uri_channels_both_set);
> migration_test_add("/migration/validate_uri/channels/none_set",
> test_validate_uri_channels_none_set);
> +
> + migration_test_add("/migration/hotplug/cpu/virtqueues",
> + test_cpu_hotplug_virtqueues);
> }
next prev parent reply other threads:[~2025-01-15 10:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 21:08 [RFC PATCH] tests/qtest/migration: Add cpu hotplug test Fabiano Rosas
2025-01-14 13:44 ` Stefan Hajnoczi
2025-01-14 14:15 ` Fabiano Rosas
2025-01-14 19:28 ` Stefan Hajnoczi
2025-01-14 20:15 ` Peter Xu
2025-01-14 21:14 ` Stefan Hajnoczi
2025-01-14 21:52 ` Peter Xu
2025-01-15 10:24 ` Igor Mammedov [this message]
2025-01-15 12:53 ` Fabiano Rosas
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=20250115112451.021e6aa2@imammedo.users.ipa.redhat.com \
--to=imammedo@redhat.com \
--cc=farosas@suse.de \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--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 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.