mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-15 18:05:49 +00:00
27cead0dd2
---------
Before:
---------
*** Compatibility Warning ***
virtio-blk device was not detected
While you have requested a virtio-blk device, the guest kernel did not initialize it.
Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_BLK=y enabled in its .config
*** Compatibility Warning ***
virtio-net device was not detected
While you have requested a virtio-net device, the guest kernel did not initialize it.
Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_NET=y enabled in its .config
# KVM session ended normally.
---------
After:
---------
# KVM compatibility warning.
virtio-blk device was not detected.
While you have requested a virtio-blk device, the guest kernel did not initialize it.
Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_BLK=y enabled in .config.
# KVM compatibility warning.
virtio-net device was not detected.
While you have requested a virtio-net device, the guest kernel did not initialize it.
Please make sure that the guest kernel was compiled with CONFIG_VIRTIO_NET=y enabled in .config.
# KVM session ended normally.
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
100 lines
1.5 KiB
C
100 lines
1.5 KiB
C
#include "kvm/guest_compat.h"
|
|
|
|
#include "kvm/mutex.h"
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/list.h>
|
|
|
|
struct compat_message {
|
|
int id;
|
|
char *title;
|
|
char *desc;
|
|
|
|
struct list_head list;
|
|
};
|
|
|
|
static int id;
|
|
static DEFINE_MUTEX(compat_mtx);
|
|
static LIST_HEAD(messages);
|
|
|
|
static void compat__free(struct compat_message *msg)
|
|
{
|
|
free(msg->title);
|
|
free(msg->desc);
|
|
free(msg);
|
|
}
|
|
|
|
int compat__add_message(const char *title, const char *desc)
|
|
{
|
|
struct compat_message *msg;
|
|
int msg_id;
|
|
|
|
msg = malloc(sizeof(*msg));
|
|
if (msg == NULL)
|
|
goto cleanup;
|
|
|
|
msg->title = strdup(title);
|
|
msg->desc = strdup(desc);
|
|
|
|
if (msg->title == NULL || msg->desc == NULL)
|
|
goto cleanup;
|
|
|
|
mutex_lock(&compat_mtx);
|
|
|
|
msg->id = msg_id = id++;
|
|
list_add_tail(&msg->list, &messages);
|
|
|
|
mutex_unlock(&compat_mtx);
|
|
|
|
return msg_id;
|
|
|
|
cleanup:
|
|
if (msg)
|
|
compat__free(msg);
|
|
|
|
return -ENOMEM;
|
|
}
|
|
|
|
int compat__remove_message(int id)
|
|
{
|
|
struct compat_message *pos, *n;
|
|
|
|
mutex_lock(&compat_mtx);
|
|
|
|
list_for_each_entry_safe(pos, n, &messages, list) {
|
|
if (pos->id == id) {
|
|
list_del(&pos->list);
|
|
compat__free(pos);
|
|
|
|
mutex_unlock(&compat_mtx);
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
mutex_unlock(&compat_mtx);
|
|
|
|
return -ENOENT;
|
|
}
|
|
|
|
int compat__print_all_messages(void)
|
|
{
|
|
mutex_lock(&compat_mtx);
|
|
|
|
while (!list_empty(&messages)) {
|
|
struct compat_message *msg;
|
|
|
|
msg = list_first_entry(&messages, struct compat_message, list);
|
|
|
|
printf("\n # KVM compatibility warning.\n\t%s\n\t%s\n",
|
|
msg->title, msg->desc);
|
|
|
|
list_del(&msg->list);
|
|
compat__free(msg);
|
|
}
|
|
|
|
mutex_unlock(&compat_mtx);
|
|
|
|
return 0;
|
|
}
|