- self._params.add('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('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('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)))
+ self._params.add_with_value(
+ u"chardev", f"socket,id=char{self._vhost_id},"
+ f"path={socket}{u',server' if server is True else u''}"
+ )
+ self._params.add_with_value(
+ u"netdev", f"vhost-user,id=vhost{self._vhost_id},"
+ f"chardev=char{self._vhost_id},queues={queues}"
+ )
+ mac = f"52:54:00:00:{self._opt.get(u'qemu_id'):02x}:" \
+ f"{self._vhost_id:02x}"
+ queue_size = f"rx_queue_size={queue_size},tx_queue_size={queue_size}" \
+ if queue_size else u""
+ self._params.add_with_value(
+ u"device", f"virtio-net-pci,netdev=vhost{self._vhost_id},mac={mac},"
+ f"addr={self._vhost_id+5}.0,mq=on,vectors={2 * queues + 2},"
+ f"csum={u'on' if csum else u'off'},gso={u'on' if gso else u'off'},"
+ f"guest_tso4=off,guest_tso6=off,guest_ecn=off,"
+ f"{queue_size}"
+ )