From: Michal Privoznik Date: Mon, 23 Jun 2014 13:46:31 +0000 (+0200) Subject: virNumaGetPages: Don't fail on huge page-less systems X-Git-Tag: v1.2.6-rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c78a270da9268dfc6e3af77c843acd3d70dd50b;p=thirdparty%2Flibvirt.git virNumaGetPages: Don't fail on huge page-less systems If we are running on a system that is not capable of huge pages (e.g. because the kernel is not configured that way) we still try to open "/sys/kernel/mm/hugepages/" which however does not exist. We should be tolerant to this specific use case. Signed-off-by: Michal Privoznik --- diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 66d228181b..207b8043f5 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -738,7 +738,7 @@ virNumaGetPages(int node, int ret = -1; char *path = NULL; DIR *dir = NULL; - int direrr; + int direrr = 0; struct dirent *entry; unsigned int *tmp_size = NULL, *tmp_avail = NULL, *tmp_free = NULL; unsigned int ntmp = 0; @@ -760,13 +760,17 @@ virNumaGetPages(int node, goto cleanup; if (!(dir = opendir(path))) { - virReportSystemError(errno, - _("unable to open path: %s"), - path); - goto cleanup; + /* It's okay if the @path doesn't exist. Maybe we are running on + * system without huge pages support where the path may not exist. */ + if (errno != ENOENT) { + virReportSystemError(errno, + _("unable to open path: %s"), + path); + goto cleanup; + } } - while ((direrr = virDirRead(dir, &entry, path)) > 0) { + while (dir && (direrr = virDirRead(dir, &entry, path)) > 0) { const char *page_name = entry->d_name; unsigned int page_size, page_avail = 0, page_free = 0; char *end;