diff options
author | Marc-André Lureau | 2017-06-07 18:35:53 +0200 |
---|---|---|
committer | Markus Armbruster | 2017-06-19 14:56:29 +0200 |
commit | a2740ad584839ac84f3cdb2d928de93a0d7f4e72 (patch) | |
tree | 8230dd4feda8eec4323bb09ca9b25baa3883d3b3 /hw/core/qdev-properties.c | |
parent | Merge remote-tracking branch 'remotes/rth/tags/pull-s390-20170613' into staging (diff) | |
download | qemu-a2740ad584839ac84f3cdb2d928de93a0d7f4e72.tar.gz qemu-a2740ad584839ac84f3cdb2d928de93a0d7f4e72.tar.xz qemu-a2740ad584839ac84f3cdb2d928de93a0d7f4e72.zip |
qdev: remove PropertyInfo.qtype field
Remove dependency on qapi qtype, replace a field by a few PropertyInfo
callbacks to set the default value type (introduced in commit 4f2d3d7).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170607163635.17635-2-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/core/qdev-properties.c')
-rw-r--r-- | hw/core/qdev-properties.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 9f1a497322..c5e028a45e 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -69,6 +69,12 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } +static void set_default_value_enum(Object *obj, const Property *prop) +{ + object_property_set_str(obj, prop->info->enum_table[prop->defval], + prop->name, &error_abort); +} + /* Bit */ static uint32_t qdev_get_prop_mask(Property *prop) @@ -120,11 +126,17 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name, bit_prop_set(dev, prop, value); } +static void set_default_value_bool(Object *obj, const Property *prop) +{ + object_property_set_bool(obj, prop->defval, prop->name, &error_abort); +} + PropertyInfo qdev_prop_bit = { .name = "bool", .description = "on/off", .get = prop_get_bit, .set = prop_set_bit, + .set_default_value = set_default_value_bool, }; /* Bit64 */ @@ -183,6 +195,7 @@ PropertyInfo qdev_prop_bit64 = { .description = "on/off", .get = prop_get_bit64, .set = prop_set_bit64, + .set_default_value = set_default_value_bool, }; /* --- bool --- */ @@ -216,6 +229,7 @@ PropertyInfo qdev_prop_bool = { .name = "bool", .get = get_bool, .set = set_bool, + .set_default_value = set_default_value_bool, }; /* --- 8bit integer --- */ @@ -245,10 +259,16 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_uint8(v, name, ptr, errp); } +static void set_default_value_int(Object *obj, const Property *prop) +{ + object_property_set_int(obj, prop->defval, prop->name, &error_abort); +} + PropertyInfo qdev_prop_uint8 = { .name = "uint8", .get = get_uint8, .set = set_uint8, + .set_default_value = set_default_value_int, }; /* --- 16bit integer --- */ @@ -282,6 +302,7 @@ PropertyInfo qdev_prop_uint16 = { .name = "uint16", .get = get_uint16, .set = set_uint16, + .set_default_value = set_default_value_int, }; /* --- 32bit integer --- */ @@ -340,12 +361,14 @@ PropertyInfo qdev_prop_uint32 = { .name = "uint32", .get = get_uint32, .set = set_uint32, + .set_default_value = set_default_value_int, }; PropertyInfo qdev_prop_int32 = { .name = "int32", .get = get_int32, .set = set_int32, + .set_default_value = set_default_value_int, }; /* --- 64bit integer --- */ @@ -379,6 +402,7 @@ PropertyInfo qdev_prop_uint64 = { .name = "uint64", .get = get_uint64, .set = set_uint64, + .set_default_value = set_default_value_int, }; /* --- string --- */ @@ -526,6 +550,7 @@ PropertyInfo qdev_prop_on_off_auto = { .enum_table = OnOffAuto_lookup, .get = get_enum, .set = set_enum, + .set_default_value = set_default_value_enum, }; /* --- lost tick policy --- */ @@ -537,6 +562,7 @@ PropertyInfo qdev_prop_losttickpolicy = { .enum_table = LostTickPolicy_lookup, .get = get_enum, .set = set_enum, + .set_default_value = set_default_value_enum, }; /* --- Block device error handling policy --- */ @@ -550,6 +576,7 @@ PropertyInfo qdev_prop_blockdev_on_error = { .enum_table = BlockdevOnError_lookup, .get = get_enum, .set = set_enum, + .set_default_value = set_default_value_enum, }; /* --- BIOS CHS translation */ @@ -563,6 +590,7 @@ PropertyInfo qdev_prop_bios_chs_trans = { .enum_table = BiosAtaTranslation_lookup, .get = get_enum, .set = set_enum, + .set_default_value = set_default_value_enum, }; /* --- FDC default drive types */ @@ -573,7 +601,8 @@ PropertyInfo qdev_prop_fdc_drive_type = { "144/288/120/none/auto", .enum_table = FloppyDriveType_lookup, .get = get_enum, - .set = set_enum + .set = set_enum, + .set_default_value = set_default_value_enum, }; /* --- pci address --- */ @@ -648,6 +677,7 @@ PropertyInfo qdev_prop_pci_devfn = { .print = print_pci_devfn, .get = get_int32, .set = set_pci_devfn, + .set_default_value = set_default_value_int, }; /* --- blocksize --- */ @@ -695,6 +725,7 @@ PropertyInfo qdev_prop_blocksize = { .description = "A power of two between 512 and 32768", .get = get_uint16, .set = set_blocksize, + .set_default_value = set_default_value_int, }; /* --- pci host address --- */ @@ -917,6 +948,7 @@ PropertyInfo qdev_prop_arraylen = { .name = "uint32", .get = get_uint32, .set = set_prop_arraylen, + .set_default_value = set_default_value_int, }; /* --- public helpers --- */ @@ -1153,4 +1185,5 @@ PropertyInfo qdev_prop_size = { .name = "size", .get = get_size, .set = set_size, + .set_default_value = set_default_value_int, }; |