[libvirt] [PATCH 3/5] vmx: Refactor number parsing in virVMXParseConfig

Ján Tomko jtomko at redhat.com
Wed Apr 3 14:13:45 UTC 2019


On Wed, Apr 03, 2019 at 02:44:52PM +0200, Peter Krempa wrote:
>Parsing of the cpu affinity list was using virParseNumber. Modernize it
>to get rid of the virParseNumber call.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/vmx/vmx.c | 56 ++++++++++++++++++---------------------------------
> 1 file changed, 20 insertions(+), 36 deletions(-)
>
>diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
>index 429630faaf..70d9443766 100644
>--- a/src/vmx/vmx.c
>+++ b/src/vmx/vmx.c
>@@ -1500,43 +1500,35 @@ virVMXParseConfig(virVMXContext *ctx,
>+        if (!(afflist = virStringSplitCount(sched_cpu_affinity, ",", 0, &naffs)))
>+            goto cleanup;
>

>-            if (number >= VIR_DOMAIN_CPUMASK_LEN) {
>-                virReportError(VIR_ERR_INTERNAL_ERROR,
>-                               _("VMX entry 'sched.cpu.affinity' contains a %d, "
>-                                 "this value is too large"), number);
>-                goto cleanup;
>-            }

Even though an entry greater than VIR_DOMAIN_CPUMASK_LEN is unlikely, I
don't think a refactor should remove this check

>+        if (naffs < numvcpus) {
>+            virReportError(VIR_ERR_INTERNAL_ERROR,
>+                           _("Expecting VMX entry 'sched.cpu.affinity' to contain "
>+                             "at least as many values as 'numvcpus' (%lld) but "
>+                             "found only %zu value(s)"), numvcpus, naffs);
>+            goto cleanup;
>+        }
>
>-            ignore_value(virBitmapSetBit(def->cpumask, number));
>-            ++count;
>+        for (aff = afflist; *aff; aff++) {
>+            const char *current = *aff;
>+            unsigned int number;

With the check left in:
Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190403/93ca8ff0/attachment-0001.sig>


More information about the libvir-list mailing list