X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/199e19ee538eb61fd08b1c1ee5aa838ebdcc968e..0746a92612276aee69e66dfe6782b0f882d221d5:/qmp.c diff --git a/qmp.c b/qmp.c index 7ee9bcfdcf..f72261667f 100644 --- a/qmp.c +++ b/qmp.c @@ -16,11 +16,11 @@ #include "qemu/osdep.h" #include "qemu-version.h" #include "qemu/cutils.h" +#include "qemu/option.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/uuid.h" -#include "qmp-commands.h" #include "chardev/char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" @@ -30,8 +30,12 @@ #include "sysemu/blockdev.h" #include "sysemu/block-backend.h" #include "qom/qom-qobject.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-ui.h" +#include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" -#include "qapi/qmp/qobject.h" #include "qapi/qobject-input-visitor.h" #include "hw/boards.h" #include "qom/object_interfaces.h" @@ -113,11 +117,6 @@ void qmp_system_powerdown(Error **erp) qemu_system_powerdown_request(); } -void qmp_cpu(int64_t index, Error **errp) -{ - /* Just do nothing */ -} - void qmp_cpu_add(int64_t id, Error **errp) { MachineClass *mc; @@ -148,13 +147,13 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp) #ifndef CONFIG_SPICE /* - * qmp-commands.hx ensures that QMP command query-spice exists only - * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands - * result. However, the QAPI schema is blissfully unaware of that, - * and the QAPI code generator happily generates a dead - * qmp_marshal_query_spice() that calls qmp_query_spice(). Provide it - * one, or else linking fails. FIXME Educate the QAPI schema on - * CONFIG_SPICE. + * qmp_unregister_commands_hack() ensures that QMP command query-spice + * exists only #ifdef CONFIG_SPICE. Necessary for an accurate + * query-commands result. However, the QAPI schema is blissfully + * unaware of that, and the QAPI code generator happily generates a + * dead qmp_marshal_query_spice() that calls qmp_query_spice(). + * Provide it one, or else linking fails. FIXME Educate the QAPI + * schema on CONFIG_SPICE. */ SpiceInfo *qmp_query_spice(Error **errp) { @@ -164,10 +163,8 @@ SpiceInfo *qmp_query_spice(Error **errp) void qmp_cont(Error **errp) { - Error *local_err = NULL; BlockBackend *blk; - BlockDriverState *bs; - BdrvNextIterator it; + Error *local_err = NULL; /* if there is a dump in background, we should wait until the dump * finished */ @@ -187,14 +184,6 @@ void qmp_cont(Error **errp) blk_iostatus_reset(blk); } - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { - bdrv_add_key(bs, NULL, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - } - /* Continuing after completed migration. Images have been inactivated to * allow the destination to take control. Need to get control back now. * @@ -440,9 +429,15 @@ static void qom_list_types_tramp(ObjectClass *klass, void *data) { ObjectTypeInfoList *e, **pret = data; ObjectTypeInfo *info; + ObjectClass *parent = object_class_get_parent(klass); info = g_malloc0(sizeof(*info)); info->name = g_strdup(object_class_get_name(klass)); + info->has_abstract = info->abstract = object_class_is_abstract(klass); + if (parent) { + info->has_parent = true; + info->parent = g_strdup(object_class_get_name(parent)); + } e = g_malloc0(sizeof(*e)); e->value = info; @@ -470,12 +465,12 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, * * The caller must free the return value. */ -static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, - const char *name, - const char *default_type, - const char *description) +static ObjectPropertyInfo *make_device_property_info(ObjectClass *klass, + const char *name, + const char *default_type, + const char *description) { - DevicePropertyInfo *info; + ObjectPropertyInfo *info; Property *prop; do { @@ -490,13 +485,14 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, * for removal. This conditional should be removed along with * it. */ - if (!prop->info->set) { + if (!prop->info->set && !prop->info->create) { return NULL; /* no way to set it, don't show */ } info = g_malloc0(sizeof(*info)); info->name = g_strdup(prop->name); - info->type = g_strdup(prop->info->name); + info->type = default_type ? g_strdup(default_type) + : g_strdup(prop->info->name); info->has_description = !!prop->info->description; info->description = g_strdup(prop->info->description); return info; @@ -514,14 +510,14 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, return info; } -DevicePropertyInfoList *qmp_device_list_properties(const char *typename, - Error **errp) +ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, + Error **errp) { ObjectClass *klass; Object *obj; ObjectProperty *prop; ObjectPropertyIterator iter; - DevicePropertyInfoList *prop_list = NULL; + ObjectPropertyInfoList *prop_list = NULL; klass = object_class_by_name(typename); if (klass == NULL) { @@ -546,8 +542,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, object_property_iter_init(&iter, obj); while ((prop = object_property_iter_next(&iter))) { - DevicePropertyInfo *info; - DevicePropertyInfoList *entry; + ObjectPropertyInfo *info; + ObjectPropertyInfoList *entry; /* Skip Object and DeviceState properties */ if (strcmp(prop->name, "type") == 0 || @@ -582,6 +578,55 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, return prop_list; } +ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, + Error **errp) +{ + ObjectClass *klass; + Object *obj = NULL; + ObjectProperty *prop; + ObjectPropertyIterator iter; + ObjectPropertyInfoList *prop_list = NULL; + + klass = object_class_by_name(typename); + if (klass == NULL) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Class '%s' not found", typename); + return NULL; + } + + klass = object_class_dynamic_cast(klass, TYPE_OBJECT); + if (klass == NULL) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_OBJECT); + return NULL; + } + + if (object_class_is_abstract(klass)) { + object_class_property_iter_init(&iter, klass); + } else { + obj = object_new(typename); + object_property_iter_init(&iter, obj); + } + while ((prop = object_property_iter_next(&iter))) { + ObjectPropertyInfo *info; + ObjectPropertyInfoList *entry; + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(prop->name); + info->type = g_strdup(prop->type); + info->has_description = !!prop->description; + info->description = g_strdup(prop->description); + + entry = g_malloc0(sizeof(*entry)); + entry->value = info; + entry->next = prop_list; + prop_list = entry; + } + + object_unref(obj); + + return prop_list; +} + CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) { return arch_query_cpu_definitions(errp); @@ -660,7 +705,7 @@ void qmp_object_add(const char *type, const char *id, Object *obj; if (props) { - pdict = qobject_to_qdict(props); + pdict = qobject_to(QDict, props); if (!pdict) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); return; @@ -686,12 +731,7 @@ void qmp_object_del(const char *id, Error **errp) MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) { - MemoryDeviceInfoList *head = NULL; - MemoryDeviceInfoList **prev = &head; - - qmp_pc_dimm_device_list(qdev_get_machine(), &prev); - - return head; + return qmp_pc_dimm_device_list(); } ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp) @@ -712,3 +752,32 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp) return head; } + +MemoryInfo *qmp_query_memory_size_summary(Error **errp) +{ + MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo)); + + mem_info->base_memory = ram_size; + + mem_info->plugged_memory = get_plugged_memory_size(); + mem_info->has_plugged_memory = + mem_info->plugged_memory != (uint64_t)-1; + + return mem_info; +} + +static QemuSemaphore x_oob_test_sem; + +static void __attribute__((constructor)) x_oob_test_init(void) +{ + qemu_sem_init(&x_oob_test_sem, 0); +} + +void qmp_x_oob_test(bool lock, Error **errp) +{ + if (lock) { + qemu_sem_wait(&x_oob_test_sem); + } else { + qemu_sem_post(&x_oob_test_sem); + } +}