From 37f88dc6c2fe472abcf694cecb3531bdba1e41a8 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 9 Feb 2009 15:16:47 +0000
Subject: [PATCH] KVM: actually support different nic types

When executing the KVM runtime we load the nic type from the runtime
hvparams and use it to specify the nic model type. As for the disk we
translate the DEV_PARAVIRTUAL type to 'virtio'.

Reviewed-by: iustinp
---
 lib/hypervisor/hv_kvm.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 9baf279f2..24c271d56 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -393,8 +393,14 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if not kvm_nics:
       kvm_cmd.extend(['-net', 'none'])
     else:
+      nic_type = hvparams[constants.HV_NIC_TYPE]
+      if nic_type == constants.HT_NIC_PARAVIRTUAL:
+        nic_model = "model=virtio"
+      else:
+        nic_model = "model=%s" % nic_type
+
       for nic_seq, nic in enumerate(kvm_nics):
-        nic_val = "nic,macaddr=%s,model=virtio" % nic.mac
+        nic_val = "nic,macaddr=%s,%s" % (nic.mac, nic_model)
         script = self._WriteNetScript(instance, nic_seq, nic)
         kvm_cmd.extend(['-net', nic_val])
         kvm_cmd.extend(['-net', 'tap,script=%s' % script])
-- 
GitLab