Commit 05440845 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

gnt-instance: new hypervisor parameter 'vif_type'



This patch fixes issue 247. It empowers the user to specify
explicitly the vif type of a nic configuration of a Xen HVM
instance. This includes the option of setting it to '' on the
commandline, causing Ganeti to leave out the 'type' parameter
in the vif configuration completely.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3e0c2a24
......@@ -849,6 +849,7 @@ HV_VGA = "vga"
HV_KVM_EXTRA = "kvm_extra"
HV_KVM_MACHINE_VERSION = "machine_version"
HV_KVM_PATH = "kvm_path"
HV_VIF_TYPE = "vif_type"
HVS_PARAMETER_TYPES = {
......@@ -918,6 +919,7 @@ HVS_PARAMETER_TYPES = {
HV_VGA: VTYPE_STRING,
HV_KVM_EXTRA: VTYPE_STRING,
HV_KVM_MACHINE_VERSION: VTYPE_STRING,
HV_VIF_TYPE: VTYPE_STRING,
}
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
......@@ -1311,6 +1313,15 @@ HT_KVM_VALID_NIC_TYPES = compat.UniqueFrozenset([
HT_NIC_PARAVIRTUAL,
])
# Vif types
# default vif type in xen-hvm
HT_HVM_VIF_IOEMU = "ioemu"
HT_HVM_VIF_VIF = "vif"
HT_HVM_VALID_VIF_TYPES = compat.UniqueFrozenset([
HT_HVM_VIF_IOEMU,
HT_HVM_VIF_VIF,
])
# Disk types
HT_DISK_IOEMU = "ioemu"
HT_DISK_IDE = "ide"
......@@ -1931,6 +1942,7 @@ HVC_DEFAULTS = {
HV_CPU_MASK: CPU_PINNING_ALL,
HV_CPU_CAP: 0,
HV_CPU_WEIGHT: 256,
HV_VIF_TYPE: HT_HVM_VIF_IOEMU,
},
HT_KVM: {
HV_KVM_PATH: KVM_PATH,
......
......@@ -767,6 +767,8 @@ class XenHvmHypervisor(XenHypervisor):
constants.HV_CPU_CAP: hv_base.NO_CHECK,
constants.HV_CPU_WEIGHT:
(False, lambda x: 0 < x < 65535, "invalid weight", None, None),
constants.HV_VIF_TYPE:
hv_base.ParamInSet(False, constants.HT_HVM_VALID_VIF_TYPES),
}
@classmethod
......@@ -840,14 +842,23 @@ class XenHvmHypervisor(XenHypervisor):
config.write("localtime = 1\n")
vif_data = []
# Note: what is called 'nic_type' here, is used as value for the xen nic
# vif config parameter 'model'. For the xen nic vif parameter 'type', we use
# the 'vif_type' to avoid a clash of notation.
nic_type = hvp[constants.HV_NIC_TYPE]
if nic_type is None:
vif_type_str = ""
if hvp[constants.HV_VIF_TYPE]:
vif_type_str = ", type=%s" % hvp[constants.HV_VIF_TYPE]
# ensure old instances don't change
nic_type_str = ", type=ioemu"
nic_type_str = vif_type_str
elif nic_type == constants.HT_NIC_PARAVIRTUAL:
nic_type_str = ", type=paravirtualized"
else:
nic_type_str = ", model=%s, type=ioemu" % nic_type
# parameter 'model' is only valid with type 'ioemu'
nic_type_str = ", model=%s, type=%s" % \
(nic_type, constants.HT_HVM_VIF_IOEMU)
for nic in instance.nics:
nic_str = "mac=%s%s" % (nic.mac, nic_type_str)
ip = getattr(nic, "ip", None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment