Signed-off-by: Yonggang Luo <[email protected]>
---
hw/core/machine-qmp-cmds.c | 16 ++++++++++++++++
qapi/machine.json | 5 ++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 59818764dad..620d64585e5 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -21,8 +21,10 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/type-helpers.h"
#include "qemu/uuid.h"
+#include "qemu/base-arch-defs.h"
#include "qemu/target-info.h"
#include "qemu/target-info-qapi.h"
+#include "qemu/target-info-qom.h"
#include "qom/qom-qobject.h"
#include "system/hostmem.h"
#include "system/hw_accel.h"
@@ -104,6 +106,8 @@ MachineInfoList *qmp_query_machines(bool has_compat_props,
bool compat_props,
MachineClass *mc = el->data;
const char *default_cpu_type = machine_class_default_cpu_type(mc);
MachineInfo *info;
+ QemuTargetInfoList **target_tail;
+ GSList *tel;
info = g_malloc0(sizeof(*info));
if (mc->is_default) {
@@ -130,6 +134,18 @@ MachineInfoList *qmp_query_machines(bool has_compat_props,
bool compat_props,
}
info->secure = object_class_is_secure(OBJECT_CLASS(mc));
+ target_tail = &info->targets;
+ for (tel = target_info_qom_get_targets(); tel; tel = tel->next) {
+ const TargetInfo *ti = TARGET_INFO_CLASS(tel->data)->target_info;
+
+ if (mc->targets & QEMU_ARCH_BIT(ti->target_arch)) {
+ QemuTargetInfo *target = g_new0(QemuTargetInfo, 1);
+
+ target->arch = ti->target_arch;
+ QAPI_LIST_APPEND(target_tail, target);
+ }
+ }
+
if (compat_props && mc->compat_props) {
int i;
info->compat_props = NULL;
diff --git a/qapi/machine.json b/qapi/machine.json
index 47fbc422ec5..ee089ff8c68 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -189,6 +189,9 @@
#
# @acpi: machine type supports ACPI (since 8.0)
#
+# @targets: targets supported by this machine
+# (since 11.2)
+#
# @compat-props: The machine type's compatibility properties. Only
# present when `query-machines` argument @compat-props is true.
# (since 9.1)
@@ -212,7 +215,7 @@
'*default-ram-id': 'str', 'acpi': 'bool',
'*compat-props': { 'type': ['CompatProperty'],
'features': ['unstable'] },
- 'secure': 'bool' } }
+ 'secure': 'bool', 'targets': ['QemuTargetInfo'] } }
##
# @query-machines:
--
2.55.0.windows.3