hw/arm/allwinner-r40: add Clock Control Unit
[qemu/ar7.git] / migration / threadinfo.c
blob1de8b31855b04ff0655dd70823619e4eae8bf593
1 /*
2 * Migration Threads info
4 * Copyright (c) 2022 HUAWEI TECHNOLOGIES CO., LTD.
6 * Authors:
7 * Jiang Jiacheng <jiangjiacheng@huawei.com>
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.
13 #include "threadinfo.h"
15 static QLIST_HEAD(, MigrationThread) migration_threads;
17 MigrationThread *MigrationThreadAdd(const char *name, int thread_id)
19 MigrationThread *thread = g_new0(MigrationThread, 1);
20 thread->name = name;
21 thread->thread_id = thread_id;
23 QLIST_INSERT_HEAD(&migration_threads, thread, node);
25 return thread;
28 void MigrationThreadDel(MigrationThread *thread)
30 if (thread) {
31 QLIST_REMOVE(thread, node);
32 g_free(thread);
36 MigrationThreadInfoList *qmp_query_migrationthreads(Error **errp)
38 MigrationThreadInfoList *head = NULL;
39 MigrationThreadInfoList **tail = &head;
40 MigrationThread *thread = NULL;
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;
47 QAPI_LIST_APPEND(tail, info);
50 return head;