diff options
author | Roman Kagan | 2020-05-29 00:55:15 +0200 |
---|---|---|
committer | Kevin Wolf | 2020-06-17 14:53:40 +0200 |
commit | 031ffd9a612618e86eb1d783b285d658e95f117d (patch) | |
tree | 1e070b2ed1d3186fe3c10769a36fc483b6b5f364 /hw/core | |
parent | block: make BlockConf size props 32bit and accept size suffixes (diff) | |
download | qemu-031ffd9a612618e86eb1d783b285d658e95f117d.tar.gz qemu-031ffd9a612618e86eb1d783b285d658e95f117d.tar.xz qemu-031ffd9a612618e86eb1d783b285d658e95f117d.zip |
qdev-properties: add getter for size32 and blocksize
Add getter for size32, and use it for blocksize, too.
In its human-readable branch, it reports approximate size in
human-readable units next to the exact byte value, like the getter for
64bit size does.
Adjust the expected test output accordingly.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200528225516.1676602-8-rvkagan@yandex-team.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r-- | hw/core/qdev-properties.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index bd4abdc1d1..63d48db70c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -730,6 +730,17 @@ const PropertyInfo qdev_prop_pci_devfn = { /* --- 32bit unsigned int 'size' type --- */ +static void get_size32(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + DeviceState *dev = DEVICE(obj); + Property *prop = opaque; + uint32_t *ptr = qdev_get_prop_ptr(dev, prop); + uint64_t value = *ptr; + + visit_type_size(v, name, &value, errp); +} + static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -763,7 +774,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, const PropertyInfo qdev_prop_size32 = { .name = "size", - .get = get_uint32, + .get = get_size32, .set = set_size32, .set_default_value = set_default_value_uint, }; @@ -821,7 +832,7 @@ const PropertyInfo qdev_prop_blocksize = { .name = "size", .description = "A power of two between " MIN_BLOCK_SIZE_STR " and " MAX_BLOCK_SIZE_STR, - .get = get_uint32, + .get = get_size32, .set = set_blocksize, .set_default_value = set_default_value_uint, }; |