Revision 3ed444e9 kvm-all.c
b/kvm-all.c | ||
---|---|---|
1207 | 1207 |
return 0; |
1208 | 1208 |
} |
1209 | 1209 |
|
1210 |
static int kvm_max_vcpus(KVMState *s) |
|
1211 |
{ |
|
1212 |
int ret; |
|
1213 |
|
|
1214 |
/* Find number of supported CPUs using the recommended |
|
1215 |
* procedure from the kernel API documentation to cope with |
|
1216 |
* older kernels that may be missing capabilities. |
|
1217 |
*/ |
|
1218 |
ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS); |
|
1219 |
if (ret) { |
|
1220 |
return ret; |
|
1221 |
} |
|
1222 |
ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS); |
|
1223 |
if (ret) { |
|
1224 |
return ret; |
|
1225 |
} |
|
1226 |
|
|
1227 |
return 4; |
|
1228 |
} |
|
1229 |
|
|
1210 | 1230 |
int kvm_init(void) |
1211 | 1231 |
{ |
1212 | 1232 |
static const char upgrade_note[] = |
... | ... | |
1216 | 1236 |
const KVMCapabilityInfo *missing_cap; |
1217 | 1237 |
int ret; |
1218 | 1238 |
int i; |
1239 |
int max_vcpus; |
|
1219 | 1240 |
|
1220 | 1241 |
s = g_malloc0(sizeof(KVMState)); |
1221 | 1242 |
|
... | ... | |
1256 | 1277 |
goto err; |
1257 | 1278 |
} |
1258 | 1279 |
|
1280 |
max_vcpus = kvm_max_vcpus(s); |
|
1281 |
if (smp_cpus > max_vcpus) { |
|
1282 |
ret = -EINVAL; |
|
1283 |
fprintf(stderr, "Number of SMP cpus requested (%d) exceeds max cpus " |
|
1284 |
"supported by KVM (%d)\n", smp_cpus, max_vcpus); |
|
1285 |
goto err; |
|
1286 |
} |
|
1287 |
|
|
1259 | 1288 |
s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0); |
1260 | 1289 |
if (s->vmfd < 0) { |
1261 | 1290 |
#ifdef TARGET_S390X |
Also available in: Unified diff