]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNumaSetPagePoolSize: Produce friendlier error message
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 8 Jun 2015 12:05:25 +0000 (14:05 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 10 Jun 2015 15:27:16 +0000 (17:27 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1224587

The function takes two important arguments (among many others): @node
and @page_size. From these two a path under /sys is constructed. The
path is then used to read and write the desired size of huge pages
pool. However, if the path does not exists due to either @node or
@page_size having nonexistent value (e.g. there's no such NUMA node or
no page size like -2), an cryptic error message is produced:

  virsh # allocpages --pagesize 2049 --pagecount 8 --cellno -2
  error: Failed to open file '/sys/devices/system/node/node-2/hugepages/hugepages-2049kB/nr_hugepages': No such file or directory

Add two more checks to catch this and therefore produce much more
friendlier error messages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnuma.c

index 669192a276982f4c680f30f87ffaa9b1905c7ee9..1a62d62d75e868e456abb10815bf39a8e73dc931 100644 (file)
@@ -849,9 +849,22 @@ 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"));
+        goto cleanup;
+    }
+
     /* Firstly check, if there's anything for us to do */
     if (virFileReadAll(nr_path, 1024, &nr_buf) < 0)
         goto cleanup;