i386: kvm: kvm_arch_get_supported_cpuid: clean up has_kvm_features check

Instead of a function-specific has_kvm_features variable, simply use a
"found" variable that will be checked in case we have to use the legacy
get_para_features() interface.

No behavior change, just code cleanup.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Eduardo Habkost 2012-10-04 17:48:54 -03:00 committed by Marcelo Tosatti
parent 7b46e5ce81
commit 8c723b7958
1 changed files with 3 additions and 5 deletions

View File

@ -130,7 +130,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
int i, max; int i, max;
uint32_t ret = 0; uint32_t ret = 0;
uint32_t cpuid_1_edx; uint32_t cpuid_1_edx;
int has_kvm_features = 0; bool found = false;
max = 1; max = 1;
while ((cpuid = try_get_cpuid(s, max)) == NULL) { while ((cpuid = try_get_cpuid(s, max)) == NULL) {
@ -140,9 +140,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
for (i = 0; i < cpuid->nent; ++i) { for (i = 0; i < cpuid->nent; ++i) {
if (cpuid->entries[i].function == function && if (cpuid->entries[i].function == function &&
cpuid->entries[i].index == index) { cpuid->entries[i].index == index) {
if (cpuid->entries[i].function == KVM_CPUID_FEATURES) { found = true;
has_kvm_features = 1;
}
switch (reg) { switch (reg) {
case R_EAX: case R_EAX:
ret = cpuid->entries[i].eax; ret = cpuid->entries[i].eax;
@ -181,7 +179,7 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
g_free(cpuid); g_free(cpuid);
/* fallback for older kernels */ /* fallback for older kernels */
if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) { if ((function == KVM_CPUID_FEATURES) && !found) {
ret = get_para_features(s); ret = get_para_features(s);
} }