[libvirt] [PATCH v2 1/6] Introduce virFileFindHugeTLBFS
Peter Krempa
pkrempa at redhat.com
Thu Jul 24 06:41:02 UTC 2014
On 07/23/14 21:06, Daniel P. Berrange wrote:
> On Wed, Jul 23, 2014 at 05:37:17PM +0200, Michal Privoznik wrote:
>> +int
>> +virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs,
>> + size_t *ret_nfs)
>> +{
>> + int ret = -1;
>> + FILE *f = NULL;
>> + struct mntent mb;
>> + char mntbuf[1024];
>> + virHugeTLBFSPtr fs = NULL;
>> + size_t nfs = 0;
>> + unsigned long long default_hugepagesz;
>> +
>> + if (virFileGetDefaultHugepageSize(&default_hugepagesz) < 0)
>> + goto cleanup;
>> +
>> + if (!(f = setmntent(PROC_MOUNTS, "r"))) {
>> + virReportSystemError(errno,
>> + _("Unable to open %s"),
>> + PROC_MOUNTS);
>> + goto cleanup;
>> + }
>> +
>> + while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) {
>> + virHugeTLBFSPtr tmp;
>> +
>> + if (STRNEQ(mb.mnt_type, "hugetlbfs"))
>> + continue;
>> +
>> + if (VIR_REALLOC_N(fs, nfs + 1) < 0)
>> + goto cleanup;
>> +
>> + tmp = &fs[nfs];
>> + nfs++;
>
> Stilll think we should be using VIR_EXPAND_N here to ensure
> new space is fully zerod.
Or perhaps use VIR_APPEND_ELEMENT?
>
>> +
>> + if (VIR_STRDUP(tmp->mnt_dir, mb.mnt_dir) < 0)
>> + goto cleanup;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140724/2184db21/attachment-0001.sig>
More information about the libvir-list
mailing list