From: Asias He <[email protected]>

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

   lkvm run --network trans=mmio

Signed-off-by: Asias He <[email protected]>
---
 tools/kvm/builtin-run.c            |    2 ++
 tools/kvm/include/kvm/virtio-net.h |    1 +
 tools/kvm/virtio/net.c             |    8 ++++++--
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 33be3bd..97f61d0 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -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) {
diff --git a/tools/kvm/include/kvm/virtio-net.h 
b/tools/kvm/include/kvm/virtio-net.h
index a3219b6..ebcd77f 100644
--- a/tools/kvm/include/kvm/virtio-net.h
+++ b/tools/kvm/include/kvm/virtio-net.h
@@ -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;
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index 33bf623..d523f61 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -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);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to