Skip to content

Commit 6713262

Browse files
Jiang JiachengJuan Quintela
Jiang Jiacheng
authored and
Juan Quintela
committed
migration: Introduce interface query-migrationthreads
Introduce interface query-migrationthreads. The interface is used to query information about migration threads and returns with migration thread's name and its id. Introduce threadinfo.c to manage threads with migration. Signed-off-by: Jiang Jiacheng <[email protected]> Reviewed-by: Juan Quintela <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
1 parent ebfc578 commit 6713262

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

migration/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ softmmu_ss.add(files(
2626
'savevm.c',
2727
'socket.c',
2828
'tls.c',
29+
'threadinfo.c',
2930
), gnutls)
3031

3132
softmmu_ss.add(when: rdma, if_true: files('rdma.c'))

migration/threadinfo.c

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Migration Threads info
3+
*
4+
* Copyright (c) 2022 HUAWEI TECHNOLOGIES CO., LTD.
5+
*
6+
* Authors:
7+
* Jiang Jiacheng <[email protected]>
8+
*
9+
* This work is licensed under the terms of the GNU GPL, version 2 or later.
10+
* See the COPYING file in the top-level directory.
11+
*/
12+
13+
#include "threadinfo.h"
14+
15+
static QLIST_HEAD(, MigrationThread) migration_threads;
16+
17+
MigrationThread *MigrationThreadAdd(const char *name, int thread_id)
18+
{
19+
MigrationThread *thread = g_new0(MigrationThread, 1);
20+
thread->name = name;
21+
thread->thread_id = thread_id;
22+
23+
QLIST_INSERT_HEAD(&migration_threads, thread, node);
24+
25+
return thread;
26+
}
27+
28+
void MigrationThreadDel(MigrationThread *thread)
29+
{
30+
if (thread) {
31+
QLIST_REMOVE(thread, node);
32+
g_free(thread);
33+
}
34+
}
35+
36+
MigrationThreadInfoList *qmp_query_migrationthreads(Error **errp)
37+
{
38+
MigrationThreadInfoList *head = NULL;
39+
MigrationThreadInfoList **tail = &head;
40+
MigrationThread *thread = NULL;
41+
42+
QLIST_FOREACH(thread, &migration_threads, node) {
43+
MigrationThreadInfo *info = g_new0(MigrationThreadInfo, 1);
44+
info->name = g_strdup(thread->name);
45+
info->thread_id = thread->thread_id;
46+
47+
QAPI_LIST_APPEND(tail, info);
48+
}
49+
50+
return head;
51+
}

migration/threadinfo.h

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Migration Threads info
3+
*
4+
* Copyright (c) 2022 HUAWEI TECHNOLOGIES CO., LTD.
5+
*
6+
* Authors:
7+
* Jiang Jiacheng <[email protected]>
8+
*
9+
* This work is licensed under the terms of the GNU GPL, version 2 or later.
10+
* See the COPYING file in the top-level directory.
11+
*/
12+
13+
#include "qemu/queue.h"
14+
#include "qemu/osdep.h"
15+
#include "qapi/error.h"
16+
#include "qapi/qapi-commands-migration.h"
17+
18+
typedef struct MigrationThread MigrationThread;
19+
20+
struct MigrationThread {
21+
const char *name; /* the name of migration thread */
22+
int thread_id; /* ID of the underlying host thread */
23+
QLIST_ENTRY(MigrationThread) node;
24+
};
25+
26+
MigrationThread *MigrationThreadAdd(const char *name, int thread_id);
27+
28+
void MigrationThreadDel(MigrationThread *info);

qapi/migration.json

+29
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,35 @@
19581958
{ 'command': 'query-vcpu-dirty-limit',
19591959
'returns': [ 'DirtyLimitInfo' ] }
19601960

1961+
##
1962+
# @MigrationThreadInfo:
1963+
#
1964+
# Information about migrationthreads
1965+
#
1966+
# @name: the name of migration thread
1967+
#
1968+
# @thread-id: ID of the underlying host thread
1969+
#
1970+
# Since: 7.2
1971+
##
1972+
{ 'struct': 'MigrationThreadInfo',
1973+
'data': {'name': 'str',
1974+
'thread-id': 'int'} }
1975+
1976+
##
1977+
# @query-migrationthreads:
1978+
#
1979+
# Returns information of migration threads
1980+
#
1981+
# data: migration thread name
1982+
#
1983+
# returns: information about migration threads
1984+
#
1985+
# Since: 7.2
1986+
##
1987+
{ 'command': 'query-migrationthreads',
1988+
'returns': ['MigrationThreadInfo'] }
1989+
19611990
##
19621991
# @snapshot-save:
19631992
#

0 commit comments

Comments
 (0)