[PATCH] conf: report no NUMA nodes when attaching memory device

Kristina Hanicova posted 1 patch 1 year, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/ddc89babb454cf18821c53fd6332a69b3e2f670c.1669382284.git.khanicov@redhat.com
src/conf/domain_validate.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] conf: report no NUMA nodes when attaching memory device
Posted by Kristina Hanicova 1 year, 5 months ago
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>
---
 src/conf/domain_validate.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 5bc7ea10aa..95b8d9b419 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -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"),
-- 
2.38.1
Re: [PATCH] conf: report no NUMA nodes when attaching memory device
Posted by Jiri Denemark 1 year, 5 months ago
On Fri, Nov 25, 2022 at 14:20:53 +0100, Kristina Hanicova wrote:
> 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>
> ---
>  src/conf/domain_validate.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>