[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V6 18/24] tests/qtest: optimize migrate_set_ports
From: |
Steve Sistare |
Subject: |
[PATCH V6 18/24] tests/qtest: optimize migrate_set_ports |
Date: |
Tue, 14 Jan 2025 09:23:48 -0800 |
Do not query connection parameters if all port numbers are known. This is
more efficient, and also solves a problem for the cpr-transfer test.
At the point where cpr-transfer calls migrate_qmp and migrate_set_ports,
the monitor is not connected and queries are not allowed. Port=0 is
never used for cpr-transfer.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
tests/qtest/migration/migration-util.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/tests/qtest/migration/migration-util.c
b/tests/qtest/migration/migration-util.c
index 526bed7..0ce1413 100644
--- a/tests/qtest/migration/migration-util.c
+++ b/tests/qtest/migration/migration-util.c
@@ -135,25 +135,32 @@ migrate_get_connect_qdict(QTestState *who)
void migrate_set_ports(QTestState *to, QList *channel_list)
{
- QDict *addr;
+ g_autoptr(QDict) addr = NULL;
QListEntry *entry;
const char *addr_port = NULL;
- addr = migrate_get_connect_qdict(to);
-
QLIST_FOREACH_ENTRY(channel_list, entry) {
QDict *channel = qobject_to(QDict, qlist_entry_obj(entry));
QDict *addrdict = qdict_get_qdict(channel, "addr");
- if (qdict_haskey(addrdict, "port") &&
- qdict_haskey(addr, "port") &&
- (strcmp(qdict_get_str(addrdict, "port"), "0") == 0)) {
+ if (!qdict_haskey(addrdict, "port") ||
+ strcmp(qdict_get_str(addrdict, "port"), "0")) {
+ continue;
+ }
+
+ /*
+ * Fetch addr only if needed, so tests that are not yet connected to
+ * the monitor do not query it. Such tests cannot use port=0.
+ */
+ if (!addr) {
+ addr = migrate_get_connect_qdict(to);
+ }
+
+ if (qdict_haskey(addr, "port")) {
addr_port = qdict_get_str(addr, "port");
qdict_put_str(addrdict, "port", addr_port);
}
}
-
- qobject_unref(addr);
}
bool migrate_watch_for_events(QTestState *who, const char *name,
--
1.8.3.1
- [PATCH V6 05/24] memory: add RAM_PRIVATE, (continued)
- [PATCH V6 05/24] memory: add RAM_PRIVATE, Steve Sistare, 2025/01/14
- [PATCH V6 03/24] physmem: qemu_ram_alloc_from_fd extensions, Steve Sistare, 2025/01/14
- [PATCH V6 02/24] physmem: fix qemu_ram_alloc_from_fd size calculation, Steve Sistare, 2025/01/14
- [PATCH V6 04/24] physmem: fd-based shared memory, Steve Sistare, 2025/01/14
- [PATCH V6 07/24] migration: cpr-state, Steve Sistare, 2025/01/14
- [PATCH V6 06/24] machine: aux-ram-share option, Steve Sistare, 2025/01/14
- [PATCH V6 09/24] hostmem-memfd: preserve for cpr, Steve Sistare, 2025/01/14
- [PATCH V6 08/24] physmem: preserve ram blocks for cpr, Steve Sistare, 2025/01/14
- [PATCH V6 10/24] hostmem-shm: preserve for cpr, Steve Sistare, 2025/01/14
- [PATCH V6 18/24] tests/qtest: optimize migrate_set_ports,
Steve Sistare <=
- [PATCH V6 12/24] migration: incoming channel, Steve Sistare, 2025/01/14
- [PATCH V6 20/24] migration-test: defer connection, Steve Sistare, 2025/01/14
- [PATCH V6 24/24] migration: cpr-transfer documentation, Steve Sistare, 2025/01/14
- [PATCH V6 11/24] migration: enhance migrate_uri_parse, Steve Sistare, 2025/01/14
- [PATCH V6 22/24] tests/qtest: assert qmp connected, Steve Sistare, 2025/01/14
- [PATCH V6 16/24] migration: cpr-transfer mode, Steve Sistare, 2025/01/14
- [PATCH V6 13/24] migration: SCM_RIGHTS for QEMUFile, Steve Sistare, 2025/01/14
- [PATCH V6 17/24] migration-test: memory_backend, Steve Sistare, 2025/01/14
- [PATCH V6 14/24] migration: VMSTATE_FD, Steve Sistare, 2025/01/14