2
0

qmp.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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. *
  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.
  14. */
  15. #include "qemu/osdep.h"
  16. #include "qemu-version.h"
  17. #include "qemu/cutils.h"
  18. #include "monitor/monitor.h"
  19. #include "sysemu/sysemu.h"
  20. #include "qemu/config-file.h"
  21. #include "qemu/uuid.h"
  22. #include "qmp-commands.h"
  23. #include "sysemu/char.h"
  24. #include "ui/qemu-spice.h"
  25. #include "ui/vnc.h"
  26. #include "sysemu/kvm.h"
  27. #include "sysemu/arch_init.h"
  28. #include "hw/qdev.h"
  29. #include "sysemu/blockdev.h"
  30. #include "sysemu/block-backend.h"
  31. #include "qom/qom-qobject.h"
  32. #include "qapi/qmp/qerror.h"
  33. #include "qapi/qmp/qobject.h"
  34. #include "qapi/qobject-input-visitor.h"
  35. #include "hw/boards.h"
  36. #include "qom/object_interfaces.h"
  37. #include "hw/mem/pc-dimm.h"
  38. #include "hw/acpi/acpi_dev_interface.h"
  39. NameInfo *qmp_query_name(Error **errp)
  40. {
  41. NameInfo *info = g_malloc0(sizeof(*info));
  42. if (qemu_name) {
  43. info->has_name = true;
  44. info->name = g_strdup(qemu_name);
  45. }
  46. return info;
  47. }
  48. VersionInfo *qmp_query_version(Error **errp)
  49. {
  50. VersionInfo *info = g_new0(VersionInfo, 1);
  51. info->qemu = g_new0(VersionTriple, 1);
  52. info->qemu->major = QEMU_VERSION_MAJOR;
  53. info->qemu->minor = QEMU_VERSION_MINOR;
  54. info->qemu->micro = QEMU_VERSION_MICRO;
  55. info->package = g_strdup(QEMU_PKGVERSION);
  56. return info;
  57. }
  58. KvmInfo *qmp_query_kvm(Error **errp)
  59. {
  60. KvmInfo *info = g_malloc0(sizeof(*info));
  61. info->enabled = kvm_enabled();
  62. info->present = kvm_available();
  63. return info;
  64. }
  65. UuidInfo *qmp_query_uuid(Error **errp)
  66. {
  67. UuidInfo *info = g_malloc0(sizeof(*info));
  68. info->UUID = qemu_uuid_unparse_strdup(&qemu_uuid);
  69. return info;
  70. }
  71. void qmp_quit(Error **errp)
  72. {
  73. no_shutdown = 0;
  74. qemu_system_shutdown_request();
  75. }
  76. void qmp_stop(Error **errp)
  77. {
  78. /* if there is a dump in background, we should wait until the dump
  79. * finished */
  80. if (dump_in_progress()) {
  81. error_setg(errp, "There is a dump in process, please wait.");
  82. return;
  83. }
  84. if (runstate_check(RUN_STATE_INMIGRATE)) {
  85. autostart = 0;
  86. } else {
  87. vm_stop(RUN_STATE_PAUSED);
  88. }
  89. }
  90. void qmp_system_reset(Error **errp)
  91. {
  92. qemu_system_reset_request();
  93. }
  94. void qmp_system_powerdown(Error **erp)
  95. {
  96. qemu_system_powerdown_request();
  97. }
  98. void qmp_cpu(int64_t index, Error **errp)
  99. {
  100. /* Just do nothing */
  101. }
  102. void qmp_cpu_add(int64_t id, Error **errp)
  103. {
  104. MachineClass *mc;
  105. mc = MACHINE_GET_CLASS(current_machine);
  106. if (mc->hot_add_cpu) {
  107. mc->hot_add_cpu(id, errp);
  108. } else {
  109. error_setg(errp, "Not supported");
  110. }
  111. }
  112. #ifndef CONFIG_VNC
  113. /* If VNC support is enabled, the "true" query-vnc command is
  114. defined in the VNC subsystem */
  115. VncInfo *qmp_query_vnc(Error **errp)
  116. {
  117. error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
  118. return NULL;
  119. };
  120. VncInfo2List *qmp_query_vnc_servers(Error **errp)
  121. {
  122. error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
  123. return NULL;
  124. };
  125. #endif
  126. #ifndef CONFIG_SPICE
  127. /*
  128. * qmp-commands.hx ensures that QMP command query-spice exists only
  129. * #ifdef CONFIG_SPICE. Necessary for an accurate query-commands
  130. * result. However, the QAPI schema is blissfully unaware of that,
  131. * and the QAPI code generator happily generates a dead
  132. * qmp_marshal_query_spice() that calls qmp_query_spice(). Provide it
  133. * one, or else linking fails. FIXME Educate the QAPI schema on
  134. * CONFIG_SPICE.
  135. */
  136. SpiceInfo *qmp_query_spice(Error **errp)
  137. {
  138. abort();
  139. };
  140. #endif
  141. void qmp_cont(Error **errp)
  142. {
  143. Error *local_err = NULL;
  144. BlockBackend *blk;
  145. BlockDriverState *bs;
  146. BdrvNextIterator it;
  147. /* if there is a dump in background, we should wait until the dump
  148. * finished */
  149. if (dump_in_progress()) {
  150. error_setg(errp, "There is a dump in process, please wait.");
  151. return;
  152. }
  153. if (runstate_needs_reset()) {
  154. error_setg(errp, "Resetting the Virtual Machine is required");
  155. return;
  156. } else if (runstate_check(RUN_STATE_SUSPENDED)) {
  157. return;
  158. }
  159. for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
  160. blk_iostatus_reset(blk);
  161. }
  162. for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
  163. bdrv_add_key(bs, NULL, &local_err);
  164. if (local_err) {
  165. error_propagate(errp, local_err);
  166. return;
  167. }
  168. }
  169. /* Continuing after completed migration. Images have been inactivated to
  170. * allow the destination to take control. Need to get control back now. */
  171. if (runstate_check(RUN_STATE_FINISH_MIGRATE) ||
  172. runstate_check(RUN_STATE_POSTMIGRATE))
  173. {
  174. bdrv_invalidate_cache_all(&local_err);
  175. if (local_err) {
  176. error_propagate(errp, local_err);
  177. return;
  178. }
  179. }
  180. blk_resume_after_migration(&local_err);
  181. if (local_err) {
  182. error_propagate(errp, local_err);
  183. return;
  184. }
  185. if (runstate_check(RUN_STATE_INMIGRATE)) {
  186. autostart = 1;
  187. } else {
  188. vm_start();
  189. }
  190. }
  191. void qmp_system_wakeup(Error **errp)
  192. {
  193. qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
  194. }
  195. ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
  196. {
  197. Object *obj;
  198. bool ambiguous = false;
  199. ObjectPropertyInfoList *props = NULL;
  200. ObjectProperty *prop;
  201. ObjectPropertyIterator iter;
  202. obj = object_resolve_path(path, &ambiguous);
  203. if (obj == NULL) {
  204. if (ambiguous) {
  205. error_setg(errp, "Path '%s' is ambiguous", path);
  206. } else {
  207. error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
  208. "Device '%s' not found", path);
  209. }
  210. return NULL;
  211. }
  212. object_property_iter_init(&iter, obj);
  213. while ((prop = object_property_iter_next(&iter))) {
  214. ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry));
  215. entry->value = g_malloc0(sizeof(ObjectPropertyInfo));
  216. entry->next = props;
  217. props = entry;
  218. entry->value->name = g_strdup(prop->name);
  219. entry->value->type = g_strdup(prop->type);
  220. }
  221. return props;
  222. }
  223. void qmp_qom_set(const char *path, const char *property, QObject *value,
  224. Error **errp)
  225. {
  226. Object *obj;
  227. obj = object_resolve_path(path, NULL);
  228. if (!obj) {
  229. error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
  230. "Device '%s' not found", path);
  231. return;
  232. }
  233. object_property_set_qobject(obj, value, property, errp);
  234. }
  235. QObject *qmp_qom_get(const char *path, const char *property, Error **errp)
  236. {
  237. Object *obj;
  238. obj = object_resolve_path(path, NULL);
  239. if (!obj) {
  240. error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
  241. "Device '%s' not found", path);
  242. return NULL;
  243. }
  244. return object_property_get_qobject(obj, property, errp);
  245. }
  246. void qmp_set_password(const char *protocol, const char *password,
  247. bool has_connected, const char *connected, Error **errp)
  248. {
  249. int disconnect_if_connected = 0;
  250. int fail_if_connected = 0;
  251. int rc;
  252. if (has_connected) {
  253. if (strcmp(connected, "fail") == 0) {
  254. fail_if_connected = 1;
  255. } else if (strcmp(connected, "disconnect") == 0) {
  256. disconnect_if_connected = 1;
  257. } else if (strcmp(connected, "keep") == 0) {
  258. /* nothing */
  259. } else {
  260. error_setg(errp, QERR_INVALID_PARAMETER, "connected");
  261. return;
  262. }
  263. }
  264. if (strcmp(protocol, "spice") == 0) {
  265. if (!qemu_using_spice(errp)) {
  266. return;
  267. }
  268. rc = qemu_spice_set_passwd(password, fail_if_connected,
  269. disconnect_if_connected);
  270. if (rc != 0) {
  271. error_setg(errp, QERR_SET_PASSWD_FAILED);
  272. }
  273. return;
  274. }
  275. if (strcmp(protocol, "vnc") == 0) {
  276. if (fail_if_connected || disconnect_if_connected) {
  277. /* vnc supports "connected=keep" only */
  278. error_setg(errp, QERR_INVALID_PARAMETER, "connected");
  279. return;
  280. }
  281. /* Note that setting an empty password will not disable login through
  282. * this interface. */
  283. rc = vnc_display_password(NULL, password);
  284. if (rc < 0) {
  285. error_setg(errp, QERR_SET_PASSWD_FAILED);
  286. }
  287. return;
  288. }
  289. error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
  290. }
  291. void qmp_expire_password(const char *protocol, const char *whenstr,
  292. Error **errp)
  293. {
  294. time_t when;
  295. int rc;
  296. if (strcmp(whenstr, "now") == 0) {
  297. when = 0;
  298. } else if (strcmp(whenstr, "never") == 0) {
  299. when = TIME_MAX;
  300. } else if (whenstr[0] == '+') {
  301. when = time(NULL) + strtoull(whenstr+1, NULL, 10);
  302. } else {
  303. when = strtoull(whenstr, NULL, 10);
  304. }
  305. if (strcmp(protocol, "spice") == 0) {
  306. if (!qemu_using_spice(errp)) {
  307. return;
  308. }
  309. rc = qemu_spice_set_pw_expire(when);
  310. if (rc != 0) {
  311. error_setg(errp, QERR_SET_PASSWD_FAILED);
  312. }
  313. return;
  314. }
  315. if (strcmp(protocol, "vnc") == 0) {
  316. rc = vnc_display_pw_expire(NULL, when);
  317. if (rc != 0) {
  318. error_setg(errp, QERR_SET_PASSWD_FAILED);
  319. }
  320. return;
  321. }
  322. error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
  323. }
  324. #ifdef CONFIG_VNC
  325. void qmp_change_vnc_password(const char *password, Error **errp)
  326. {
  327. if (vnc_display_password(NULL, password) < 0) {
  328. error_setg(errp, QERR_SET_PASSWD_FAILED);
  329. }
  330. }
  331. static void qmp_change_vnc_listen(const char *target, Error **errp)
  332. {
  333. QemuOptsList *olist = qemu_find_opts("vnc");
  334. QemuOpts *opts;
  335. if (strstr(target, "id=")) {
  336. error_setg(errp, "id not supported");
  337. return;
  338. }
  339. opts = qemu_opts_find(olist, "default");
  340. if (opts) {
  341. qemu_opts_del(opts);
  342. }
  343. opts = vnc_parse(target, errp);
  344. if (!opts) {
  345. return;
  346. }
  347. vnc_display_open("default", errp);
  348. }
  349. static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
  350. Error **errp)
  351. {
  352. if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
  353. if (!has_arg) {
  354. error_setg(errp, QERR_MISSING_PARAMETER, "password");
  355. } else {
  356. qmp_change_vnc_password(arg, errp);
  357. }
  358. } else {
  359. qmp_change_vnc_listen(target, errp);
  360. }
  361. }
  362. #else
  363. void qmp_change_vnc_password(const char *password, Error **errp)
  364. {
  365. error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
  366. }
  367. static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
  368. Error **errp)
  369. {
  370. error_setg(errp, QERR_FEATURE_DISABLED, "vnc");
  371. }
  372. #endif /* !CONFIG_VNC */
  373. void qmp_change(const char *device, const char *target,
  374. bool has_arg, const char *arg, Error **errp)
  375. {
  376. if (strcmp(device, "vnc") == 0) {
  377. qmp_change_vnc(target, has_arg, arg, errp);
  378. } else {
  379. qmp_blockdev_change_medium(true, device, false, NULL, target,
  380. has_arg, arg, false, 0, errp);
  381. }
  382. }
  383. static void qom_list_types_tramp(ObjectClass *klass, void *data)
  384. {
  385. ObjectTypeInfoList *e, **pret = data;
  386. ObjectTypeInfo *info;
  387. info = g_malloc0(sizeof(*info));
  388. info->name = g_strdup(object_class_get_name(klass));
  389. e = g_malloc0(sizeof(*e));
  390. e->value = info;
  391. e->next = *pret;
  392. *pret = e;
  393. }
  394. ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
  395. const char *implements,
  396. bool has_abstract,
  397. bool abstract,
  398. Error **errp)
  399. {
  400. ObjectTypeInfoList *ret = NULL;
  401. object_class_foreach(qom_list_types_tramp, implements, abstract, &ret);
  402. return ret;
  403. }
  404. /* Return a DevicePropertyInfo for a qdev property.
  405. *
  406. * If a qdev property with the given name does not exist, use the given default
  407. * type. If the qdev property info should not be shown, return NULL.
  408. *
  409. * The caller must free the return value.
  410. */
  411. static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
  412. const char *name,
  413. const char *default_type,
  414. const char *description)
  415. {
  416. DevicePropertyInfo *info;
  417. Property *prop;
  418. do {
  419. for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
  420. if (strcmp(name, prop->name) != 0) {
  421. continue;
  422. }
  423. /*
  424. * TODO Properties without a parser are just for dirty hacks.
  425. * qdev_prop_ptr is the only such PropertyInfo. It's marked
  426. * for removal. This conditional should be removed along with
  427. * it.
  428. */
  429. if (!prop->info->set) {
  430. return NULL; /* no way to set it, don't show */
  431. }
  432. info = g_malloc0(sizeof(*info));
  433. info->name = g_strdup(prop->name);
  434. info->type = g_strdup(prop->info->name);
  435. info->has_description = !!prop->info->description;
  436. info->description = g_strdup(prop->info->description);
  437. return info;
  438. }
  439. klass = object_class_get_parent(klass);
  440. } while (klass != object_class_by_name(TYPE_DEVICE));
  441. /* Not a qdev property, use the default type */
  442. info = g_malloc0(sizeof(*info));
  443. info->name = g_strdup(name);
  444. info->type = g_strdup(default_type);
  445. info->has_description = !!description;
  446. info->description = g_strdup(description);
  447. return info;
  448. }
  449. DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
  450. Error **errp)
  451. {
  452. ObjectClass *klass;
  453. Object *obj;
  454. ObjectProperty *prop;
  455. ObjectPropertyIterator iter;
  456. DevicePropertyInfoList *prop_list = NULL;
  457. klass = object_class_by_name(typename);
  458. if (klass == NULL) {
  459. error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
  460. "Device '%s' not found", typename);
  461. return NULL;
  462. }
  463. klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
  464. if (klass == NULL) {
  465. error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_DEVICE);
  466. return NULL;
  467. }
  468. if (object_class_is_abstract(klass)) {
  469. error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename",
  470. "non-abstract device type");
  471. return NULL;
  472. }
  473. if (DEVICE_CLASS(klass)->cannot_destroy_with_object_finalize_yet) {
  474. error_setg(errp, "Can't list properties of device '%s'", typename);
  475. return NULL;
  476. }
  477. obj = object_new(typename);
  478. object_property_iter_init(&iter, obj);
  479. while ((prop = object_property_iter_next(&iter))) {
  480. DevicePropertyInfo *info;
  481. DevicePropertyInfoList *entry;
  482. /* Skip Object and DeviceState properties */
  483. if (strcmp(prop->name, "type") == 0 ||
  484. strcmp(prop->name, "realized") == 0 ||
  485. strcmp(prop->name, "hotpluggable") == 0 ||
  486. strcmp(prop->name, "hotplugged") == 0 ||
  487. strcmp(prop->name, "parent_bus") == 0) {
  488. continue;
  489. }
  490. /* Skip legacy properties since they are just string versions of
  491. * properties that we already list.
  492. */
  493. if (strstart(prop->name, "legacy-", NULL)) {
  494. continue;
  495. }
  496. info = make_device_property_info(klass, prop->name, prop->type,
  497. prop->description);
  498. if (!info) {
  499. continue;
  500. }
  501. entry = g_malloc0(sizeof(*entry));
  502. entry->value = info;
  503. entry->next = prop_list;
  504. prop_list = entry;
  505. }
  506. object_unref(obj);
  507. return prop_list;
  508. }
  509. CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
  510. {
  511. return arch_query_cpu_definitions(errp);
  512. }
  513. CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
  514. CpuModelInfo *model,
  515. Error **errp)
  516. {
  517. return arch_query_cpu_model_expansion(type, model, errp);
  518. }
  519. CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *modela,
  520. CpuModelInfo *modelb,
  521. Error **errp)
  522. {
  523. return arch_query_cpu_model_comparison(modela, modelb, errp);
  524. }
  525. CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *modela,
  526. CpuModelInfo *modelb,
  527. Error **errp)
  528. {
  529. return arch_query_cpu_model_baseline(modela, modelb, errp);
  530. }
  531. void qmp_add_client(const char *protocol, const char *fdname,
  532. bool has_skipauth, bool skipauth, bool has_tls, bool tls,
  533. Error **errp)
  534. {
  535. Chardev *s;
  536. int fd;
  537. fd = monitor_get_fd(cur_mon, fdname, errp);
  538. if (fd < 0) {
  539. return;
  540. }
  541. if (strcmp(protocol, "spice") == 0) {
  542. if (!qemu_using_spice(errp)) {
  543. close(fd);
  544. return;
  545. }
  546. skipauth = has_skipauth ? skipauth : false;
  547. tls = has_tls ? tls : false;
  548. if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
  549. error_setg(errp, "spice failed to add client");
  550. close(fd);
  551. }
  552. return;
  553. #ifdef CONFIG_VNC
  554. } else if (strcmp(protocol, "vnc") == 0) {
  555. skipauth = has_skipauth ? skipauth : false;
  556. vnc_display_add_client(NULL, fd, skipauth);
  557. return;
  558. #endif
  559. } else if ((s = qemu_chr_find(protocol)) != NULL) {
  560. if (qemu_chr_add_client(s, fd) < 0) {
  561. error_setg(errp, "failed to add client");
  562. close(fd);
  563. return;
  564. }
  565. return;
  566. }
  567. error_setg(errp, "protocol '%s' is invalid", protocol);
  568. close(fd);
  569. }
  570. void qmp_object_add(const char *type, const char *id,
  571. bool has_props, QObject *props, Error **errp)
  572. {
  573. QDict *pdict;
  574. Visitor *v;
  575. Object *obj;
  576. if (props) {
  577. pdict = qobject_to_qdict(props);
  578. if (!pdict) {
  579. error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
  580. return;
  581. }
  582. QINCREF(pdict);
  583. } else {
  584. pdict = qdict_new();
  585. }
  586. v = qobject_input_visitor_new(QOBJECT(pdict));
  587. obj = user_creatable_add_type(type, id, pdict, v, errp);
  588. visit_free(v);
  589. if (obj) {
  590. object_unref(obj);
  591. }
  592. QDECREF(pdict);
  593. }
  594. void qmp_object_del(const char *id, Error **errp)
  595. {
  596. user_creatable_del(id, errp);
  597. }
  598. MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
  599. {
  600. MemoryDeviceInfoList *head = NULL;
  601. MemoryDeviceInfoList **prev = &head;
  602. qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
  603. return head;
  604. }
  605. ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
  606. {
  607. bool ambig;
  608. ACPIOSTInfoList *head = NULL;
  609. ACPIOSTInfoList **prev = &head;
  610. Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
  611. if (obj) {
  612. AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
  613. AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
  614. adevc->ospm_status(adev, &prev);
  615. } else {
  616. error_setg(errp, "command is not supported, missing ACPI device");
  617. }
  618. return head;
  619. }