Skip to contentSkip to conversation

vhost net support v3

PATCH New Lucas Meneghel Rodrigues 1 participant 3 messages Oct 8, 2010 KVM

lore
Share & tools
lore
#0 lore raw

cover vhost net support v3

The first patch of the series looks good, will be applied. The second one needs more care.

Lucas Meneghel Rodrigues (2):
KVM test: Use -device to add nic device when possible KVM test: Add vhost-net support

 client/tests/kvm/kvm_vm.py             |   40 ++++++++++++++++++++++++-------
 client/tests/kvm/tests_base.cfg.sample |    5 ++++
 2 files changed, 36 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/2 KVM test: Use -device to add nic device when possible

This patch tries to use "-device" to add nic device because recent qemu suggests to use it. A nic_extra_params was also introduced to add some advanced params to a nic (currently only availabe for virtio_net) such as mrg_rxbuf.

Changes from v2:
- Not needed to save lines in simple if clauses, do proper line break
- Rebase against latest HEAD

---
 client/tests/kvm/kvm_vm.py             |   33 +++++++++++++++++++++++++------
 client/tests/kvm/tests_base.cfg.sample |    3 ++
 2 files changed, 29 insertions(+), 7 deletions(-)
client/tests/kvm/kvm_vm.py +26 -7
index a473bb4..3388b14 100755
@@ -253,13 +253,31 @@ class VM:
             if boot: cmd += ",boot=on"
             return cmd
 
-        def add_nic(help, vlan, model=None, mac=None, netdev_id=None):
-            if has_option(help, "netdev"):
-                cmd = " -net nic,netdev=%s" % netdev_id
+        def add_nic(help, vlan, model=None, mac=None, netdev_id=None,
+                    nic_extra_params=None):
+            if has_option(help, "device"):
+                if model == "virtio":
+                    model="virtio-net-pci"
+                if not model:
+                    model= "rtl8139"
+                cmd = " -device %s" % model
+                if mac:
+                    cmd += ",mac=%s" % mac
+                if has_option(help, "netdev"):
+                    cmd += ",netdev=%s" % netdev_id
+                else:
+                    cmd += "vlan=%d,"  % vlan
+                if nic_extra_params:
+                    cmd += ",%s" % nic_extra_params
             else:
-                cmd = " -net nic,vlan=%d" % vlan
-            if model: cmd += ",model=%s" % model
-            if mac: cmd += ",macaddr='%s'" % mac
+                if has_option(help, "netdev"):
+                    cmd = " -net nic,netdev=%s" % netdev_id
+                else:
+                    cmd = " -net nic,vlan=%d" % vlan
+                if model:
+                    cmd += ",model=%s" % model
+                if mac:
+                    cmd += ",macaddr='%s'" % mac
             return cmd
 
         def add_net(help, vlan, mode, ifname=None, script=None,
@@ -414,7 +432,8 @@ class VM:
                                                      self.mac_prefix)
 
             qemu_cmd += add_nic(help, vlan, nic_params.get("nic_model"), mac,
-                                self.netdev_id[vlan])
+                                self.netdev_id[vlan],
+                                nic_params.get("nic_extra_params"))
             # Handle the '-net tap' or '-net user' part
             script = nic_params.get("nic_script")
             downscript = nic_params.get("nic_downscript")
client/tests/kvm/tests_base.cfg.sample +3 -0
index a524242..8d62c42 100644
@@ -699,6 +699,9 @@ 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
+        #nic_extra_params =
         jumbo:
             mtu = 65520
         ethtool:
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/2 KVM test: Add vhost-net support

In reply to Lucas Meneghel Rodrigues

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

Changes from v2:
- Rebase against latest HEAD

lmr - This one has problems so I'll hold on about applying this one.

---
 client/tests/kvm/kvm_vm.py             |    7 +++++--
 client/tests/kvm/tests_base.cfg.sample |    2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)
client/tests/kvm/kvm_vm.py +5 -2
index 3388b14..848ff63 100755
@@ -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
 
client/tests/kvm/tests_base.cfg.sample +2 -0
index 8d62c42..e849f31 100644
@@ -702,6 +702,8 @@ variants:
         # you can add advanced attributes on nic_extra_params
         # such as mrg_rxbuf
         #nic_extra_params =
+        # you can uncomment the following line to enable vhost-net backend
+        #vhost = yes
         jumbo:
             mtu = 65520
         ethtool:
Signature · 1 line
1.7.2.3