]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_domain: Partially validate memory amounts when auto-adding NUMA node
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 21 Jul 2023 10:57:39 +0000 (12:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 25 Jul 2023 12:51:35 +0000 (14:51 +0200)
commitbaeefe03279dc4b39e19ae61153aad864f311254
treed37f013c637443b8adf7c47f629b879d1bb16abd
parent5b6badcfbfef1c492eb24838a0833ce7a85f31b9
qemu_domain: Partially validate memory amounts when auto-adding NUMA node

When automatically adding a NUMA node (qemuDomainDefNumaAutoAdd()) the
memory size of the node is computed as:

  total_memory - sum(memory devices)

And we have a nice helper for that: virDomainDefGetMemoryInitial() so
it looks logical to just call it. Except, this code runs in post parse
callback, i.e. memory sizes were not validated and it may happen that
the sum is greater than the total memory. This would be caught by
virDomainDefPostParseMemory() but that runs only after driver specific
callbacks (i.e. after qemuDomainDefNumaAutoAdd()) and because the
domain config was changed and memory was increased to this huge
number no error is caught.

So let's do what virDomainDefGetMemoryInitial() would do, but
with error checking.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2216236
Fixes: f5d4f5c8ee44e9f1939070afcc5381bdd5545e50
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
src/qemu/qemu_domain.c