#include "qdev.h"
#include "monitor.h"
+#include "qmp-commands.h"
/*
* Aliases were a bad idea from the start. Let's keep them
* for removal. This conditional should be removed along with
* it.
*/
- if (!prop->info->parse) {
+ if (!prop->info->set) {
continue; /* no way to set it, don't show */
}
error_printf("%s.%s=%s\n", driver, prop->name,
}
if (info->bus_info) {
for (prop = info->bus_info->props; prop && prop->name; prop++) {
- if (!prop->info->parse) {
+ if (!prop->info->set) {
continue; /* no way to set it, don't show */
}
error_printf("%s.%s=%s\n", driver, prop->name,
static Object *dev;
if (dev == NULL) {
- dev = object_new("container");
- object_property_add_child(object_get_root(), "peripheral",
- OBJECT(dev), NULL);
+ dev = container_get(qdev_get_machine(), "/peripheral");
}
return dev;
static Object *dev;
if (dev == NULL) {
- dev = object_new("container");
- object_property_add_child(object_get_root(), "peripheral-anon",
- OBJECT(dev), NULL);
+ dev = container_get(qdev_get_machine(), "/peripheral-anon");
}
return dev;
id = qemu_opts_id(opts);
if (id) {
qdev->id = id;
+ }
+ if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
+ qdev_free(qdev);
+ return NULL;
+ }
+ if (qdev->id) {
object_property_add_child(qdev_get_peripheral(), qdev->id,
OBJECT(qdev), NULL);
} else {
OBJECT(qdev), NULL);
g_free(name);
}
- if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
- qdev_free(qdev);
- return NULL;
- }
if (qdev_init(qdev) < 0) {
qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
const char *prefix, int indent)
{
- char buf[64];
-
if (!props)
return;
- while (props->name) {
- /*
- * TODO Properties without a print method are just for dirty
- * hacks. qdev_prop_ptr is the only such PropertyInfo. It's
- * marked for removal. The test props->info->print should be
- * removed along with it.
- */
- if (props->info->print) {
- props->info->print(dev, props, buf, sizeof(buf));
- qdev_printf("%s-prop: %s = %s\n", prefix, props->name, buf);
+ for (; props->name; props++) {
+ Error *err = NULL;
+ char *value;
+ char *legacy_name = g_strdup_printf("legacy-%s", props->name);
+ if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
+ value = object_property_get_str(OBJECT(dev), legacy_name, &err);
+ } else {
+ value = object_property_print(OBJECT(dev), props->name, &err);
+ }
+ g_free(legacy_name);
+
+ if (err) {
+ error_free(err);
+ continue;
}
- props++;
+ qdev_printf("%s-prop: %s = %s\n", prefix, props->name,
+ value && *value ? value : "<null>");
+ g_free(value);
}
}
return 0;
}
-int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_device_del(const char *id, Error **errp)
{
- const char *id = qdict_get_str(qdict, "id");
DeviceState *dev;
dev = qdev_find_recursive(sysbus_get_default(), id);
if (NULL == dev) {
- qerror_report(QERR_DEVICE_NOT_FOUND, id);
- return -1;
+ error_set(errp, QERR_DEVICE_NOT_FOUND, id);
+ return;
}
- return qdev_unplug(dev);
+
+ qdev_unplug(dev, errp);
}
void qdev_machine_init(void)