int virtio_init(struct kvm *kvm, void *dev, struct virtio_device *vdev,
struct virtio_ops *ops, enum virtio_trans trans,
int device_id, int subsys_id, int class);
+int virtio_compat_add_message(const char *device, const char *config);
#endif /* KVM__VIRTIO_H */
list_add(&p9dev->list, &devs);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-9p device was not detected",
- "While you have requested a virtio-9p device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_NET_9P_VIRTIO=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-9p", "CONFIG_NET_9P_VIRTIO");
return err;
VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_BLN, VIRTIO_ID_BALLOON, PCI_CLASS_BLN);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-balloon device was not detected",
- "While you have requested a virtio-balloon device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_VIRTIO_BALLOON=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-balloon", "CONFIG_VIRTIO_BALLOON");
}
disk_image__set_callback(bdev->disk, virtio_blk_complete);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-blk device was not detected",
- "While you have requested a virtio-blk device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_VIRTIO_BLK=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-blk", "CONFIG_VIRTIO_BLK");
return 0;
}
virtio_init(kvm, &cdev, &cdev.vdev, &con_dev_virtio_ops,
VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_CONSOLE, VIRTIO_ID_CONSOLE, PCI_CLASS_CONSOLE);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-console device was not detected",
- "While you have requested a virtio-console device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_VIRTIO_CONSOLE=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-console", "CONFIG_VIRTIO_CONSOLE");
}
#include <sys/uio.h>
#include <stdlib.h>
+#include "kvm/guest_compat.h"
#include "kvm/barrier.h"
#include "kvm/virtio.h"
#include "kvm/virtio-pci.h"
return 0;
}
+
+int virtio_compat_add_message(const char *device, const char *config)
+{
+ int len = 1024;
+ int compat_id;
+ char *title;
+ char *desc;
+
+ title = malloc(len);
+ if (!title)
+ return -ENOMEM;
+
+ desc = malloc(len);
+ if (!desc) {
+ free(title);
+ return -ENOMEM;
+ }
+
+ snprintf(title, len, "%s device was not detected", device);
+ snprintf(desc, len, "While you have requested a %s device, "
+ "the guest kernel did not initialize it.\n"
+ "Please make sure that the guest kernel was "
+ "compiled with %s=y enabled in its .config",
+ device, config);
+
+ compat_id = compat__add_message(title, desc);
+
+ free(desc);
+ free(title);
+
+ return compat_id;
+}
virtio_net__io_thread_init(params->kvm, ndev);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-net device was not detected",
- "While you have requested a virtio-net device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_VIRTIO_NET=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-net", "CONFIG_VIRTIO_NET");
}
list_add_tail(&rdev->list, &rdevs);
if (compat_id != -1)
- compat_id = compat__add_message("virtio-rng device was not detected",
- "While you have requested a virtio-rng device, "
- "the guest kernel did not initialize it.\n"
- "Please make sure that the guest kernel was "
- "compiled with CONFIG_HW_RANDOM_VIRTIO=y enabled "
- "in its .config");
+ compat_id = virtio_compat_add_message("virtio-rng", "CONFIG_HW_RANDOM_VIRTIO");
return 0;
cleanup:
close(rdev->fd);