The current syntax when defining a NIC uses a pair of arguments, like this:

-net tap,vlan=0 -net nic,vlan=0,model=virtio

When using this pair, internally KVM will create a VLANState structure to send
ethernet frames between the guest NIC and the host tap device. This is
suboptimal and is going to be removed in the future. Plus, this combination
breaks vhost-net support.

The new syntax does not need the vlan craziness anymore, creating a direct 1:1
relationship between the backend device and the frontend device.

-netdev tap,id=netdev0 -device 
virtio-net-pci,macaddr=52:54:00:56:6c:55,netdev=netdev0

Signed-off-by: Miguel Di Ciurcio Filho <[email protected]>
---
 lib/hypervisor/hv_kvm.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index d2ac24c..e7a4a5b 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -730,18 +730,18 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       tap_extra = ""
       nic_type = up_hvp[constants.HV_NIC_TYPE]
       if nic_type == constants.HT_NIC_PARAVIRTUAL:
-        nic_model = "model=virtio"
+        nic_model = "virtio-net-pci"
         if up_hvp[constants.HV_VHOST_NET]:
           tap_extra = ",vhost=on"
       else:
-        nic_model = "model=%s" % nic_type
+        nic_model = nic_type
 
       for nic_seq, nic in enumerate(kvm_nics):
-        nic_val = "nic,vlan=%s,macaddr=%s,%s" % (nic_seq, nic.mac, nic_model)
+        nic_val = "%s,macaddr=%s,netdev=netdev%s" % (nic_model, nic.mac, 
nic_seq)
         script = self._WriteNetScriptFile(instance, nic_seq, nic)
-        tap_val = "tap,vlan=%s,script=%s%s" % (nic_seq, script, tap_extra)
-        kvm_cmd.extend(["-net", nic_val])
-        kvm_cmd.extend(["-net", tap_val])
+        tap_val = "type=tap,id=netdev%s,script=%s%s" % (nic_seq, script, 
tap_extra)
+        kvm_cmd.extend(["-netdev", tap_val])
+        kvm_cmd.extend(["-device", nic_val])
         temp_files.append(script)
 
     if incoming:
-- 
1.7.1

Reply via email to