aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2012-10-04 17:48:58 -0300
committerMarcelo Tosatti <mtosatti@redhat.com>2012-10-30 23:39:46 -0200
commitdd87f8a690330777363f9a8680fce8f2ec544414 (patch)
tree15fb9012f2324a775d270a189eaefae74fb50a11
parent4fb73f1d3be285caeb52a58fa5eaea49bd918650 (diff)
i386: kvm: extract try_get_cpuid() loop to get_supported_cpuid() function
No behavior change, just code movement. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--target-i386/kvm.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index c94897f5d3..d74dbc152c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -98,6 +98,19 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
return cpuid;
}
+/* Run KVM_GET_SUPPORTED_CPUID ioctl(), allocating a buffer large enough
+ * for all entries.
+ */
+static struct kvm_cpuid2 *get_supported_cpuid(KVMState *s)
+{
+ struct kvm_cpuid2 *cpuid;
+ int max = 1;
+ while ((cpuid = try_get_cpuid(s, max)) == NULL) {
+ max *= 2;
+ }
+ return cpuid;
+}
+
struct kvm_para_features {
int cap;
int feature;
@@ -166,15 +179,11 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
uint32_t index, int reg)
{
struct kvm_cpuid2 *cpuid;
- int max;
uint32_t ret = 0;
uint32_t cpuid_1_edx;
bool found = false;
- max = 1;
- while ((cpuid = try_get_cpuid(s, max)) == NULL) {
- max *= 2;
- }
+ cpuid = get_supported_cpuid(s);
struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index);
if (entry) {