qdev: Make PropertyInfo.print method get Object* argument
Make the code more generic and not specific to TYPE_DEVICE. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20201211220529.2290218-8-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
5eb32b2113
commit
40ea00b066
|
@ -801,9 +801,10 @@ invalid:
|
||||||
g_free(str);
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,
|
static int print_pci_devfn(Object *obj, Property *prop, char *dest,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
|
DeviceState *dev = DEVICE(obj);
|
||||||
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
|
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
|
||||||
|
|
||||||
if (*ptr == -1) {
|
if (*ptr == -1) {
|
||||||
|
|
|
@ -988,13 +988,12 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v,
|
||||||
const char *name, void *opaque,
|
const char *name, void *opaque,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
DeviceState *dev = DEVICE(obj);
|
|
||||||
Property *prop = opaque;
|
Property *prop = opaque;
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char *ptr = buffer;
|
char *ptr = buffer;
|
||||||
|
|
||||||
prop->info->print(dev, prop, buffer, sizeof(buffer));
|
prop->info->print(obj, prop, buffer, sizeof(buffer));
|
||||||
visit_type_str(v, name, &ptr, errp);
|
visit_type_str(v, name, &ptr, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct PropertyInfo {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
const QEnumLookup *enum_table;
|
const QEnumLookup *enum_table;
|
||||||
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
|
int (*print)(Object *obj, Property *prop, char *dest, size_t len);
|
||||||
void (*set_default_value)(ObjectProperty *op, const Property *prop);
|
void (*set_default_value)(ObjectProperty *op, const Property *prop);
|
||||||
void (*create)(ObjectClass *oc, Property *prop);
|
void (*create)(ObjectClass *oc, Property *prop);
|
||||||
ObjectPropertyAccessor *get;
|
ObjectPropertyAccessor *get;
|
||||||
|
|
Loading…
Reference in a new issue