diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-06-22 11:34:38 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-06-22 11:34:39 +0100 |
commit | 84e3d0725b06bdf8c6985788caa7776d6b7353ce (patch) | |
tree | e4b273590132a034fe693debb52e7037bb7730f2 /hw/core | |
parent | db7a99cdc1d0f4d8cbf7c41ce9e570dce04f0a11 (diff) | |
parent | 269c20b2bbd2aa8531e0cdc741fb166f290d7a2b (diff) | |
download | qemu-84e3d0725b06bdf8c6985788caa7776d6b7353ce.zip qemu-84e3d0725b06bdf8c6985788caa7776d6b7353ce.tar.gz qemu-84e3d0725b06bdf8c6985788caa7776d6b7353ce.tar.bz2 |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-06-09-v2' into staging
QAPI patches for 2017-06-09
# gpg: Signature made Tue 20 Jun 2017 13:31:39 BST
# gpg: using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-qapi-2017-06-09-v2: (41 commits)
tests/qdict: check more get_try_int() cases
console: use get_uint() for "head" property
i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
numa: use get_uint() for "size" property
pnv-core: use get_uint() for "core-pir" property
pvpanic: use get_uint() for "ioport" property
auxbus: use get_uint() for "addr" property
arm: use get_uint() for "mp-affinity" property
xen: use get_uint() for "max-ram-below-4g" property
pc: use get_uint() for "hpet-intcap" property
pc: use get_uint() for "apic-id" property
pc: use get_uint() for "iobase" property
acpi: use get_uint() for "pci-hole*" properties
acpi: use get_uint() for various acpi properties
acpi: use get_uint() for "acpi-pcihp-io*" properties
platform-bus: use get_uint() for "addr" property
bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base"
aspeed: use {set, get}_uint() for "ram-size" property
pcihp: use get_uint() for "bsel" property
pc-dimm: make "size" property uint64
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/platform-bus.c | 2 | ||||
-rw-r--r-- | hw/core/qdev-properties.c | 40 | ||||
-rw-r--r-- | hw/core/qdev.c | 13 |
3 files changed, 42 insertions, 13 deletions
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c index 329ac67..33d32fb 100644 --- a/hw/core/platform-bus.c +++ b/hw/core/platform-bus.c @@ -71,7 +71,7 @@ hwaddr platform_bus_get_mmio_addr(PlatformBusDevice *pbus, SysBusDevice *sbdev, return -1; } - return object_property_get_int(OBJECT(sbdev_mr), "addr", NULL); + return object_property_get_uint(OBJECT(sbdev_mr), "addr", NULL); } static void platform_bus_count_irqs(SysBusDevice *sbdev, void *opaque) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 9f1a497..68cd653 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.i], + 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.u, 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,21 @@ 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.i, prop->name, &error_abort); +} + +static void set_default_value_uint(Object *obj, const Property *prop) +{ + object_property_set_uint(obj, prop->defval.u, prop->name, &error_abort); +} + PropertyInfo qdev_prop_uint8 = { .name = "uint8", .get = get_uint8, .set = set_uint8, + .set_default_value = set_default_value_uint, }; /* --- 16bit integer --- */ @@ -282,6 +307,7 @@ PropertyInfo qdev_prop_uint16 = { .name = "uint16", .get = get_uint16, .set = set_uint16, + .set_default_value = set_default_value_uint, }; /* --- 32bit integer --- */ @@ -340,12 +366,14 @@ PropertyInfo qdev_prop_uint32 = { .name = "uint32", .get = get_uint32, .set = set_uint32, + .set_default_value = set_default_value_uint, }; PropertyInfo qdev_prop_int32 = { .name = "int32", .get = get_int32, .set = set_int32, + .set_default_value = set_default_value_int, }; /* --- 64bit integer --- */ @@ -379,6 +407,7 @@ PropertyInfo qdev_prop_uint64 = { .name = "uint64", .get = get_uint64, .set = set_uint64, + .set_default_value = set_default_value_uint, }; /* --- string --- */ @@ -526,6 +555,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 +567,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 +581,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 +595,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 +606,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 +682,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 +730,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_uint, }; /* --- pci host address --- */ @@ -917,6 +953,7 @@ PropertyInfo qdev_prop_arraylen = { .name = "uint32", .get = get_uint32, .set = set_prop_arraylen, + .set_default_value = set_default_value_uint, }; /* --- public helpers --- */ @@ -1153,4 +1190,5 @@ PropertyInfo qdev_prop_size = { .name = "size", .get = get_size, .set = set_size, + .set_default_value = set_default_value_uint, }; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0ce45a2..849952a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -793,17 +793,8 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, prop->info->description, &error_abort); - if (prop->qtype == QTYPE_NONE) { - return; - } - - if (prop->qtype == QTYPE_QBOOL) { - object_property_set_bool(obj, prop->defval, prop->name, &error_abort); - } else if (prop->info->enum_table) { - object_property_set_str(obj, prop->info->enum_table[prop->defval], - prop->name, &error_abort); - } else if (prop->qtype == QTYPE_QINT) { - object_property_set_int(obj, prop->defval, prop->name, &error_abort); + if (prop->info->set_default_value) { + prop->info->set_default_value(obj, prop); } } |