Revision 4b784cf8 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
722 | 722 |
kvm_cmd, kvm_nics, up_hvp = kvm_runtime |
723 | 723 |
up_hvp = objects.FillDict(conf_hvp, up_hvp) |
724 | 724 |
|
725 |
kvm_version = self._GetKVMVersion() |
|
726 |
if kvm_version: |
|
727 |
_, v_major, v_min, v_rev = kvm_version |
|
728 |
else: |
|
729 |
raise errors.HypervisorError("Unable to get KVM version") |
|
730 |
|
|
725 | 731 |
# We know it's safe to run as a different user upon migration, so we'll use |
726 | 732 |
# the latest conf, from conf_hvp. |
727 | 733 |
security_model = conf_hvp[constants.HV_SECURITY_MODEL] |
... | ... | |
737 | 743 |
tap_extra = "" |
738 | 744 |
nic_type = up_hvp[constants.HV_NIC_TYPE] |
739 | 745 |
if nic_type == constants.HT_NIC_PARAVIRTUAL: |
740 |
nic_model = "model=virtio" |
|
746 |
# From version 0.12.0, kvm uses a new sintax for network configuration. |
|
747 |
if (v_major, v_min) >= (0,12): |
|
748 |
nic_model = "virtio-net-pci" |
|
749 |
else: |
|
750 |
nic_model = "virtio" |
|
751 |
|
|
741 | 752 |
if up_hvp[constants.HV_VHOST_NET]: |
742 |
tap_extra = ",vhost=on" |
|
753 |
# vhost_net is only available from version 0.13.0 or newer |
|
754 |
if (v_major, v_min) >= (0,13): |
|
755 |
tap_extra = ",vhost=on" |
|
756 |
else: |
|
757 |
raise errors.HypervisorError("vhost_net is configured" |
|
758 |
" but it is not available") |
|
743 | 759 |
else: |
744 |
nic_model = "model=%s" % nic_type
|
|
760 |
nic_model = nic_type |
|
745 | 761 |
|
746 | 762 |
for nic_seq, nic in enumerate(kvm_nics): |
747 |
nic_val = "nic,vlan=%s,macaddr=%s,%s" % (nic_seq, nic.mac, nic_model) |
|
748 | 763 |
script = self._WriteNetScriptFile(instance, nic_seq, nic) |
749 |
tap_val = "tap,vlan=%s,script=%s%s" % (nic_seq, script, tap_extra) |
|
750 |
kvm_cmd.extend(["-net", nic_val]) |
|
751 |
kvm_cmd.extend(["-net", tap_val]) |
|
752 | 764 |
temp_files.append(script) |
765 |
if (v_major, v_min) >= (0,12): |
|
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) |
|
768 |
kvm_cmd.extend(["-netdev", tap_val, "-device", nic_val]) |
|
769 |
else: |
|
770 |
nic_val = "nic,vlan=%s,macaddr=%s,model=%s" % (nic_seq, nic.mac, nic_model) |
|
771 |
tap_val = "tap,vlan=%s,script=%s" % (nic_seq, script) |
|
772 |
kvm_cmd.extend(["-net", tap_val, "-net", nic_val]) |
|
753 | 773 |
|
754 | 774 |
if incoming: |
755 | 775 |
target, port = incoming |
Also available in: Unified diff