On 09/30/2015 12:01 AM, Luyao Huang wrote: > Commit 1c24cfe9 fix the problem in virNumaSetPagePoolSize, > this patch just like it and fix the issue in another function. > > when user use freepages and specify a invalid node or page size, > will get error like this: > > # virsh freepages 0 1 > error: Failed to open file '/sys/devices/system/node/node0/hugepages/hugepages-1kB/free_hugepages': No such file or directory > > Add two checks to catch this and therefore produce much more > friendlier error messages. > > Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx> > --- > src/util/virnuma.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > Perhaps the more entertaining part of this patch is/was it possible to use "freepages 0 0"? Before patch 1, before patch 2, after patch 2. Based on the answer to the question below, I can adjust the commit message (and code if necessary) a bit in order to remove the really long line and make it flow better. > diff --git a/src/util/virnuma.c b/src/util/virnuma.c > index 8577bd8..c8beade 100644 > --- a/src/util/virnuma.c > +++ b/src/util/virnuma.c > @@ -560,6 +560,12 @@ virNumaGetHugePageInfo(int node, > page_size, "nr_hugepages") < 0) > goto cleanup; > > + if (!virFileExists(path)) { > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", > + _("page size or NUMA node not available")); > + goto cleanup; > + } > + Why is there no "if (node != -1 && !virNumaNodeIsAvailable(node)) {" check prior to the virNumaGetHugePageInfoPath call? <same for next change too> John > if (virFileReadAll(path, 1024, &buf) < 0) > goto cleanup; > > @@ -579,6 +585,12 @@ virNumaGetHugePageInfo(int node, > page_size, "free_hugepages") < 0) > goto cleanup; > > + if (!virFileExists(path)) { > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", > + _("page size or NUMA node not available")); > + goto cleanup; > + } > + > if (virFileReadAll(path, 1024, &buf) < 0) > goto cleanup; > > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list