kvm tools: Introduce trans=mmio parameter for virtio-net

To select virtio-mmio instead of virito-pci transport:

   lkvm run --network trans=mmio

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
Asias He
2015-06-01 16:39:51 +01:00
committed by Will Deacon
parent 755752d63b
commit 69205aa12b
3 changed files with 9 additions and 2 deletions
+2
View File
@@ -244,6 +244,8 @@ static int set_net_param(struct virtio_net_params *p, const char *param,
p->guest_ip = strdup(val);
} else if (strcmp(param, "host_ip") == 0) {
p->host_ip = strdup(val);
} else if (strcmp(param, "trans") == 0) {
p->trans = strdup(val);
} else if (strcmp(param, "vhost") == 0) {
p->vhost = atoi(val);
} else if (strcmp(param, "fd") == 0) {
+1
View File
@@ -7,6 +7,7 @@ struct virtio_net_params {
const char *guest_ip;
const char *host_ip;
const char *script;
const char *trans;
char guest_mac[6];
char host_mac[6];
struct kvm *kvm;
+6 -2
View File
@@ -526,8 +526,12 @@ void virtio_net__init(const struct virtio_net_params *params)
ndev->ops = &uip_ops;
}
virtio_init(kvm, ndev, &ndev->vdev, &net_dev_virtio_ops,
VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
if (params->trans && strcmp(params->trans, "mmio") == 0)
virtio_init(kvm, ndev, &ndev->vdev, &net_dev_virtio_ops,
VIRTIO_MMIO, PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
else
virtio_init(kvm, ndev, &ndev->vdev, &net_dev_virtio_ops,
VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_NET, VIRTIO_ID_NET, PCI_CLASS_NET);
if (params->vhost)
virtio_net__vhost_init(params->kvm, ndev);