[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [Fwd: [PATCH] Fix virt-install cpuset check]



Hi there,

there was an error (exception) when trying to set cpuset pinning string
that was ending with comma because of function was trying to convert an
empty string as well. This was throwing an exception for string ending
with comma, strings like "1,"... So this patch fixes this and sets the
cpuset value to the one with this ending comma stripped, ie. "1" instead
of "1,".

Thanks,
Michal


# HG changeset patch
# User Michal Novotny <minovotn redhat com>
# Date 1248686159 -7200
# Node ID 55f259019028f0084c72cf32cc7b40dcfe2d2787
# Parent  a4baddfadf5c61a8779129edf83ea64c69ea552a
Fix CPU Pinning check for pinning string ending with comma

When you provided CPU pinning string that was ending with comma an
uncaught exception occured of ValueError about invalid literal for
int() with base 10 because of empty string passed to int() function.
This patch fixes the lines ending with comma, lines like "1," and
corrects this to correct CPU pinning string, ie. "1".

diff -r a4baddfadf5c -r 55f259019028 virtinst/Guest.py
--- a/virtinst/Guest.py	Mon Jul 20 11:18:30 2009 -0400
+++ b/virtinst/Guest.py	Mon Jul 27 11:15:59 2009 +0200
@@ -196,9 +196,11 @@
                     raise ValueError, _("cpuset's pCPU numbers must be less "
                                         "than pCPUs.")
             else:
-                if int(c) >= pcpus:
-                    raise ValueError, _("cpuset's pCPU numbers must be less "
-                                        "than pCPUs.")
+                if len(c) > 0:
+                    val = int(c)
+                    if val >= pcpus:
+                        raise ValueError, _("cpuset's pCPU numbers must be less "
+                                            "than pCPUs.")
         self._cpuset = val
     cpuset = property(get_cpuset, set_cpuset)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]