]>
Commit | Line | Data |
---|---|---|
67132620 JJ |
1 | /* |
2 | * Migration Threads info | |
3 | * | |
4 | * Copyright (c) 2022 HUAWEI TECHNOLOGIES CO., LTD. | |
5 | * | |
6 | * Authors: | |
7 | * Jiang Jiacheng <jiangjiacheng@huawei.com> | |
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 | } |