Commit fbe27e2b authored by Guido Trotter's avatar Guido Trotter
Browse files

KVM: vhost net acceleration support



This will only work on patched or newer (>= 2.6.34) kernels and with a
patched version of qemu-kvm.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent f6781abf
......@@ -437,6 +437,7 @@ HV_DISK_CACHE = "disk_cache"
HV_SECURITY_MODEL = "security_model"
HV_SECURITY_DOMAIN = "security_domain"
HV_KVM_FLAG = "kvm_flag"
HV_VHOST_NET = "vhost_net"
HVS_PARAMETER_TYPES = {
HV_BOOT_ORDER: VTYPE_STRING,
......@@ -467,6 +468,7 @@ HVS_PARAMETER_TYPES = {
HV_SECURITY_MODEL: VTYPE_STRING,
HV_SECURITY_DOMAIN: VTYPE_STRING,
HV_KVM_FLAG: VTYPE_STRING,
HV_VHOST_NET: VTYPE_BOOL,
}
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
......@@ -733,6 +735,7 @@ HVC_DEFAULTS = {
HV_SECURITY_MODEL: HT_SM_NONE,
HV_SECURITY_DOMAIN: '',
HV_KVM_FLAG: "",
HV_VHOST_NET: False,
},
HT_FAKE: {
},
......
......@@ -86,6 +86,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
constants.HV_SECURITY_DOMAIN: hv_base.NO_CHECK,
constants.HV_KVM_FLAG:
hv_base.ParamInSet(False, constants.HT_KVM_FLAG_VALUES),
constants.HV_VHOST_NET: hv_base.NO_CHECK,
}
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)',
......@@ -611,19 +612,23 @@ class KVMHypervisor(hv_base.BaseHypervisor):
kvm_cmd.extend(["-runas", hvp[constants.HV_SECURITY_DOMAIN]])
if not kvm_nics:
kvm_cmd.extend(['-net', 'none'])
kvm_cmd.extend(["-net", "none"])
else:
tap_extra = ""
nic_type = hvparams[constants.HV_NIC_TYPE]
if nic_type == constants.HT_NIC_PARAVIRTUAL:
nic_model = "model=virtio"
if hvparams[constants.HV_VHOST_NET]:
tap_extra = ",vhost=on"
else:
nic_model = "model=%s" % nic_type
for nic_seq, nic in enumerate(kvm_nics):
nic_val = "nic,vlan=%s,macaddr=%s,%s" % (nic_seq, nic.mac, nic_model)
script = self._WriteNetScript(instance, nic_seq, nic)
kvm_cmd.extend(['-net', nic_val])
kvm_cmd.extend(['-net', 'tap,vlan=%s,script=%s' % (nic_seq, script)])
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])
temp_files.append(script)
if incoming:
......
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