2
0

qmp.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. {
  383. DevicePropertyInfo *info;
  384. Property *prop;
  385. do {
  386. for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
  387. if (strcmp(name, prop->name) != 0) {
  388. continue;
  389. }
  390. /*
  391. * TODO Properties without a parser are just for dirty hacks.
  392. * qdev_prop_ptr is the only such PropertyInfo. It's marked
  393. * for removal. This conditional should be removed along with
  394. * it.
  395. */
  396. if (!prop->info->set) {
  397. return NULL; /* no way to set it, don't show */
  398. }
  399. info = g_malloc0(sizeof(*info));
  400. info->name = g_strdup(prop->name);
  401. info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
  402. return info;
  403. }
  404. klass = object_class_get_parent(klass);
  405. } while (klass != object_class_by_name(TYPE_DEVICE));
  406. /* Not a qdev property, use the default type */
  407. info = g_malloc0(sizeof(*info));
  408. info->name = g_strdup(name);
  409. info->type = g_strdup(default_type);
  410. return info;
  411. }
  412. DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
  413. Error **errp)
  414. {
  415. ObjectClass *klass;
  416. Object *obj;
  417. ObjectProperty *prop;
  418. DevicePropertyInfoList *prop_list = NULL;
  419. klass = object_class_by_name(typename);
  420. if (klass == NULL) {
  421. error_set(errp, QERR_DEVICE_NOT_FOUND, typename);
  422. return NULL;
  423. }
  424. klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
  425. if (klass == NULL) {
  426. error_set(errp, QERR_INVALID_PARAMETER_VALUE,
  427. "name", TYPE_DEVICE);
  428. return NULL;
  429. }
  430. obj = object_new(typename);
  431. QTAILQ_FOREACH(prop, &obj->properties, node) {
  432. DevicePropertyInfo *info;
  433. DevicePropertyInfoList *entry;
  434. /* Skip Object and DeviceState properties */
  435. if (strcmp(prop->name, "type") == 0 ||
  436. strcmp(prop->name, "realized") == 0 ||
  437. strcmp(prop->name, "hotpluggable") == 0 ||
  438. strcmp(prop->name, "hotplugged") == 0 ||
  439. strcmp(prop->name, "parent_bus") == 0) {
  440. continue;
  441. }
  442. /* Skip legacy properties since they are just string versions of
  443. * properties that we already list.
  444. */
  445. if (strstart(prop->name, "legacy-", NULL)) {
  446. continue;
  447. }
  448. info = make_device_property_info(klass, prop->name, prop->type);
  449. if (!info) {
  450. continue;
  451. }
  452. entry = g_malloc0(sizeof(*entry));
  453. entry->value = info;
  454. entry->next = prop_list;
  455. prop_list = entry;
  456. }
  457. object_unref(obj);
  458. return prop_list;
  459. }
  460. CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
  461. {
  462. return arch_query_cpu_definitions(errp);
  463. }
  464. void qmp_add_client(const char *protocol, const char *fdname,
  465. bool has_skipauth, bool skipauth, bool has_tls, bool tls,
  466. Error **errp)
  467. {
  468. CharDriverState *s;
  469. int fd;
  470. fd = monitor_get_fd(cur_mon, fdname, errp);
  471. if (fd < 0) {
  472. return;
  473. }
  474. if (strcmp(protocol, "spice") == 0) {
  475. if (!using_spice) {
  476. error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
  477. close(fd);
  478. return;
  479. }
  480. skipauth = has_skipauth ? skipauth : false;
  481. tls = has_tls ? tls : false;
  482. if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
  483. error_setg(errp, "spice failed to add client");
  484. close(fd);
  485. }
  486. return;
  487. #ifdef CONFIG_VNC
  488. } else if (strcmp(protocol, "vnc") == 0) {
  489. skipauth = has_skipauth ? skipauth : false;
  490. vnc_display_add_client(NULL, fd, skipauth);
  491. return;
  492. #endif
  493. } else if ((s = qemu_chr_find(protocol)) != NULL) {
  494. if (qemu_chr_add_client(s, fd) < 0) {
  495. error_setg(errp, "failed to add client");
  496. close(fd);
  497. return;
  498. }
  499. return;
  500. }
  501. error_setg(errp, "protocol '%s' is invalid", protocol);
  502. close(fd);
  503. }
  504. void object_add(const char *type, const char *id, const QDict *qdict,
  505. Visitor *v, Error **errp)
  506. {
  507. Object *obj;
  508. ObjectClass *klass;
  509. const QDictEntry *e;
  510. Error *local_err = NULL;
  511. klass = object_class_by_name(type);
  512. if (!klass) {
  513. error_setg(errp, "invalid object type: %s", type);
  514. return;
  515. }
  516. if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE)) {
  517. error_setg(errp, "object type '%s' isn't supported by object-add",
  518. type);
  519. return;
  520. }
  521. if (object_class_is_abstract(klass)) {
  522. error_setg(errp, "object type '%s' is abstract", type);
  523. return;
  524. }
  525. obj = object_new(type);
  526. if (qdict) {
  527. for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
  528. object_property_set(obj, v, e->key, &local_err);
  529. if (local_err) {
  530. goto out;
  531. }
  532. }
  533. }
  534. object_property_add_child(container_get(object_get_root(), "/objects"),
  535. id, obj, &local_err);
  536. if (local_err) {
  537. goto out;
  538. }
  539. user_creatable_complete(obj, &local_err);
  540. if (local_err) {
  541. object_property_del(container_get(object_get_root(), "/objects"),
  542. id, &error_abort);
  543. goto out;
  544. }
  545. out:
  546. if (local_err) {
  547. error_propagate(errp, local_err);
  548. }
  549. object_unref(obj);
  550. }
  551. int qmp_object_add(Monitor *mon, const QDict *qdict, QObject **ret)
  552. {
  553. const char *type = qdict_get_str(qdict, "qom-type");
  554. const char *id = qdict_get_str(qdict, "id");
  555. QObject *props = qdict_get(qdict, "props");
  556. const QDict *pdict = NULL;
  557. Error *local_err = NULL;
  558. QmpInputVisitor *qiv;
  559. if (props) {
  560. pdict = qobject_to_qdict(props);
  561. if (!pdict) {
  562. error_set(&local_err, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
  563. goto out;
  564. }
  565. }
  566. qiv = qmp_input_visitor_new(props);
  567. object_add(type, id, pdict, qmp_input_get_visitor(qiv), &local_err);
  568. qmp_input_visitor_cleanup(qiv);
  569. out:
  570. if (local_err) {
  571. qerror_report_err(local_err);
  572. error_free(local_err);
  573. return -1;
  574. }
  575. return 0;
  576. }
  577. void qmp_object_del(const char *id, Error **errp)
  578. {
  579. Object *container;
  580. Object *obj;
  581. container = container_get(object_get_root(), "/objects");
  582. obj = object_resolve_path_component(container, id);
  583. if (!obj) {
  584. error_setg(errp, "object id not found");
  585. return;
  586. }
  587. object_unparent(obj);
  588. }
  589. MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
  590. {
  591. MemoryDeviceInfoList *head = NULL;
  592. MemoryDeviceInfoList **prev = &head;
  593. qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
  594. return head;
  595. }
  596. ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
  597. {
  598. bool ambig;
  599. ACPIOSTInfoList *head = NULL;
  600. ACPIOSTInfoList **prev = &head;
  601. Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
  602. if (obj) {
  603. AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
  604. AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
  605. adevc->ospm_status(adev, &prev);
  606. } else {
  607. error_setg(errp, "command is not supported, missing ACPI device");
  608. }
  609. return head;
  610. }