1 #include "kvm/guest_compat.h"
5 #include <linux/kernel.h>
6 #include <linux/list.h>
8 struct compat_message
{
13 struct list_head list
;
17 static DEFINE_MUTEX(compat_mtx
);
18 static LIST_HEAD(messages
);
20 int compat__add_message(const char *title
, const char *desc
)
22 struct compat_message
*msg
;
24 mutex_lock(&compat_mtx
);
25 msg
= malloc(sizeof(*msg
));
29 *msg
= (struct compat_message
) {
31 .title
= strdup(title
),
35 if (msg
->title
== NULL
|| msg
->desc
== NULL
)
38 list_add_tail(&msg
->list
, &messages
);
40 mutex_unlock(&compat_mtx
);
51 mutex_unlock(&compat_mtx
);
56 static void compat__free(struct compat_message
*msg
)
63 int compat__remove_message(int id
)
65 struct compat_message
*pos
, *n
;
67 mutex_lock(&compat_mtx
);
69 list_for_each_entry_safe(pos
, n
, &messages
, list
) {
74 mutex_unlock(&compat_mtx
);
80 mutex_unlock(&compat_mtx
);
85 int compat__print_all_messages(void)
87 mutex_lock(&compat_mtx
);
89 while (!list_empty(&messages
)) {
90 struct compat_message
*msg
;
92 msg
= list_first_entry(&messages
, struct compat_message
, list
);
94 printf("\n\n*** Compatability Warning ***\n\n\t%s\n\n%s\n",
95 msg
->title
, msg
->desc
);
101 mutex_unlock(&compat_mtx
);