]> git.proxmox.com Git - mirror_qemu.git/blame - qmp.c
qerror: Eliminate QERR_DEVICE_NOT_FOUND
[mirror_qemu.git] / qmp.c
CommitLineData
48a32bed
AL
1/*
2 * QEMU Management Protocol
3 *
4 * Copyright IBM, Corp. 2011
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
6b620ca3
PB
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
48a32bed
AL
14 */
15
16#include "qemu-common.h"
9c17d615 17#include "sysemu/sysemu.h"
48a32bed 18#include "qmp-commands.h"
dccfcd0e 19#include "sysemu/char.h"
fbf796fd
LC
20#include "ui/qemu-spice.h"
21#include "ui/vnc.h"
9c17d615
PB
22#include "sysemu/kvm.h"
23#include "sysemu/arch_init.h"
b4b12c62 24#include "hw/qdev.h"
9c17d615 25#include "sysemu/blockdev.h"
14cccb61 26#include "qom/qom-qobject.h"
cff8b2c6
PB
27#include "qapi/qmp/qobject.h"
28#include "qapi/qmp-input-visitor.h"
69ca3ea5 29#include "hw/boards.h"
269e09f3 30#include "qom/object_interfaces.h"
6f2e2730 31#include "hw/mem/pc-dimm.h"
02419bcb 32#include "hw/acpi/acpi_dev_interface.h"
48a32bed
AL
33
34NameInfo *qmp_query_name(Error **errp)
35{
36 NameInfo *info = g_malloc0(sizeof(*info));
37
38 if (qemu_name) {
39 info->has_name = true;
40 info->name = g_strdup(qemu_name);
41 }
42
43 return info;
44}
b9c15f16 45
7daecb30 46VersionInfo *qmp_query_version(Error **errp)
b9c15f16 47{
4752cdbb 48 VersionInfo *info = g_new0(VersionInfo, 1);
b9c15f16
LC
49 const char *version = QEMU_VERSION;
50 char *tmp;
51
4752cdbb
EB
52 info->qemu = g_new0(VersionTriple, 1);
53 info->qemu->major = strtol(version, &tmp, 10);
b9c15f16 54 tmp++;
4752cdbb 55 info->qemu->minor = strtol(tmp, &tmp, 10);
b9c15f16 56 tmp++;
4752cdbb 57 info->qemu->micro = strtol(tmp, &tmp, 10);
b9c15f16
LC
58 info->package = g_strdup(QEMU_PKGVERSION);
59
60 return info;
61}
292a2602
LC
62
63KvmInfo *qmp_query_kvm(Error **errp)
64{
65 KvmInfo *info = g_malloc0(sizeof(*info));
66
67 info->enabled = kvm_enabled();
68 info->present = kvm_available();
69
70 return info;
71}
72
efab767e
LC
73UuidInfo *qmp_query_uuid(Error **errp)
74{
75 UuidInfo *info = g_malloc0(sizeof(*info));
76 char uuid[64];
77
78 snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1],
79 qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],
80 qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],
81 qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
82 qemu_uuid[14], qemu_uuid[15]);
83
84 info->UUID = g_strdup(uuid);
85 return info;
86}
87
7daecb30 88void qmp_quit(Error **errp)
7a7f325e
LC
89{
90 no_shutdown = 0;
91 qemu_system_shutdown_request();
92}
93
5f158f21
LC
94void qmp_stop(Error **errp)
95{
1e998146
PB
96 if (runstate_check(RUN_STATE_INMIGRATE)) {
97 autostart = 0;
98 } else {
99 vm_stop(RUN_STATE_PAUSED);
100 }
5f158f21
LC
101}
102
38d22653
LC
103void qmp_system_reset(Error **errp)
104{
105 qemu_system_reset_request();
106}
5bc465e4
LC
107
108void qmp_system_powerdown(Error **erp)
109{
110 qemu_system_powerdown_request();
111}
755f1968
LC
112
113void qmp_cpu(int64_t index, Error **errp)
114{
115 /* Just do nothing */
116}
2b54aa87 117
69ca3ea5
IM
118void qmp_cpu_add(int64_t id, Error **errp)
119{
0056ae24
MA
120 MachineClass *mc;
121
122 mc = MACHINE_GET_CLASS(current_machine);
958db90c
MA
123 if (mc->hot_add_cpu) {
124 mc->hot_add_cpu(id, errp);
69ca3ea5
IM
125 } else {
126 error_setg(errp, "Not supported");
127 }
128}
129
2b54aa87
LC
130#ifndef CONFIG_VNC
131/* If VNC support is enabled, the "true" query-vnc command is
132 defined in the VNC subsystem */
133VncInfo *qmp_query_vnc(Error **errp)
134{
135 error_set(errp, QERR_FEATURE_DISABLED, "vnc");
136 return NULL;
137};
89db2177
LY
138
139VncInfo2List *qmp_query_vnc_servers(Error **errp)
140{
141 error_set(errp, QERR_FEATURE_DISABLED, "vnc");
142 return NULL;
143};
2b54aa87 144#endif
d1f29646
LC
145
146#ifndef CONFIG_SPICE
ad0ec14b
MA
147/*
148 * qmp-commands.hx ensures that QMP command query-spice exists only
149 * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands
150 * result. However, the QAPI schema is blissfully unaware of that,
151 * and the QAPI code generator happily generates a dead
152 * qmp_marshal_input_query_spice() that calls qmp_query_spice().
153 * Provide it one, or else linking fails.
154 * FIXME Educate the QAPI schema on CONFIG_SPICE.
155 */
d1f29646
LC
156SpiceInfo *qmp_query_spice(Error **errp)
157{
ad0ec14b 158 abort();
d1f29646
LC
159};
160#endif
e42e818b 161
e42e818b
LC
162void qmp_cont(Error **errp)
163{
4d2855a3 164 Error *local_err = NULL;
ab31979a 165 BlockDriverState *bs;
e42e818b 166
ede085b3 167 if (runstate_needs_reset()) {
f231b88d 168 error_setg(errp, "Resetting the Virtual Machine is required");
e42e818b 169 return;
ad02b96a
LC
170 } else if (runstate_check(RUN_STATE_SUSPENDED)) {
171 return;
e42e818b
LC
172 }
173
ab31979a
MA
174 for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
175 bdrv_iostatus_reset(bs);
176 }
177 for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
4d2855a3
MA
178 bdrv_add_key(bs, NULL, &local_err);
179 if (local_err) {
180 error_propagate(errp, local_err);
ab31979a
MA
181 return;
182 }
e42e818b
LC
183 }
184
1e998146
PB
185 if (runstate_check(RUN_STATE_INMIGRATE)) {
186 autostart = 1;
187 } else {
188 vm_start();
189 }
e42e818b 190}
b4b12c62 191
9b9df25a
GH
192void qmp_system_wakeup(Error **errp)
193{
194 qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
195}
196
57c9fafe 197ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
b4b12c62 198{
57c9fafe 199 Object *obj;
b4b12c62 200 bool ambiguous = false;
57c9fafe
AL
201 ObjectPropertyInfoList *props = NULL;
202 ObjectProperty *prop;
b4b12c62 203
57c9fafe
AL
204 obj = object_resolve_path(path, &ambiguous);
205 if (obj == NULL) {
79772087
MT
206 if (ambiguous) {
207 error_setg(errp, "Path '%s' is ambiguous", path);
208 } else {
75158ebb
MA
209 error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
210 "Device '%s' not found", path);
79772087 211 }
b4b12c62
AL
212 return NULL;
213 }
214
57c9fafe
AL
215 QTAILQ_FOREACH(prop, &obj->properties, node) {
216 ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry));
b4b12c62 217
57c9fafe 218 entry->value = g_malloc0(sizeof(ObjectPropertyInfo));
b4b12c62
AL
219 entry->next = props;
220 props = entry;
221
222 entry->value->name = g_strdup(prop->name);
223 entry->value->type = g_strdup(prop->type);
224 }
225
226 return props;
227}
eb6e8ea5
AL
228
229/* FIXME: teach qapi about how to pass through Visitors */
230int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
231{
232 const char *path = qdict_get_str(qdict, "path");
233 const char *property = qdict_get_str(qdict, "property");
234 QObject *value = qdict_get(qdict, "value");
235 Error *local_err = NULL;
57c9fafe 236 Object *obj;
eb6e8ea5 237
57c9fafe
AL
238 obj = object_resolve_path(path, NULL);
239 if (!obj) {
75158ebb
MA
240 error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
241 "Device '%s' not found", path);
eb6e8ea5
AL
242 goto out;
243 }
244
9f5f1350 245 object_property_set_qobject(obj, value, property, &local_err);
eb6e8ea5
AL
246
247out:
248 if (local_err) {
249 qerror_report_err(local_err);
250 error_free(local_err);
251 return -1;
252 }
253
254 return 0;
255}
256
257int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret)
258{
259 const char *path = qdict_get_str(qdict, "path");
260 const char *property = qdict_get_str(qdict, "property");
261 Error *local_err = NULL;
57c9fafe 262 Object *obj;
eb6e8ea5 263
57c9fafe
AL
264 obj = object_resolve_path(path, NULL);
265 if (!obj) {
75158ebb
MA
266 error_set(&local_err, ERROR_CLASS_DEVICE_NOT_FOUND,
267 "Device '%s' not found", path);
eb6e8ea5
AL
268 goto out;
269 }
270
9f5f1350 271 *ret = object_property_get_qobject(obj, property, &local_err);
eb6e8ea5
AL
272
273out:
274 if (local_err) {
275 qerror_report_err(local_err);
276 error_free(local_err);
277 return -1;
278 }
279
280 return 0;
281}
fbf796fd
LC
282
283void qmp_set_password(const char *protocol, const char *password,
284 bool has_connected, const char *connected, Error **errp)
285{
286 int disconnect_if_connected = 0;
287 int fail_if_connected = 0;
288 int rc;
289
290 if (has_connected) {
291 if (strcmp(connected, "fail") == 0) {
292 fail_if_connected = 1;
293 } else if (strcmp(connected, "disconnect") == 0) {
294 disconnect_if_connected = 1;
295 } else if (strcmp(connected, "keep") == 0) {
296 /* nothing */
297 } else {
298 error_set(errp, QERR_INVALID_PARAMETER, "connected");
299 return;
300 }
301 }
302
303 if (strcmp(protocol, "spice") == 0) {
b25d81ba 304 if (!qemu_using_spice(errp)) {
fbf796fd
LC
305 return;
306 }
307 rc = qemu_spice_set_passwd(password, fail_if_connected,
308 disconnect_if_connected);
309 if (rc != 0) {
310 error_set(errp, QERR_SET_PASSWD_FAILED);
311 }
312 return;
313 }
314
315 if (strcmp(protocol, "vnc") == 0) {
316 if (fail_if_connected || disconnect_if_connected) {
317 /* vnc supports "connected=keep" only */
318 error_set(errp, QERR_INVALID_PARAMETER, "connected");
319 return;
320 }
321 /* Note that setting an empty password will not disable login through
322 * this interface. */
323 rc = vnc_display_password(NULL, password);
324 if (rc < 0) {
325 error_set(errp, QERR_SET_PASSWD_FAILED);
326 }
327 return;
328 }
329
330 error_set(errp, QERR_INVALID_PARAMETER, "protocol");
331}
9ad5372d
LC
332
333void qmp_expire_password(const char *protocol, const char *whenstr,
334 Error **errp)
335{
336 time_t when;
337 int rc;
338
339 if (strcmp(whenstr, "now") == 0) {
340 when = 0;
341 } else if (strcmp(whenstr, "never") == 0) {
342 when = TIME_MAX;
343 } else if (whenstr[0] == '+') {
344 when = time(NULL) + strtoull(whenstr+1, NULL, 10);
345 } else {
346 when = strtoull(whenstr, NULL, 10);
347 }
348
349 if (strcmp(protocol, "spice") == 0) {
b25d81ba 350 if (!qemu_using_spice(errp)) {
9ad5372d
LC
351 return;
352 }
353 rc = qemu_spice_set_pw_expire(when);
354 if (rc != 0) {
355 error_set(errp, QERR_SET_PASSWD_FAILED);
356 }
357 return;
358 }
359
360 if (strcmp(protocol, "vnc") == 0) {
361 rc = vnc_display_pw_expire(NULL, when);
362 if (rc != 0) {
363 error_set(errp, QERR_SET_PASSWD_FAILED);
364 }
365 return;
366 }
367
368 error_set(errp, QERR_INVALID_PARAMETER, "protocol");
369}
270b243f 370
333a96ec 371#ifdef CONFIG_VNC
270b243f
LC
372void qmp_change_vnc_password(const char *password, Error **errp)
373{
374 if (vnc_display_password(NULL, password) < 0) {
375 error_set(errp, QERR_SET_PASSWD_FAILED);
376 }
377}
333a96ec 378
007fcd3e 379static void qmp_change_vnc_listen(const char *target, Error **errp)
333a96ec 380{
4db14629
GH
381 QemuOptsList *olist = qemu_find_opts("vnc");
382 QemuOpts *opts;
383
384 if (strstr(target, "id=")) {
385 error_setg(errp, "id not supported");
386 return;
387 }
388
389 opts = qemu_opts_find(olist, "default");
390 if (opts) {
391 qemu_opts_del(opts);
392 }
70b94331 393 opts = vnc_parse(target, errp);
f7801c5c
GA
394 if (!opts) {
395 return;
396 }
397
4db14629 398 vnc_display_open("default", errp);
333a96ec
LC
399}
400
401static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
402 Error **errp)
403{
404 if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
405 if (!has_arg) {
406 error_set(errp, QERR_MISSING_PARAMETER, "password");
407 } else {
408 qmp_change_vnc_password(arg, errp);
409 }
410 } else {
411 qmp_change_vnc_listen(target, errp);
412 }
413}
414#else
415void qmp_change_vnc_password(const char *password, Error **errp)
416{
417 error_set(errp, QERR_FEATURE_DISABLED, "vnc");
418}
419static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
420 Error **errp)
421{
422 error_set(errp, QERR_FEATURE_DISABLED, "vnc");
423}
424#endif /* !CONFIG_VNC */
425
426void qmp_change(const char *device, const char *target,
7daecb30 427 bool has_arg, const char *arg, Error **errp)
333a96ec
LC
428{
429 if (strcmp(device, "vnc") == 0) {
7daecb30 430 qmp_change_vnc(target, has_arg, arg, errp);
333a96ec 431 } else {
7daecb30 432 qmp_change_blockdev(device, target, arg, errp);
333a96ec
LC
433 }
434}
5eeee3fa
AL
435
436static void qom_list_types_tramp(ObjectClass *klass, void *data)
437{
438 ObjectTypeInfoList *e, **pret = data;
439 ObjectTypeInfo *info;
440
441 info = g_malloc0(sizeof(*info));
442 info->name = g_strdup(object_class_get_name(klass));
443
444 e = g_malloc0(sizeof(*e));
445 e->value = info;
446 e->next = *pret;
447 *pret = e;
448}
449
450ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
451 const char *implements,
452 bool has_abstract,
453 bool abstract,
454 Error **errp)
455{
456 ObjectTypeInfoList *ret = NULL;
457
458 object_class_foreach(qom_list_types_tramp, implements, abstract, &ret);
459
460 return ret;
461}
1daa31b9 462
f4eb32b5
SH
463/* Return a DevicePropertyInfo for a qdev property.
464 *
465 * If a qdev property with the given name does not exist, use the given default
466 * type. If the qdev property info should not be shown, return NULL.
467 *
468 * The caller must free the return value.
469 */
470static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
471 const char *name,
07d09c58
GA
472 const char *default_type,
473 const char *description)
f4eb32b5
SH
474{
475 DevicePropertyInfo *info;
476 Property *prop;
477
478 do {
479 for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
480 if (strcmp(name, prop->name) != 0) {
481 continue;
482 }
483
484 /*
485 * TODO Properties without a parser are just for dirty hacks.
486 * qdev_prop_ptr is the only such PropertyInfo. It's marked
487 * for removal. This conditional should be removed along with
488 * it.
489 */
490 if (!prop->info->set) {
491 return NULL; /* no way to set it, don't show */
492 }
493
494 info = g_malloc0(sizeof(*info));
495 info->name = g_strdup(prop->name);
07d09c58
GA
496 info->type = g_strdup(prop->info->name);
497 info->has_description = !!prop->info->description;
498 info->description = g_strdup(prop->info->description);
f4eb32b5
SH
499 return info;
500 }
501 klass = object_class_get_parent(klass);
502 } while (klass != object_class_by_name(TYPE_DEVICE));
503
504 /* Not a qdev property, use the default type */
505 info = g_malloc0(sizeof(*info));
506 info->name = g_strdup(name);
507 info->type = g_strdup(default_type);
07d09c58
GA
508 info->has_description = !!description;
509 info->description = g_strdup(description);
510
f4eb32b5
SH
511 return info;
512}
513
1daa31b9
AL
514DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
515 Error **errp)
516{
517 ObjectClass *klass;
f4eb32b5
SH
518 Object *obj;
519 ObjectProperty *prop;
1daa31b9
AL
520 DevicePropertyInfoList *prop_list = NULL;
521
522 klass = object_class_by_name(typename);
523 if (klass == NULL) {
75158ebb
MA
524 error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
525 "Device '%s' not found", typename);
1daa31b9
AL
526 return NULL;
527 }
528
529 klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
530 if (klass == NULL) {
531 error_set(errp, QERR_INVALID_PARAMETER_VALUE,
532 "name", TYPE_DEVICE);
533 return NULL;
534 }
535
f4eb32b5 536 obj = object_new(typename);
1daa31b9 537
f4eb32b5
SH
538 QTAILQ_FOREACH(prop, &obj->properties, node) {
539 DevicePropertyInfo *info;
540 DevicePropertyInfoList *entry;
541
542 /* Skip Object and DeviceState properties */
543 if (strcmp(prop->name, "type") == 0 ||
544 strcmp(prop->name, "realized") == 0 ||
545 strcmp(prop->name, "hotpluggable") == 0 ||
4115dd65 546 strcmp(prop->name, "hotplugged") == 0 ||
f4eb32b5
SH
547 strcmp(prop->name, "parent_bus") == 0) {
548 continue;
549 }
1daa31b9 550
f4eb32b5
SH
551 /* Skip legacy properties since they are just string versions of
552 * properties that we already list.
553 */
554 if (strstart(prop->name, "legacy-", NULL)) {
555 continue;
556 }
1daa31b9 557
07d09c58
GA
558 info = make_device_property_info(klass, prop->name, prop->type,
559 prop->description);
f4eb32b5
SH
560 if (!info) {
561 continue;
1daa31b9 562 }
f4eb32b5
SH
563
564 entry = g_malloc0(sizeof(*entry));
565 entry->value = info;
566 entry->next = prop_list;
567 prop_list = entry;
568 }
569
570 object_unref(obj);
1daa31b9
AL
571
572 return prop_list;
573}
e4e31c63 574
76b64a7a
AL
575CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
576{
577 return arch_query_cpu_definitions(errp);
578}
579
b224e5e2
LC
580void qmp_add_client(const char *protocol, const char *fdname,
581 bool has_skipauth, bool skipauth, bool has_tls, bool tls,
582 Error **errp)
583{
584 CharDriverState *s;
585 int fd;
586
587 fd = monitor_get_fd(cur_mon, fdname, errp);
588 if (fd < 0) {
589 return;
590 }
591
592 if (strcmp(protocol, "spice") == 0) {
b25d81ba 593 if (!qemu_using_spice(errp)) {
b224e5e2
LC
594 close(fd);
595 return;
596 }
597 skipauth = has_skipauth ? skipauth : false;
598 tls = has_tls ? tls : false;
599 if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
600 error_setg(errp, "spice failed to add client");
601 close(fd);
602 }
603 return;
604#ifdef CONFIG_VNC
605 } else if (strcmp(protocol, "vnc") == 0) {
606 skipauth = has_skipauth ? skipauth : false;
607 vnc_display_add_client(NULL, fd, skipauth);
608 return;
609#endif
610 } else if ((s = qemu_chr_find(protocol)) != NULL) {
611 if (qemu_chr_add_client(s, fd) < 0) {
612 error_setg(errp, "failed to add client");
613 close(fd);
614 return;
615 }
616 return;
617 }
618
619 error_setg(errp, "protocol '%s' is invalid", protocol);
620 close(fd);
621}
ab2d0531 622
cff8b2c6
PB
623void object_add(const char *type, const char *id, const QDict *qdict,
624 Visitor *v, Error **errp)
625{
626 Object *obj;
c3481247 627 ObjectClass *klass;
cff8b2c6
PB
628 const QDictEntry *e;
629 Error *local_err = NULL;
630
c3481247
EH
631 klass = object_class_by_name(type);
632 if (!klass) {
d1169464 633 error_setg(errp, "invalid object type: %s", type);
cff8b2c6
PB
634 return;
635 }
636
c3481247
EH
637 if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE)) {
638 error_setg(errp, "object type '%s' isn't supported by object-add",
639 type);
640 return;
641 }
642
643 if (object_class_is_abstract(klass)) {
644 error_setg(errp, "object type '%s' is abstract", type);
645 return;
646 }
647
cff8b2c6
PB
648 obj = object_new(type);
649 if (qdict) {
650 for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
651 object_property_set(obj, v, e->key, &local_err);
652 if (local_err) {
69252c04 653 goto out;
cff8b2c6
PB
654 }
655 }
656 }
657
bc2256c4 658 object_property_add_child(object_get_objects_root(),
a790f4ec 659 id, obj, &local_err);
269e09f3
IM
660 if (local_err) {
661 goto out;
662 }
663
a790f4ec
IM
664 user_creatable_complete(obj, &local_err);
665 if (local_err) {
bc2256c4 666 object_property_del(object_get_objects_root(),
a790f4ec
IM
667 id, &error_abort);
668 goto out;
669 }
69252c04
IM
670out:
671 if (local_err) {
672 error_propagate(errp, local_err);
673 }
cff8b2c6
PB
674 object_unref(obj);
675}
676
677int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret)
678{
679 const char *type = qdict_get_str(qdict, "qom-type");
680 const char *id = qdict_get_str(qdict, "id");
681 QObject *props = qdict_get(qdict, "props");
682 const QDict *pdict = NULL;
683 Error *local_err = NULL;
684 QmpInputVisitor *qiv;
685
686 if (props) {
687 pdict = qobject_to_qdict(props);
688 if (!pdict) {
689 error_set(&local_err, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
690 goto out;
691 }
692 }
693
694 qiv = qmp_input_visitor_new(props);
695 object_add(type, id, pdict, qmp_input_get_visitor(qiv), &local_err);
696 qmp_input_visitor_cleanup(qiv);
697
698out:
699 if (local_err) {
700 qerror_report_err(local_err);
701 error_free(local_err);
702 return -1;
703 }
704
705 return 0;
706}
707
ab2d0531
PB
708void qmp_object_del(const char *id, Error **errp)
709{
710 Object *container;
711 Object *obj;
712
bc2256c4 713 container = object_get_objects_root();
ab2d0531
PB
714 obj = object_resolve_path_component(container, id);
715 if (!obj) {
716 error_setg(errp, "object id not found");
717 return;
718 }
d6edb155
LM
719
720 if (!user_creatable_can_be_deleted(USER_CREATABLE(obj), errp)) {
721 error_setg(errp, "%s is in use, can not be deleted", id);
722 return;
723 }
ab2d0531
PB
724 object_unparent(obj);
725}
6f2e2730
IM
726
727MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
728{
729 MemoryDeviceInfoList *head = NULL;
730 MemoryDeviceInfoList **prev = &head;
731
732 qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
733
734 return head;
735}
02419bcb
IM
736
737ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
738{
739 bool ambig;
740 ACPIOSTInfoList *head = NULL;
741 ACPIOSTInfoList **prev = &head;
742 Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
743
744 if (obj) {
745 AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
746 AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
747
748 adevc->ospm_status(adev, &prev);
749 } else {
750 error_setg(errp, "command is not supported, missing ACPI device");
751 }
752
753 return head;
754}