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

Merge branch 'devel-2.1'



* devel-2.1:
  Abstract the LUXI eom into a constant
  KVM: vhost net acceleration support

Conflicts:
	lib/luxi.py
	  - trivial
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parents d88eba85 25942a6c
......@@ -146,7 +146,6 @@ class IOServer(SocketServer.UnixStreamServer):
class ClientRqHandler(SocketServer.BaseRequestHandler):
"""Client handler"""
EOM = '\3'
READ_SIZE = 4096
def setup(self):
......@@ -183,14 +182,14 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
data = self.request.recv(self.READ_SIZE)
if not data:
return None
new_msgs = (self._buffer + data).split(self.EOM)
new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
self._buffer = new_msgs.pop()
self._msgs.extend(new_msgs)
return self._msgs.popleft()
def send_message(self, msg):
# TODO: sendall is not guaranteed to send everything
self.request.sendall(msg + self.EOM)
self.request.sendall(msg + constants.LUXI_EOM)
class ClientOps:
......
......@@ -170,6 +170,9 @@ LOG_BURNIN = LOG_DIR + "burnin.log"
DEV_CONSOLE = "/dev/console"
# luxi related constants
LUXI_EOM = "\3"
# one of 'no', 'yes', 'only'
SYSLOG_USAGE = _autoconf.SYSLOG_USAGE
SYSLOG_NO = "no"
......@@ -345,7 +348,6 @@ INISECT_HYP = "hypervisor"
INISECT_BEP = "backend"
# dynamic device modification
DDM_ADD = 'add'
DDM_REMOVE = 'remove'
......@@ -461,6 +463,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,
......@@ -491,6 +494,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())
......@@ -757,6 +761,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:
......
......@@ -115,15 +115,12 @@ class Transport:
"""
def __init__(self, address, timeouts=None, eom=None):
def __init__(self, address, timeouts=None):
"""Constructor for the Client class.
Arguments:
- address: a valid address the the used transport class
- timeout: a list of timeouts, to be used on connect and read/write
- eom: an identifier to be used as end-of-message which the
upper-layer will guarantee that this identifier will not appear
in any message
There are two timeouts used since we might want to wait for a long
time for a response, but the connect timeout should be lower.
......@@ -146,11 +143,6 @@ class Transport:
self._buffer = ""
self._msgs = collections.deque()
if eom is None:
self.eom = '\3'
else:
self.eom = eom
try:
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
......@@ -196,13 +188,13 @@ class Transport:
This just sends a message and doesn't wait for the response.
"""
if self.eom in msg:
if constants.LUXI_EOM in msg:
raise ProtocolError("Message terminator found in payload")
self._CheckSocket()
try:
# TODO: sendall is not guaranteed to send everything
self.socket.sendall(msg + self.eom)
self.socket.sendall(msg + constants.LUXI_EOM)
except socket.timeout, err:
raise TimeoutError("Sending timeout: %s" % str(err))
......@@ -232,7 +224,7 @@ class Transport:
break
if not data:
raise ConnectionClosedError("Connection closed while reading")
new_msgs = (self._buffer + data).split(self.eom)
new_msgs = (self._buffer + data).split(constants.LUXI_EOM)
self._buffer = new_msgs.pop()
self._msgs.extend(new_msgs)
return self._msgs.popleft()
......
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