- def _huge_page_check(self):
- """Huge page check."""
- huge_mnt = self._qemu_opt.get('huge_mnt')
- mem_size = self._qemu_opt.get('mem_size')
- # Check size of free huge pages
- (_, output, _) = self._ssh.exec_command('grep Huge /proc/meminfo')
- regex = re.compile(r'HugePages_Free:\s+(\d+)')
- match = regex.search(output)
- huge_free = int(match.group(1))
- regex = re.compile(r'Hugepagesize:\s+(\d+)')
- match = regex.search(output)
- huge_size = int(match.group(1))
- if (mem_size * 1024) > (huge_free * huge_size):
- raise RuntimeError('Not enough free huge pages {0} kB, required '
- '{1} MB'.format(huge_free * huge_size, mem_size))
- # Check if huge pages mount point exist
- has_huge_mnt = False
- (_, output, _) = self._ssh.exec_command('cat /proc/mounts')
- for line in output.splitlines():
- # Try to find something like:
- # none /mnt/huge hugetlbfs rw,relatime,pagesize=2048k 0 0
- mount = line.split()
- if mount[2] == 'hugetlbfs' and mount[1] == huge_mnt:
- has_huge_mnt = True
- break
- # If huge page mount point not exist create one
- if not has_huge_mnt:
- cmd = 'mount -t hugetlbfs -o pagesize=2048k none {0}'.format(
- huge_mnt)
- (ret_code, _, stderr) = self._ssh.exec_command_sudo(cmd)
- if int(ret_code) != 0:
- logger.debug('Mount huge pages failed {0}'.format(stderr))
- raise RuntimeError('Mount huge pages failed on {0}'.format(
- self._node['host']))
-