qmp.c 19 KB

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