]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: report no NUMA nodes when attaching memory device
authorKristina Hanicova <khanicov@redhat.com>
Fri, 25 Nov 2022 13:20:53 +0000 (14:20 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 1 Dec 2022 10:03:09 +0000 (11:03 +0100)
Error message reports that the guest has '0' NUMA nodes
configured when trying to attach a memory device to a guest with
no NUMA nodes. This may be a little misleading because '0' can
also be node's id.  A more friendly way is to directly report
that the guest has no NUMA nodes.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2142519

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/conf/domain_validate.c

index 5bc7ea10aaded8e93caf0cb9e1040fa5dd8b835e..95b8d9b41938f0fc2348f5e7bd2cd26316c86a25 100644 (file)
@@ -2257,6 +2257,12 @@ virDomainMemoryDefValidate(const virDomainMemoryDef *mem,
     if (mem->targetNode != -1) {
         const size_t nodeCount = virDomainNumaGetNodeCount(def->numa);
 
+        if (nodeCount == 0) {
+            virReportError(VIR_ERR_XML_DETAIL, "%s",
+                           _("can't add memory backend as guest has no NUMA nodes configured"));
+            return -1;
+        }
+
         if (mem->targetNode >= nodeCount) {
             virReportError(VIR_ERR_XML_DETAIL,
                            _("can't add memory backend for guest node '%d' as the guest has only '%zu' NUMA nodes configured"),