- def qemu_add_vhost_user_if(self, socket, server=True, jumbo_frames=False,
- queue_size=None, queues=1):
- """Add Vhost-user interface.
-
- :param socket: Path of the unix socket.
- :param server: If True the socket shall be a listening socket.
- :param jumbo_frames: Set True if jumbo frames are used in the test.
- :param queue_size: Vring queue size.
- :param queues: Number of queues.
- :type socket: str
- :type server: bool
- :type jumbo_frames: bool
- :type queue_size: int
- :type queues: int
- """
- self._vhost_id += 1
- self._params.add_with_value(
- 'chardev', 'socket,id=char{vhost},path={socket}{server}'.format(
- vhost=self._vhost_id, socket=socket,
- server=',server' if server is True else ''))
- self._params.add_with_value(
- 'netdev', 'vhost-user,id=vhost{vhost},chardev=char{vhost},'
- 'queues={queues}'.format(vhost=self._vhost_id, queues=queues))
- mac = ('52:54:00:00:{qemu:02x}:{vhost:02x}'.
- format(qemu=self._opt.get('qemu_id'), vhost=self._vhost_id))
- queue_size = ('rx_queue_size={queue_size},tx_queue_size={queue_size}'.
- format(queue_size=queue_size)) if queue_size else ''
- mbuf = 'on,host_mtu=9200'
- self._params.add_with_value(
- 'device', 'virtio-net-pci,netdev=vhost{vhost},mac={mac},bus=pci.0,'
- 'addr={addr}.0,mq=on,vectors={vectors},csum=off,gso=off,'
- 'guest_tso4=off,guest_tso6=off,guest_ecn=off,mrg_rxbuf={mbuf},'
- '{queue_size}'.format(
- addr=self._vhost_id+5, vhost=self._vhost_id, mac=mac,
- mbuf=mbuf if jumbo_frames else 'off', queue_size=queue_size,
- vectors=(2 * queues + 2)))
-
- # Add interface MAC and socket to the node dict.
- if_data = {'mac_address': mac, 'socket': socket}
- if_name = 'vhost{vhost}'.format(vhost=self._vhost_id)
- self._vm_info['interfaces'][if_name] = if_data
- # Add socket to temporary file list.
- self._temp[if_name] = socket
-