X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=vnfs%2Fqemu%2Fqemu_virtio_net.py;h=efeea490db946501037a411e72c671c606d7ad62;hb=91e0985be7ca2b2654f89928315431228b7ecc56;hp=afb519c3232d1dfcc2d4947a7ea01d56364dd519;hpb=0fb65d2afadad1f092788f5a4f251b09851b3ae7;p=vswitchperf.git diff --git a/vnfs/qemu/qemu_virtio_net.py b/vnfs/qemu/qemu_virtio_net.py index afb519c3..efeea490 100644 --- a/vnfs/qemu/qemu_virtio_net.py +++ b/vnfs/qemu/qemu_virtio_net.py @@ -36,39 +36,33 @@ class QemuVirtioNet(IVnfQemu): tasks.run_task(['sudo', 'modprobe', 'vhost_net'], self._logger, 'Loading vhost_net module...', True) - # calculate indexes of guest devices (e.g. charx, dpdkvhostuserx) - i = self._number * 2 - if1 = str(i) - if2 = str(i + 1) + # calculate index of first interface, i.e. check how many + # interfaces has been created for previous VMs, where 1st NIC + # of 1st VM has index 0 + start_index = sum(S.getValue('GUEST_NICS_NR')[:self._number]) # multi-queue values - if int(S.getValue('GUEST_NIC_QUEUES')): - queue_str = ',queues={}'.format(S.getValue('GUEST_NIC_QUEUES')) + if int(S.getValue('GUEST_NIC_QUEUES')[self._number]): + queue_str = ',queues={}'.format( + S.getValue('GUEST_NIC_QUEUES')[self._number]) mq_vector_str = ',mq=on,vectors={}'.format( - int(S.getValue('GUEST_NIC_QUEUES')) * 2 + 2) + int(S.getValue('GUEST_NIC_QUEUES')[self._number]) * 2 + 2) else: queue_str, mq_vector_str = '', '' - self._cmd += ['-netdev', - 'tap,id=' + self._net1 + queue_str + - ',script=no,downscript=no,' + - 'ifname=tap' + if1 + ',vhost=on', - '-device', - 'virtio-net-pci,mac=' + - S.getValue('GUEST_NET1_MAC')[self._number] + - ',netdev=' + self._net1 + - ',csum=off,gso=off,' + - 'guest_tso4=off,guest_tso6=off,guest_ecn=off' + - mq_vector_str, - '-netdev', - 'tap,id=' + self._net2 + queue_str + - ',script=no,downscript=no,' + - 'ifname=tap' + if2 + ',vhost=on', - '-device', - 'virtio-net-pci,mac=' + - S.getValue('GUEST_NET2_MAC')[self._number] + - ',netdev=' + self._net2 + - ',csum=off,gso=off,' + - 'guest_tso4=off,guest_tso6=off,guest_ecn=off' + - mq_vector_str, - ] + # setup requested number of interfaces + for nic in range(len(self._nics)): + index = start_index + nic + ifi = str(index) + self._cmd += ['-netdev', 'type=tap,id=' + + self._nics[nic]['device'] + queue_str + + ',script=no,downscript=no,' + + 'ifname=tap' + ifi + ',vhost=on', + '-device', + 'virtio-net-pci,mac=' + + self._nics[nic]['mac'] + ',netdev=' + + self._nics[nic]['device'] + + ',csum=off,gso=off,' + + 'guest_tso4=off,guest_tso6=off,guest_ecn=off' + + mq_vector_str, + ]