提交 465df477 编写于 作者: M Michal Privoznik

virfile: Introduce and use virFileGetDefaultHugepage

This helper returns the default hugetlbfs mount point from given
array of mount points.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 59a22be8
......@@ -1864,6 +1864,7 @@ virFileFindResourceFull;
virFileFlock;
virFileFreeACLs;
virFileGetACLs;
virFileGetDefaultHugepage;
virFileGetHugepageSize;
virFileGetMountReverseSubtree;
virFileGetMountSubtree;
......
......@@ -1914,16 +1914,12 @@ qemuGetDomainDefaultHugepath(const virDomainDef *def,
virHugeTLBFSPtr hugetlbfs,
size_t nhugetlbfs)
{
size_t i;
for (i = 0; i < nhugetlbfs; i++)
if (hugetlbfs[i].deflt)
break;
virHugeTLBFSPtr p;
if (i == nhugetlbfs)
i = 0;
if (!(p = virFileGetDefaultHugepage(hugetlbfs, nhugetlbfs)))
p = &hugetlbfs[0];
return qemuGetDomainHugepagePath(def, &hugetlbfs[i]);
return qemuGetDomainHugepagePath(def, p);
}
......
......@@ -3735,6 +3735,31 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs ATTRIBUTE_UNUSED,
}
#endif /* defined __linux__ */
/**
* virFileGetDefaultHugepage:
* @fs: array of hugetlbfs mount points
* @nfs: number of items in @fs
*
* In the passed array of hugetlbfs mount points @fs find the
* default one. It's the one which has no '-o pagesize'.
*
* Returns: default hugepage, or
* NULL if none found
*/
virHugeTLBFSPtr
virFileGetDefaultHugepage(virHugeTLBFSPtr fs,
size_t nfs)
{
size_t i;
for (i = 0; i < nfs; i++) {
if (fs[i].deflt)
return &fs[i];
}
return NULL;
}
int virFileIsSharedFS(const char *path)
{
return virFileIsSharedFSType(path,
......
......@@ -334,6 +334,9 @@ int virFileGetHugepageSize(const char *path,
int virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
size_t *ret_nfs);
virHugeTLBFSPtr virFileGetDefaultHugepage(virHugeTLBFSPtr fs,
size_t nfs);
int virFileSetupDev(const char *path,
const char *mount_options);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册