]>
git.proxmox.com Git - qemu.git/blob - qmp.c
2 * QEMU Management Protocol
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #include "qemu-common.h"
16 #include "qmp-commands.h"
18 #include "arch_init.h"
21 NameInfo
*qmp_query_name(Error
**errp
)
23 NameInfo
*info
= g_malloc0(sizeof(*info
));
26 info
->has_name
= true;
27 info
->name
= g_strdup(qemu_name
);
33 VersionInfo
*qmp_query_version(Error
**err
)
35 VersionInfo
*info
= g_malloc0(sizeof(*info
));
36 const char *version
= QEMU_VERSION
;
39 info
->qemu
.major
= strtol(version
, &tmp
, 10);
41 info
->qemu
.minor
= strtol(tmp
, &tmp
, 10);
43 info
->qemu
.micro
= strtol(tmp
, &tmp
, 10);
44 info
->package
= g_strdup(QEMU_PKGVERSION
);
49 KvmInfo
*qmp_query_kvm(Error
**errp
)
51 KvmInfo
*info
= g_malloc0(sizeof(*info
));
53 info
->enabled
= kvm_enabled();
54 info
->present
= kvm_available();
59 UuidInfo
*qmp_query_uuid(Error
**errp
)
61 UuidInfo
*info
= g_malloc0(sizeof(*info
));
64 snprintf(uuid
, sizeof(uuid
), UUID_FMT
, qemu_uuid
[0], qemu_uuid
[1],
65 qemu_uuid
[2], qemu_uuid
[3], qemu_uuid
[4], qemu_uuid
[5],
66 qemu_uuid
[6], qemu_uuid
[7], qemu_uuid
[8], qemu_uuid
[9],
67 qemu_uuid
[10], qemu_uuid
[11], qemu_uuid
[12], qemu_uuid
[13],
68 qemu_uuid
[14], qemu_uuid
[15]);
70 info
->UUID
= g_strdup(uuid
);
74 void qmp_quit(Error
**err
)
77 qemu_system_shutdown_request();
80 void qmp_stop(Error
**errp
)
82 vm_stop(RUN_STATE_PAUSED
);
85 void qmp_system_reset(Error
**errp
)
87 qemu_system_reset_request();
90 void qmp_system_powerdown(Error
**erp
)
92 qemu_system_powerdown_request();
95 void qmp_cpu(int64_t index
, Error
**errp
)
101 /* If VNC support is enabled, the "true" query-vnc command is
102 defined in the VNC subsystem */
103 VncInfo
*qmp_query_vnc(Error
**errp
)
105 error_set(errp
, QERR_FEATURE_DISABLED
, "vnc");
111 /* If SPICE support is enabled, the "true" query-spice command is
112 defined in the SPICE subsystem. Also note that we use a small
113 trick to maintain query-spice's original behavior, which is not
114 to be available in the namespace if SPICE is not compiled in */
115 SpiceInfo
*qmp_query_spice(Error
**errp
)
117 error_set(errp
, QERR_COMMAND_NOT_FOUND
, "query-spice");
122 static void iostatus_bdrv_it(void *opaque
, BlockDriverState
*bs
)
124 bdrv_iostatus_reset(bs
);
127 static void encrypted_bdrv_it(void *opaque
, BlockDriverState
*bs
)
129 Error
**err
= opaque
;
131 if (!error_is_set(err
) && bdrv_key_required(bs
)) {
132 error_set(err
, QERR_DEVICE_ENCRYPTED
, bdrv_get_device_name(bs
));
136 void qmp_cont(Error
**errp
)
138 Error
*local_err
= NULL
;
140 if (runstate_check(RUN_STATE_INMIGRATE
)) {
141 error_set(errp
, QERR_MIGRATION_EXPECTED
);
143 } else if (runstate_check(RUN_STATE_INTERNAL_ERROR
) ||
144 runstate_check(RUN_STATE_SHUTDOWN
)) {
145 error_set(errp
, QERR_RESET_REQUIRED
);
149 bdrv_iterate(iostatus_bdrv_it
, NULL
);
150 bdrv_iterate(encrypted_bdrv_it
, &local_err
);
152 error_propagate(errp
, local_err
);
159 DevicePropertyInfoList
*qmp_qom_list(const char *path
, Error
**errp
)
162 bool ambiguous
= false;
163 DevicePropertyInfoList
*props
= NULL
;
164 DeviceProperty
*prop
;
166 dev
= qdev_resolve_path(path
, &ambiguous
);
168 error_set(errp
, QERR_DEVICE_NOT_FOUND
, path
);
172 QTAILQ_FOREACH(prop
, &dev
->properties
, node
) {
173 DevicePropertyInfoList
*entry
= g_malloc0(sizeof(*entry
));
175 entry
->value
= g_malloc0(sizeof(DevicePropertyInfo
));
179 entry
->value
->name
= g_strdup(prop
->name
);
180 entry
->value
->type
= g_strdup(prop
->type
);