Commit-ID: b5afaf5516d8f3bcbd833de9cfe4ebccb6557163 Gitweb: http://git.kernel.org/tip/b5afaf5516d8f3bcbd833de9cfe4ebccb6557163 Author: Suzuki K. Poulose <suzuki.poulose@xxxxxxx> AuthorDate: Tue, 16 Dec 2014 18:18:00 +0000 Committer: Will Deacon <will.deacon@xxxxxxx> CommitDate: Wed, 17 Dec 2014 10:48:53 +0000 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 K. Poulose <suzuki.poulose@xxxxxxx> Acked-by: Will Deacon <will.deacon@xxxxxxx> Signed-off-by: Will Deacon <will.deacon@xxxxxxx> --- tools/kvm/include/kvm/virtio.h | 1 + tools/kvm/virtio/core.c | 9 +++++++++ tools/kvm/virtio/net.c | 21 +++++++++++++++------ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h index 8a9eab5..768ee96 100644 --- a/tools/kvm/include/kvm/virtio.h +++ b/tools/kvm/include/kvm/virtio.h @@ -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) { diff --git a/tools/kvm/virtio/core.c b/tools/kvm/virtio/core.c index 9ae7887..3b6e4d7 100644 --- a/tools/kvm/virtio/core.c +++ b/tools/kvm/virtio/core.c @@ -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; diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index c8af385..ecdb94e 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -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); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |