2 * Migration Threads info
4 * Copyright (c) 2022 HUAWEI TECHNOLOGIES CO., LTD.
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);
21 thread
->thread_id
= thread_id
;
23 QLIST_INSERT_HEAD(&migration_threads
, thread
, node
);
28 void MigrationThreadDel(MigrationThread
*thread
)
31 QLIST_REMOVE(thread
, node
);
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
);