[libvirt] [PATCH] vmx: Remove check that numvcpus has to be an even number.

Richard W.M. Jones posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180530093345.19562-2-rjones@redhat.com
Test syntax-check passed
src/vmx/vmx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[libvirt] [PATCH] vmx: Remove check that numvcpus has to be an even number.
Posted by Richard W.M. Jones 5 years, 10 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1584091

It is possible to create a VMware guest with an odd number of vCPUs,
but such guests cannot be accessed by libvirt because of this
unnecessary check.

I retained the sanity-check that numvcpus must be >= 1.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 src/vmx/vmx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index bdc27b15b0..456bbaf190 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1506,10 +1506,10 @@ virVMXParseConfig(virVMXContext *ctx,
     if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0)
         goto cleanup;
 
-    if (numvcpus <= 0 || (numvcpus % 2 != 0 && numvcpus != 1)) {
+    if (numvcpus <= 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Expecting VMX entry 'numvcpus' to be an unsigned "
-                         "integer (1 or a multiple of 2) but found %lld"), numvcpus);
+                       _("Expecting VMX entry 'numvcpus' to be a positive "
+                         "integer >= 1, but found %lld"), numvcpus);
         goto cleanup;
     }
 
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vmx: Remove check that numvcpus has to be an even number.
Posted by Peter Krempa 5 years, 10 months ago
On Wed, May 30, 2018 at 10:33:45 +0100, Richard W.M. Jones wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1584091
> 
> It is possible to create a VMware guest with an odd number of vCPUs,
> but such guests cannot be accessed by libvirt because of this
> unnecessary check.
> 
> I retained the sanity-check that numvcpus must be >= 1.
> 
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> ---
>  src/vmx/vmx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
> index bdc27b15b0..456bbaf190 100644
> --- a/src/vmx/vmx.c
> +++ b/src/vmx/vmx.c
> @@ -1506,10 +1506,10 @@ virVMXParseConfig(virVMXContext *ctx,
>      if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0)
>          goto cleanup;
>  
> -    if (numvcpus <= 0 || (numvcpus % 2 != 0 && numvcpus != 1)) {
> +    if (numvcpus <= 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
> -                       _("Expecting VMX entry 'numvcpus' to be an unsigned "
> -                         "integer (1 or a multiple of 2) but found %lld"), numvcpus);
> +                       _("Expecting VMX entry 'numvcpus' to be a positive "
> +                         "integer >= 1, but found %lld"), numvcpus);
>          goto cleanup;
>      }

The same check is in virVMXFormatConfig:

maxvcpus = virDomainDefGetVcpusMax(def);
if (maxvcpus == 0 || (maxvcpus % 2 != 0 && maxvcpus != 1)) {
    virReportError(VIR_ERR_INTERNAL_ERROR,
                   _("Expecting domain XML entry 'vcpu' to be 1 or a "
                     "multiple of 2 but found %d"),
                   maxvcpus);
    goto cleanup;
}

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vmx: Remove check that numvcpus has to be an even number.
Posted by Pino Toscano 5 years, 10 months ago
On Wednesday, 30 May 2018 11:33:45 CEST Richard W.M. Jones wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1584091
> 
> It is possible to create a VMware guest with an odd number of vCPUs,
> but such guests cannot be accessed by libvirt because of this
> unnecessary check.
> 
> I retained the sanity-check that numvcpus must be >= 1.
> 
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> ---

NACK until there is a reply to
https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html

Also, this patch is incomplete, since:
- there giant "documentation" comment at the beginning was not updated
- virVMXFormatConfig has the very same check

That is why I did not send this patch yet: the check was added on
purpose (documented, and implemented), so there must be a reason, even
if trivial.  I can take care of this, but after knowing a bit more.

-- 
Pino Toscano--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list