mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
virfile: Introduce and use virFileGetDefaultHugepage
This helper returns the default hugetlbfs mount point from given array of mount points. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
59a22be864
commit
465df4771a
@ -1864,6 +1864,7 @@ virFileFindResourceFull;
|
|||||||
virFileFlock;
|
virFileFlock;
|
||||||
virFileFreeACLs;
|
virFileFreeACLs;
|
||||||
virFileGetACLs;
|
virFileGetACLs;
|
||||||
|
virFileGetDefaultHugepage;
|
||||||
virFileGetHugepageSize;
|
virFileGetHugepageSize;
|
||||||
virFileGetMountReverseSubtree;
|
virFileGetMountReverseSubtree;
|
||||||
virFileGetMountSubtree;
|
virFileGetMountSubtree;
|
||||||
|
@ -1914,16 +1914,12 @@ qemuGetDomainDefaultHugepath(const virDomainDef *def,
|
|||||||
virHugeTLBFSPtr hugetlbfs,
|
virHugeTLBFSPtr hugetlbfs,
|
||||||
size_t nhugetlbfs)
|
size_t nhugetlbfs)
|
||||||
{
|
{
|
||||||
size_t i;
|
virHugeTLBFSPtr p;
|
||||||
|
|
||||||
for (i = 0; i < nhugetlbfs; i++)
|
if (!(p = virFileGetDefaultHugepage(hugetlbfs, nhugetlbfs)))
|
||||||
if (hugetlbfs[i].deflt)
|
p = &hugetlbfs[0];
|
||||||
break;
|
|
||||||
|
|
||||||
if (i == nhugetlbfs)
|
return qemuGetDomainHugepagePath(def, p);
|
||||||
i = 0;
|
|
||||||
|
|
||||||
return qemuGetDomainHugepagePath(def, &hugetlbfs[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3735,6 +3735,31 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
#endif /* defined __linux__ */
|
#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)
|
int virFileIsSharedFS(const char *path)
|
||||||
{
|
{
|
||||||
return virFileIsSharedFSType(path,
|
return virFileIsSharedFSType(path,
|
||||||
|
@ -334,6 +334,9 @@ int virFileGetHugepageSize(const char *path,
|
|||||||
int virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
|
int virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
|
||||||
size_t *ret_nfs);
|
size_t *ret_nfs);
|
||||||
|
|
||||||
|
virHugeTLBFSPtr virFileGetDefaultHugepage(virHugeTLBFSPtr fs,
|
||||||
|
size_t nfs);
|
||||||
|
|
||||||
int virFileSetupDev(const char *path,
|
int virFileSetupDev(const char *path,
|
||||||
const char *mount_options);
|
const char *mount_options);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user