Revision 049383d9
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
724 | 724 |
|
725 | 725 |
kvm_version = self._GetKVMVersion() |
726 | 726 |
if kvm_version: |
727 |
_, v_major, v_min, v_rev = kvm_version
|
|
727 |
_, v_major, v_min, _ = kvm_version
|
|
728 | 728 |
else: |
729 | 729 |
raise errors.HypervisorError("Unable to get KVM version") |
730 | 730 |
|
... | ... | |
744 | 744 |
nic_type = up_hvp[constants.HV_NIC_TYPE] |
745 | 745 |
if nic_type == constants.HT_NIC_PARAVIRTUAL: |
746 | 746 |
# From version 0.12.0, kvm uses a new sintax for network configuration. |
747 |
if (v_major, v_min) >= (0,12): |
|
747 |
if (v_major, v_min) >= (0, 12):
|
|
748 | 748 |
nic_model = "virtio-net-pci" |
749 | 749 |
else: |
750 | 750 |
nic_model = "virtio" |
751 | 751 |
|
752 | 752 |
if up_hvp[constants.HV_VHOST_NET]: |
753 | 753 |
# vhost_net is only available from version 0.13.0 or newer |
754 |
if (v_major, v_min) >= (0,13): |
|
754 |
if (v_major, v_min) >= (0, 13):
|
|
755 | 755 |
tap_extra = ",vhost=on" |
756 | 756 |
else: |
757 | 757 |
raise errors.HypervisorError("vhost_net is configured" |
... | ... | |
762 | 762 |
for nic_seq, nic in enumerate(kvm_nics): |
763 | 763 |
script = self._WriteNetScriptFile(instance, nic_seq, nic) |
764 | 764 |
temp_files.append(script) |
765 |
if (v_major, v_min) >= (0,12): |
|
765 |
if (v_major, v_min) >= (0, 12):
|
|
766 | 766 |
nic_val = "%s,mac=%s,netdev=netdev%s" % (nic_model, nic.mac, nic_seq) |
767 |
tap_val = "type=tap,id=netdev%s,script=%s%s" % (nic_seq, script, tap_extra) |
|
767 |
tap_val = "type=tap,id=netdev%s,script=%s%s" % (nic_seq, |
|
768 |
script, tap_extra) |
|
768 | 769 |
kvm_cmd.extend(["-netdev", tap_val, "-device", nic_val]) |
769 | 770 |
else: |
770 |
nic_val = "nic,vlan=%s,macaddr=%s,model=%s" % (nic_seq, nic.mac, nic_model) |
|
771 |
nic_val = "nic,vlan=%s,macaddr=%s,model=%s" % (nic_seq, |
|
772 |
nic.mac, nic_model) |
|
771 | 773 |
tap_val = "tap,vlan=%s,script=%s" % (nic_seq, script) |
772 | 774 |
kvm_cmd.extend(["-net", tap_val, "-net", nic_val]) |
773 | 775 |
|
Also available in: Unified diff