From e802d7efb4c0809a5fc756048dc34b2d15b7618d Mon Sep 17 00:00:00 2001 From: Luyao Huang Date: Wed, 21 Oct 2015 12:13:40 +0800 Subject: [PATCH] util: Adjust error paths for virNumaSetPagePoolSize Commit id '1c24cfe9' added new checks and error messaes for failure scenarios. Let's adjust those error messages to after the call to virNumaGetHugePageInfoPath in order to provide a more specific error message depending on node and page_size After this patch: # virsh allocpages --pagesize 2047 --pagecount 1 --cellno 0 error: operation failed: page size 2047 is not available on node 0 # virsh allocpages --pagesize 2047 --pagecount 1 error: operation failed: page size 2047 is not available Signed-off-by: Luyao Huang --- src/util/virnuma.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index cb80972e6a..815cbc12cc 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -836,19 +836,25 @@ virNumaSetPagePoolSize(int node, goto cleanup; } - if (node != -1 && !virNumaNodeIsAvailable(node)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("NUMA node %d is not available"), - node); - goto cleanup; - } - if (virNumaGetHugePageInfoPath(&nr_path, node, page_size, "nr_hugepages") < 0) goto cleanup; if (!virFileExists(nr_path)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("page size or NUMA node not available")); + if (node != -1) { + if (!virNumaNodeIsAvailable(node)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("NUMA node %d is not available"), + node); + } else { + virReportError(VIR_ERR_OPERATION_FAILED, + _("page size %u is not available on node %d"), + page_size, node); + } + } else { + virReportError(VIR_ERR_OPERATION_FAILED, + _("page size %u is not available"), + page_size); + } goto cleanup; }