On Fri, Mar 22, 2013 at 5:36 AM, Mike Qiu <[email protected]> wrote:
> From: Mike Qiu <[email protected]>
>
> Currently, autotest support amd and intel's X86 cpu type, IBM Power
> cpus will be configure as 'unknown'.
>
> Add pattern to deal with the cpuinfo of power, so that can figure
> out the vendor IBM.
>
> Signed-off-by: Mike Qiu <[email protected]>
> ---
> virttest/utils_misc.py | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/virttest/utils_misc.py b/virttest/utils_misc.py
> index 2eba264..f1904dc 100644
> --- a/virttest/utils_misc.py
> +++ b/virttest/utils_misc.py
> @@ -556,11 +556,14 @@ def get_cpu_flags():
> """
> Returns a list of the CPU flags
> """
> - flags_re = re.compile(r'^flags\s*:(.*)')
> + flags_re = re.compile(r'^flags\s*:(.*)|^cpu\s*:(.*)')
> for line in open('/proc/cpuinfo').readlines():
> match = flags_re.match(line)
> if match:
> - return match.groups()[0].split()
> + if match.groups()[0]:
> + return match.groups()[0].split()
> + else:
> + return match.groups()[1].strip().split(', ')
> return []
^ Indentation is off, here's a diff of what it needs to be fixed:
diff --git a/virttest/utils_misc.py b/virttest/utils_misc.py
index f1904dc..19f985a 100644
--- a/virttest/utils_misc.py
+++ b/virttest/utils_misc.py
@@ -561,9 +561,9 @@ def get_cpu_flags():
match = flags_re.match(line)
if match:
if match.groups()[0]:
- return match.groups()[0].split()
+ return match.groups()[0].split()
else:
- return match.groups()[1].strip().split(', ')
+ return match.groups()[1].strip().split(', ')
return []
>
> @@ -575,6 +578,8 @@ def get_cpu_vendor(cpu_flags=[], verbose=True):
> vendor = 'intel'
> elif 'svm' in cpu_flags:
> vendor = 'amd'
> + elif 'POWER' in cpu_flags:
> + vendor = 'IBM'
^ As far as I know, CPU flags don't come capitalized, do they?
Also, if you verify, in some parts of the code where we call
get_cpu_vendor, you'll notice that the code expects a result in lower
case:
check_modules = ["kvm", "kvm-%s" % utils_misc.get_cpu_vendor(verbose=False)]
In the code above, is the name of the kvm module on ppc64 kvm-IBM? I
don't think so.
So you need to take into account all callers here. Also, I'd like you
to add a unittest to utils_misc_unittest with the cpu flags expected
to be found on a power 7 machine, then calling the function and have
it return the proper value.
_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel