aboutsummaryrefslogtreecommitdiff
path: root/accel/kvm/kvm-all.c
diff options
context:
space:
mode:
Diffstat (limited to 'accel/kvm/kvm-all.c')
-rw-r--r--accel/kvm/kvm-all.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4f1997deec..90c88b517d 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -87,6 +87,7 @@ struct KVMState
#endif
int many_ioeventfds;
int intx_set_mask;
+ bool sync_mmu;
/* The man page (and posix) say ioctl numbers are signed int, but
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
* unsigned, and treating them as signed here can break things */
@@ -1439,7 +1440,7 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
*/
static int kvm_recommended_vcpus(KVMState *s)
{
- int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
+ int ret = kvm_vm_check_extension(s, KVM_CAP_NR_VCPUS);
return (ret) ? ret : 4;
}
@@ -1529,26 +1530,6 @@ static int kvm_init(MachineState *ms)
s->nr_slots = 32;
}
- /* check the vcpu limits */
- soft_vcpus_limit = kvm_recommended_vcpus(s);
- hard_vcpus_limit = kvm_max_vcpus(s);
-
- while (nc->name) {
- if (nc->num > soft_vcpus_limit) {
- warn_report("Number of %s cpus requested (%d) exceeds "
- "the recommended cpus supported by KVM (%d)",
- nc->name, nc->num, soft_vcpus_limit);
-
- if (nc->num > hard_vcpus_limit) {
- fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
- "the maximum cpus supported by KVM (%d)\n",
- nc->name, nc->num, hard_vcpus_limit);
- exit(1);
- }
- }
- nc++;
- }
-
kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type");
if (mc->kvm_type) {
type = mc->kvm_type(kvm_type);
@@ -1583,6 +1564,27 @@ static int kvm_init(MachineState *ms)
}
s->vmfd = ret;
+
+ /* check the vcpu limits */
+ soft_vcpus_limit = kvm_recommended_vcpus(s);
+ hard_vcpus_limit = kvm_max_vcpus(s);
+
+ while (nc->name) {
+ if (nc->num > soft_vcpus_limit) {
+ warn_report("Number of %s cpus requested (%d) exceeds "
+ "the recommended cpus supported by KVM (%d)",
+ nc->name, nc->num, soft_vcpus_limit);
+
+ if (nc->num > hard_vcpus_limit) {
+ fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
+ "the maximum cpus supported by KVM (%d)\n",
+ nc->name, nc->num, hard_vcpus_limit);
+ exit(1);
+ }
+ }
+ nc++;
+ }
+
missing_cap = kvm_check_extension_list(s, kvm_required_capabilites);
if (!missing_cap) {
missing_cap =
@@ -1664,6 +1666,8 @@ static int kvm_init(MachineState *ms)
s->many_ioeventfds = kvm_check_many_ioeventfds();
+ s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
+
return 0;
err:
@@ -2130,10 +2134,9 @@ int kvm_device_access(int fd, int group, uint64_t attr,
return err;
}
-/* Return 1 on success, 0 on failure */
-int kvm_has_sync_mmu(void)
+bool kvm_has_sync_mmu(void)
{
- return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
+ return kvm_state->sync_mmu;
}
int kvm_has_vcpu_events(void)