X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qmp.c;h=fa82b598c6d0c58c4919cc2a2d5451f7c70a67e2;hb=6d54af0ea9eeee70b4c0eb48bd2ae1d22b207dd4;hp=dea8f81345b5623175c0f954b0ba15ddd270e333;hpb=f9ae6bcf1d4659867cfc5e6d90a5e7fdad02280b;p=mirror_qemu.git diff --git a/qmp.c b/qmp.c index dea8f81345..fa82b598c6 100644 --- a/qmp.c +++ b/qmp.c @@ -18,6 +18,8 @@ #include "qemu/cutils.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" +#include "qemu/config-file.h" +#include "qemu/uuid.h" #include "qmp-commands.h" #include "sysemu/char.h" #include "ui/qemu-spice.h" @@ -30,7 +32,7 @@ #include "qom/qom-qobject.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qobject.h" -#include "qapi/qmp-input-visitor.h" +#include "qapi/qobject-input-visitor.h" #include "hw/boards.h" #include "qom/object_interfaces.h" #include "hw/mem/pc-dimm.h" @@ -51,21 +53,11 @@ NameInfo *qmp_query_name(Error **errp) VersionInfo *qmp_query_version(Error **errp) { VersionInfo *info = g_new0(VersionInfo, 1); - const char *version = QEMU_VERSION; - const char *tmp; - int err; info->qemu = g_new0(VersionTriple, 1); - err = qemu_strtoll(version, &tmp, 10, &info->qemu->major); - assert(err == 0); - tmp++; - - err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->minor); - assert(err == 0); - tmp++; - - err = qemu_strtoll(tmp, &tmp, 10, &info->qemu->micro); - assert(err == 0); + info->qemu->major = QEMU_VERSION_MAJOR; + info->qemu->minor = QEMU_VERSION_MINOR; + info->qemu->micro = QEMU_VERSION_MICRO; info->package = g_strdup(QEMU_PKGVERSION); return info; @@ -84,15 +76,8 @@ KvmInfo *qmp_query_kvm(Error **errp) UuidInfo *qmp_query_uuid(Error **errp) { UuidInfo *info = g_malloc0(sizeof(*info)); - char uuid[64]; - snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1], - qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], - qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], - qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], - qemu_uuid[14], qemu_uuid[15]); - - info->UUID = g_strdup(uuid); + info->UUID = qemu_uuid_unparse_strdup(&qemu_uuid); return info; } @@ -446,8 +431,8 @@ void qmp_change(const char *device, const char *target, if (strcmp(device, "vnc") == 0) { qmp_change_vnc(target, has_arg, arg, errp); } else { - qmp_blockdev_change_medium(device, target, has_arg, arg, false, 0, - errp); + qmp_blockdev_change_medium(true, device, false, NULL, target, + has_arg, arg, false, 0, errp); } } @@ -547,12 +532,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, klass = object_class_dynamic_cast(klass, TYPE_DEVICE); if (klass == NULL) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name", TYPE_DEVICE); + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_DEVICE); return NULL; } if (object_class_is_abstract(klass)) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "name", + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", "non-abstract device type"); return NULL; } @@ -632,7 +617,7 @@ void qmp_add_client(const char *protocol, const char *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool tls, Error **errp) { - CharDriverState *s; + Chardev *s; int fd; fd = monitor_get_fd(cur_mon, fdname, errp); @@ -675,7 +660,7 @@ void qmp_add_client(const char *protocol, const char *fdname, void qmp_object_add(const char *type, const char *id, bool has_props, QObject *props, Error **errp) { - const QDict *pdict = NULL; + QDict *pdict; Visitor *v; Object *obj; @@ -685,14 +670,18 @@ void qmp_object_add(const char *type, const char *id, error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); return; } + QINCREF(pdict); + } else { + pdict = qdict_new(); } - v = qmp_input_visitor_new(props, true); + v = qobject_input_visitor_new(QOBJECT(pdict)); obj = user_creatable_add_type(type, id, pdict, v, errp); visit_free(v); if (obj) { object_unref(obj); } + QDECREF(pdict); } void qmp_object_del(const char *id, Error **errp)