Commit dc7a55d6 authored by Suzuki Poulose's avatar Suzuki Poulose Committed by Will Deacon
Browse files

Use the arch default transport method for network



lkvm by default sets up a virtio-pci transport for network, if none is
specified. This can be a problem on archs (e.g ARM64), where virtio-pci is
not supported yet and cause the following warning at exit.

  # KVM compatibility warning.
	virtio-net device was not detected.

This patch changes it to make use of the default transport method for the
architecture when none is specified. This will ensure that on every arch
we get the network up by default in the VM.

Signed-off-by: Suzuki Poulose's avatarSuzuki K. Poulose <suzuki.poulose@arm.com>
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent c2dad402
......@@ -160,6 +160,7 @@ 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);
const char* virtio_trans_name(enum virtio_trans trans);
static inline void *virtio_get_vq(struct kvm *kvm, u32 pfn, u32 page_size)
{
......
......@@ -12,6 +12,15 @@
#include "kvm/kvm.h"
const char* virtio_trans_name(enum virtio_trans trans)
{
if (trans == VIRTIO_PCI)
return "pci";
else if (trans == VIRTIO_MMIO)
return "mmio";
return "unknown";
}
struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len)
{
struct vring_used_elem *used_elem;
......
......@@ -758,6 +758,7 @@ static int virtio_net__init_one(struct virtio_net_params *params)
int i, err;
struct net_dev *ndev;
struct virtio_ops *ops;
enum virtio_trans trans = VIRTIO_DEFAULT_TRANS(params->kvm);
ndev = calloc(1, sizeof(struct net_dev));
if (ndev == NULL)
......@@ -799,12 +800,20 @@ static int virtio_net__init_one(struct virtio_net_params *params)
}
*ops = net_dev_virtio_ops;
if (params->trans && strcmp(params->trans, "mmio") == 0)
virtio_init(params->kvm, ndev, &ndev->vdev, ops, VIRTIO_MMIO,
PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
else
virtio_init(params->kvm, ndev, &ndev->vdev, ops, VIRTIO_PCI,
PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
if (params->trans) {
if (strcmp(params->trans, "mmio") == 0)
trans = VIRTIO_MMIO;
else if (strcmp(params->trans, "pci") == 0)
trans = VIRTIO_PCI;
else
pr_warning("virtio-net: Unknown transport method : %s, "
"falling back to %s.", params->trans,
virtio_trans_name(trans));
}
virtio_init(params->kvm, ndev, &ndev->vdev, ops, trans,
PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
if (params->vhost)
virtio_net__vhost_init(params->kvm, ndev);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment