struct framebuffer *fb = NULL;
unsigned int nr_online_cpus;
int exit_code = 0;
- int max_cpus;
+ int max_cpus, recommended_cpus;
char *hi;
int i;
void *ret;
ioeventfd__init();
max_cpus = kvm__max_cpus(kvm);
+ recommended_cpus = kvm__recommended_cpus(kvm);
if (nrcpus > max_cpus) {
printf(" # Limit the number of CPUs to %d\n", max_cpus);
kvm->nrcpus = max_cpus;
+ } else if (nrcpus > recommended_cpus) {
+ printf(" # Warning: The maximum recommended amount of VCPUs"
+ " is %d\n", recommended_cpus);
}
kvm->nrcpus = nrcpus;
};
struct kvm *kvm__init(const char *kvm_dev, u64 ram_size, const char *name);
+int kvm__recommended_cpus(struct kvm *kvm);
int kvm__max_cpus(struct kvm *kvm);
void kvm__init_ram(struct kvm *kvm);
void kvm__delete(struct kvm *kvm);
}
}
-int kvm__max_cpus(struct kvm *kvm)
+int kvm__recommended_cpus(struct kvm *kvm)
{
int ret;
ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS);
- if (ret < 0)
+ if (ret <= 0)
die_perror("KVM_CAP_NR_VCPUS");
return ret;
}
+/*
+ * The following hack should be removed once 'x86: Raise the hard
+ * VCPU count limit' makes it's way into the mainline.
+ */
+#ifndef KVM_CAP_MAX_VCPUS
+#define KVM_CAP_MAX_VCPUS 66
+#endif
+
+int kvm__max_cpus(struct kvm *kvm)
+{
+ int ret;
+
+ ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
+ if (ret <= 0)
+ ret = kvm__recommended_cpus(kvm);
+
+ return ret;
+}
+
struct kvm *kvm__init(const char *kvm_dev, u64 ram_size, const char *name)
{
struct kvm_pit_config pit_config = { .flags = 0, };