From: Michal Privoznik <mprivozn@redhat.com>
When parsing <vcpu/> part of domain XML, the number of vCPUs is
parsed using virStrToLong_ui() which allows int wrapping (i.e.
specifying -1 as a shortcut for UINT_MAX). Well, this is against:
a) our RNG schema, which allows only positive integers, and
b) documentation ("(value) ... must be between 1 and the maximum
supported by the hypervisor").
Switch to virStrToLong_uip() which rejects negative numbers.
Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/945
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
I think I've seen another incarnation of this bug not so long ago, but
couldn't find it. In the end, it doesn't matter.
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 69c2304f28..51140aa652 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18410,7 +18410,7 @@ virDomainVcpuParse(virDomainDef *def,
if (!(tmp = virXMLNodeContentString(vcpuNode)))
return -1;
- if (virStrToLong_ui(tmp, NULL, 10, &maxvcpus) < 0) {
+ if (virStrToLong_uip(tmp, NULL, 10, &maxvcpus) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("maximum vcpus count must be an integer"));
return -1;
--
2.56.0
On Tue, Oct 27, 2026 at 12:36:29 +0100, Michal Privoznik wrote:
> From: Michal Privoznik <mprivozn@redhat.com>
>
> When parsing <vcpu/> part of domain XML, the number of vCPUs is
> parsed using virStrToLong_ui() which allows int wrapping (i.e.
> specifying -1 as a shortcut for UINT_MAX). Well, this is against:
>
> a) our RNG schema, which allows only positive integers, and
> b) documentation ("(value) ... must be between 1 and the maximum
> supported by the hypervisor").
>
> Switch to virStrToLong_uip() which rejects negative numbers.
>
> Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/945
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>
> I think I've seen another incarnation of this bug not so long ago, but
> couldn't find it. In the end, it doesn't matter.
>
> src/conf/domain_conf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 69c2304f28..51140aa652 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -18410,7 +18410,7 @@ virDomainVcpuParse(virDomainDef *def,
> if (!(tmp = virXMLNodeContentString(vcpuNode)))
> return -1;
>
> - if (virStrToLong_ui(tmp, NULL, 10, &maxvcpus) < 0) {
> + if (virStrToLong_uip(tmp, NULL, 10, &maxvcpus) < 0) {
> virReportError(VIR_ERR_XML_ERROR, "%s",
> _("maximum vcpus count must be an integer"));
> return -1;
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
I found your discussion on denying negative vcpu counts quite intriguing! It really highlights how small details can significantly impact virtualization management. I'm curious, what inspired the need to enforce this rule? I had a similar experience while setting up virtual machines for game hosting — I accidentally set an absurd amount of resources, and it crashed everything! If you could share any examples where this issue caused major headaches in real-world scenarios, that would be fascinating. Thanks for shedding light on such an important topic! https://basketballstars2026.io
The best part is that no two challenges need to feel exactly the same. Some puzzles may be solved quickly, while others demand every bit of your patience and creativity. That unpredictable difficulty keeps players engaged and makes every successful solution feel satisfying. https://dordle.io
© 2016 - 2026 Red Hat, Inc.