[PATCH] KVM test: Add vhost-net support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vhost is a kernel-level backend for virtio. This patch add a nic_param
named "vhost" to enable/disable vhost backend.

Changes from v3:
- Added comment explaining that the feature only works with nic_mode =
  tap.
- Instead of commenting out the option vhost, leave it uncommented but
  with default = no.

Changes from v2:
- Rebase against latest HEAD

Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
---
 client/tests/kvm/kvm_vm.py             |    7 +++++--
 client/tests/kvm/tests_base.cfg.sample |    6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 3388b14..848ff63 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -282,9 +282,11 @@ class VM:
 
         def add_net(help, vlan, mode, ifname=None, script=None,
                     downscript=None, tftp=None, bootfile=None, hostfwd=[],
-                    netdev_id=None):
+                    netdev_id=None, vhost=False):
             if has_option(help, "netdev"):
                 cmd = " -netdev %s,id=%s" % (mode, netdev_id)
+                if vhost:
+                    cmd +=",vhost=on"
             else:
                 cmd = " -net %s,vlan=%d" % (mode, vlan)
             if mode == "tap":
@@ -448,7 +450,8 @@ class VM:
                                 self.get_ifname(vlan),
                                 script, downscript, tftp,
                                 nic_params.get("bootp"), redirs,
-                                self.netdev_id[vlan])
+                                self.netdev_id[vlan],
+                                nic_params.get("vhost")=="yes")
             # Proceed to next NIC
             vlan += 1
 
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 8d62c42..769d750 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -699,9 +699,11 @@ variants:
                 supported_features = "tx rx sg tso gso gro lro"
     - virtio_net:
         nic_model = virtio
-        # you can add advanced attributes on nic_extra_params
-        # such as mrg_rxbuf
+        # You can add advanced attributes on nic_extra_params such as mrg_rxbuf
         #nic_extra_params =
+        # You can set vhost = yes to enable the vhost kernel backend
+        # (This only works if nic_mode=tap)
+        vhost = no
         jumbo:
             mtu = 65520
         ethtool:
-- 
1.7.2.3

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux