diff --git a/hmp-commands.hx b/hmp-commands.hx index df44906ef94ba8da74565044bb21430d301264b7..3d98604f779fbae48fc66bf3686fb3566ec30dbe 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1643,6 +1643,8 @@ show qdev device model list show roms @item info tpm show the TPM device +@item info cpu_max +show the number of CPUs supported by the machine being emulated. @end table ETEXI diff --git a/hmp.c b/hmp.c index d319897767f0751e0be289ebe6ab22b59012585b..c12c495dc4c869ea9f20ea7d75a0db8965e02926 100644 --- a/hmp.c +++ b/hmp.c @@ -748,6 +748,14 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) g_free(data); } +void hmp_query_cpu_max(Monitor *mon, const QDict *qdict) +{ + int cpu_max; + + cpu_max = qmp_query_cpu_max(NULL); + monitor_printf(mon, "Maximum number of CPUs is %d\n", cpu_max); +} + static void hmp_cont_cb(void *opaque, int err) { if (!err) { diff --git a/hmp.h b/hmp.h index 95fe76e218f48ee6fb9ccb37768a85350deaa1e9..80e8b412d4279d88a2fb9d9f70704a6112ab856a 100644 --- a/hmp.h +++ b/hmp.h @@ -42,6 +42,7 @@ void hmp_stop(Monitor *mon, const QDict *qdict); void hmp_system_reset(Monitor *mon, const QDict *qdict); void hmp_system_powerdown(Monitor *mon, const QDict *qdict); void hmp_cpu(Monitor *mon, const QDict *qdict); +void hmp_query_cpu_max(Monitor *mon, const QDict *qdict); void hmp_memsave(Monitor *mon, const QDict *qdict); void hmp_pmemsave(Monitor *mon, const QDict *qdict); void hmp_ringbuf_write(Monitor *mon, const QDict *qdict); diff --git a/monitor.c b/monitor.c index 2d9e8878ebf6610fe38c74b3f3c2fe1258a7e56d..e450919269e1914130e193e64cc9ca9b180095e1 100644 --- a/monitor.c +++ b/monitor.c @@ -2745,6 +2745,13 @@ static mon_cmd_t info_cmds[] = { .help = "show the TPM device", .mhandler.cmd = hmp_info_tpm, }, + { + .name = "cpu_max", + .args_type = "", + .params = "", + .help = "Get maximum number of VCPUs supported by machine", + .mhandler.cmd = hmp_query_cpu_max, + }, { .name = NULL, }, diff --git a/qapi-schema.json b/qapi-schema.json index 0d16d14e4fdf4ab7d10f6428fa52409167bd59b6..af499bd92607e5128950ac24c9ee5feb50098727 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1831,6 +1831,17 @@ ## { 'command': 'query-migrate-cache-size', 'returns': 'int' } +## +## @query-cpu-max +## +## query maximum number of CPUs supported by machine +## +## Returns: number of CPUs +## +## Since: 1.5 +### +{ 'command': 'query-cpu-max', 'returns': 'int' } + ## # @ObjectPropertyInfo: # diff --git a/qmp-commands.hx b/qmp-commands.hx index 3aa6bd1bd9efcf9197e318f3dfad5bbfd7541362..2051fcb49ce2ea5b9437697bcad88046d88d170a 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -382,6 +382,28 @@ Example: Note: CPUs' indexes are obtained with the 'query-cpus' command. +EQMP + + { + .name = "query-cpu-max", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_cpu_max, + }, + +SQMP +query-cpu-max +------------- + +Get the maximum CPUs supported by the machine being currently +emulated. + +Returns json-int. + +Example: + +-> { "execute": "query-cpu-max" } +<- { "return": 255 } + EQMP { diff --git a/vl.c b/vl.c index aeed7f435dc09309e382059ba3af752bdd9e41b0..7643f163512bb5cf22a36797e9eeef5ba77eff0f 100644 --- a/vl.c +++ b/vl.c @@ -662,6 +662,11 @@ StatusInfo *qmp_query_status(Error **errp) return info; } +int64_t qmp_query_cpu_max(Error **errp) +{ + return current_machine->max_cpus; +} + /***********************************************************/ /* real time host monotonic timer */