+ def _copy_fwd_tools_for_all_guests(self):
+ """Copy dpdk and l2fwd code to GUEST_SHARE_DIR[s] based on selected deployment.
+ """
+ # consider only VNFs involved in the test
+ for guest_dir in set(S.getValue('GUEST_SHARE_DIR')[:self._vnf_ctl.get_vnfs_number()]):
+ self._copy_fwd_tools_for_guest(guest_dir)
+
+ def _copy_fwd_tools_for_guest(self, guest_dir):
+ """Copy dpdk and l2fwd code to GUEST_SHARE_DIR of VM
+
+ :param index: Index of VM starting from 1 (i.e. 1st VM has index 1)
+ """
+ # remove shared dir if it exists to avoid issues with file consistency
+ if os.path.exists(guest_dir):
+ tasks.run_task(['rm', '-f', '-r', guest_dir], self._logger,
+ 'Removing content of shared directory...', True)
+
+ # directory to share files between host and guest
+ os.makedirs(guest_dir)
+
+ # copy sources into shared dir only if neccessary
+ guest_loopback = set(S.getValue('GUEST_LOOPBACK'))
+ if 'testpmd' in guest_loopback or 'l2fwd' in guest_loopback:
+ try:
+ tasks.run_task(['rsync', '-a', '-r', '-l', r'--exclude="\.git"',
+ os.path.join(S.getValue('RTE_SDK_USER'), ''),
+ os.path.join(guest_dir, 'DPDK')],
+ self._logger,
+ 'Copying DPDK to shared directory...',
+ True)
+ tasks.run_task(['rsync', '-a', '-r', '-l',
+ os.path.join(S.getValue('ROOT_DIR'), 'src/l2fwd/'),
+ os.path.join(guest_dir, 'l2fwd')],
+ self._logger,
+ 'Copying l2fwd to shared directory...',
+ True)
+ except subprocess.CalledProcessError:
+ self._logger.error('Unable to copy DPDK and l2fwd to shared directory')
+
+ def _mount_hugepages(self):
+ """Mount hugepages if usage of DPDK or Qemu is detected
+ """
+ # hugepages are needed by DPDK and Qemu
+ if not self._hugepages_mounted and \
+ (self.deployment.count('v') or \
+ S.getValue('VSWITCH').lower().count('dpdk') or \
+ self._vswitch_none or \
+ self.test and 'vnf' in [step[0][0:3] for step in self.test]):
+ hugepages.mount_hugepages()
+ self._hugepages_mounted = True
+
+ def _umount_hugepages(self):
+ """Umount hugepages if they were mounted before
+ """
+ if self._hugepages_mounted:
+ hugepages.umount_hugepages()
+ self._hugepages_mounted = False
+
+ def _check_for_enough_hugepages(self):
+ """Check to make sure enough hugepages are free to satisfy the
+ test environment.