diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2017-10-03 16:27:24 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2017-10-03 16:27:24 +0100 |
| commit | d147f7e815f97cb477e223586bcb80c316ae10ea (patch) | |
| tree | 0f3c63f73bbfa50deafd9fca0a73d9e76597146a /accel/kvm/kvm-all.c | |
| parent | 0b7fe5aed7381802600a844742920935774bb6c6 (diff) | |
| parent | 346b1215b1e9f7cc6d8fe9fb6f3c2778b890afb6 (diff) | |
| download | focaccia-qemu-d147f7e815f97cb477e223586bcb80c316ae10ea.tar.gz focaccia-qemu-d147f7e815f97cb477e223586bcb80c316ae10ea.zip | |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* iothread bugfix (Eduardo) * Linux headers sync (Dave) * .gitignore fix (Eric) * KVM capability check fixes (Greg) * kvmclock fix (Jim) # gpg: Signature made Mon 02 Oct 2017 14:31:09 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: kvmclock: use the updated system_timer_msr kvm: check KVM_CAP_NR_VCPUS with kvm_vm_check_extension() kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension() linux-headers: sync against v4.14-rc1 iothread: Make iothread_stop() idempotent scsi: Ignore executable for in-tree builds Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'accel/kvm/kvm-all.c')
| -rw-r--r-- | accel/kvm/kvm-all.c | 51 |
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) |