提交 745a4f5e 编写于 作者: M Marc-André Lureau 提交者: Eduardo Habkost

accel: register global_props like machine globals

global_props is only used for Xen xen_compat_props. It's a static
array of GlobalProperty, like machine globals in SET_MACHINE_COMPAT().
Let's register the globals the same way, without extra copy allocation.
Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
Message-Id: <20181204142023.15982-5-marcandre.lureau@redhat.com>
Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
上级 3650b2de
......@@ -34,6 +34,7 @@
#include "qom/object.h"
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qapi/error.h"
static const TypeInfo accel_type = {
.name = TYPE_ACCEL,
......@@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms)
void accel_register_compat_props(AccelState *accel)
{
AccelClass *class = ACCEL_GET_CLASS(accel);
register_compat_props_array(class->global_props);
GlobalProperty *prop = class->global_props;
for (; prop && prop->driver; prop++) {
/* Any compat_props must never cause error */
prop->errp = &error_abort;
qdev_prop_register_global(prop);
}
}
void accel_setup_post(MachineState *ms)
......
......@@ -1180,27 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
global_props = g_list_append(global_props, prop);
}
void register_compat_prop(const char *driver,
const char *property,
const char *value)
{
GlobalProperty *p = g_new0(GlobalProperty, 1);
/* Any compat_props must never cause error */
p->errp = &error_abort;
p->driver = driver;
p->property = property;
p->value = value;
qdev_prop_register_global(p);
}
void register_compat_props_array(GlobalProperty *prop)
{
for (; prop && prop->driver; prop++) {
register_compat_prop(prop->driver, prop->property, prop->value);
}
}
void qdev_prop_register_global_list(GlobalProperty *props)
{
int i;
......
......@@ -255,35 +255,6 @@ void qdev_prop_set_globals(DeviceState *dev);
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
Property *prop, const char *value);
/**
* register_compat_prop:
*
* Register internal (not user-provided) global property, changing the
* default value of a given property in a device type. This can be used
* for enabling machine-type compatibility or for enabling
* accelerator-specific defaults in devices.
*
* The property values set using this function must be always valid and
* never report setter errors, as the property will have
* GlobalProperty::errp set to &error_abort.
*
* User-provided global properties should override internal global
* properties, so callers of this function should ensure that it is
* called before user-provided global properties are registered.
*
* @driver: Device type to be affected
* @property: Property whose default value is going to be changed
* @value: New default value for the property
*/
void register_compat_prop(const char *driver, const char *property,
const char *value);
/*
* register_compat_props_array(): using register_compat_prop(), which
* only registers internal global properties (which has lower priority
* than user-provided global properties)
*/
void register_compat_props_array(GlobalProperty *prop);
/**
* qdev_property_add_static:
* @dev: Device to add the property to.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册