Property type reporting improvements
v2 cover Property type reporting improvements
QOM properties could use similar work. Left for another day.
v2: Rebased
Markus Armbruster (6):
qdev: Delete unused qdev_prop_enum
qdev: Change qdev_prop_pci_devfn member @name from "int32" to "str"
qdev: Rename PropertyInfo member @name to @type
qdev: Change values of PropertyInfo member @type to be QAPI types
qdev: Improve PropertyInfo member @description for enum properties
qdev: Improve a few more PropertyInfo @description members
include/hw/qdev-properties.h | 3 +- backends/tpm/tpm_util.c | 2 +- hw/block/xen-block.c | 4 +- hw/core/qdev-properties-system.c | 78 +++++++++++++++----------------- hw/core/qdev-properties.c | 44 ++++++++---------- hw/misc/xlnx-versal-trng.c | 2 +- hw/nvme/nguid.c | 2 +- hw/nvram/xlnx-bbram.c | 2 +- hw/nvram/xlnx-efuse.c | 2 +- hw/pci/pci.c | 2 +- hw/s390x/ccw-device.c | 6 +-- hw/s390x/css.c | 4 +- hw/s390x/s390-pci-bus.c | 3 +- hw/vfio/pci-quirks.c | 2 +- target/riscv/cpu.c | 44 ++++++++++++------ target/sparc/cpu.c | 3 +- hw/display/apple-gfx.m | 2 +- 17 files changed, 106 insertions(+), 99 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/6 qdev: Delete unused qdev_prop_enum
--- include/hw/qdev-properties.h | 1 - hw/core/qdev-properties.c | 7 ------- 2 files changed, 8 deletions(-)
include/hw/qdev-properties.h +0 -1
@@ -49,7 +49,6 @@ struct PropertyInfo {extern const PropertyInfo qdev_prop_bit;extern const PropertyInfo qdev_prop_bit64;extern const PropertyInfo qdev_prop_bool; -extern const PropertyInfo qdev_prop_enum;extern const PropertyInfo qdev_prop_uint8;extern const PropertyInfo qdev_prop_uint16;extern const PropertyInfo qdev_prop_uint32;
hw/core/qdev-properties.c +0 -7
@@ -122,13 +122,6 @@ void qdev_propinfo_set_default_value_enum(ObjectProperty *op, qapi_enum_lookup(prop->info->enum_table, prop->defval.i)); } -const PropertyInfo qdev_prop_enum = { - .name ="enum" , - .get = qdev_propinfo_get_enum, - .set = qdev_propinfo_set_enum, - .set_default_value = qdev_propinfo_set_default_value_enum, -}; -/* Bit */ static uint32_t qdev_get_prop_mask (const Property *prop)
Signature · 1 line
2.48.1
Re: [PATCH v2 1/6] qdev: Delete unused qdev_prop_enum
Quoted 5 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- include/hw/qdev-properties.h | 1 - hw/core/qdev-properties.c | 7 ------- 2 files changed, 8 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v2 2/6 qdev: Change qdev_prop_pci_devfn member @name from "int32" to "str"
In reply to Markus ArmbrusterProperties using qdev_prop_pci_devfn initially accepted a string of the form "DEV.FN" or "DEV" where DEV and FN are in hexadecimal. Member @name was "pci-devfn" initially.
Commit b403298adb5 (qdev: make the non-legacy pci address property accept an integer) changed them to additionally accept integers: bits 3..7 are DEV, and bits 0..2 are FN. This is inaccessible externally in device_add so far.
The commit also changed @name to "int32", and set member @legacy-name to "pci-devfn". Together, this kept QMP command device-list-properties unaffected: it used @name only when @legacy_name was null.
Commit 07d09c58dbb (qmp: Print descriptions of object properties) quietly dumbed that down to use @name always, and the next commit 18b91a3e082q (qdev: Drop legacy_name from qdev properties) dropped member @legacy_name. This changed the value of @type reported by QMP command device-list-properties from "pci-devfn" to "int32".
But "int32" is misleading: device_add actually wants QAPI type "str". So change @name to that.
--- hw/core/qdev-properties-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev-properties-system.c +1 -1
@@ -882,7 +882,7 @@ static int print_pci_devfn(Object *obj, const Property *prop, char *dest, }const PropertyInfo qdev_prop_pci_devfn = { - .name ="int32" , + .name ="str" , .description ="Slot and optional function number, example: 06.0 or 06" , .print = print_pci_devfn, .get = qdev_propinfo_get_int32,
Signature · 1 line
2.48.1
Re: [PATCH v2 2/6] qdev: Change qdev_prop_pci_devfn member @name from "int32" to "str"
Quoted 14 lines · Markus Armbruster
Properties using
qdev_prop_pci_devfninitially accepted a string of the form "DEV.FN" or "DEV" where DEV and FN are in hexadecimal. Member @name was "pci-devfn" initially.Commit
b403298adb5(qdev: make the non-legacy pci address property accept an integer) changed them to additionally accept integers: bits 3..7 are DEV, and bits 0..2 are FN. This is inaccessible externally indevice_addso far.The commit also changed @name to "int32", and set member @legacy-name to "pci-devfn". Together, this kept QMP command device-list-properties unaffected: it used @name only when @legacy_name was null.
Quoted 8 lines
Commit
07d09c58dbb(qmp: Print descriptions of object properties) quietly dumbed that down to use @name always, and the next commit 18b91a3e082q (qdev: Droplegacy_namefrom qdev properties) dropped member @legacy_name. This changed the value of @type reported by QMP command device-list-properties from "pci-devfn" to "int32".But "int32" is misleading:
device_addactually wants QAPI type "str". So change @name to that.
That history is "fun" :-)
Quoted 5 lines
Signed-off-by Markus Armbruster <[email protected]>--- hw/core/qdev-properties-system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v2 3/6 qdev: Rename PropertyInfo member @name to @type
In reply to Markus ArmbrusterPropertyInfo member @name becomes ObjectProperty member @type, while Property member @name becomes ObjectProperty member @name. Rename the former.
--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 2 +- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 50 ++++++++++++++++---------------- hw/core/qdev-properties.c | 36 +++++++++++------------ hw/misc/xlnx-versal-trng.c | 2 +- hw/nvme/nguid.c | 2 +- hw/nvram/xlnx-bbram.c | 2 +- hw/nvram/xlnx-efuse.c | 2 +- hw/pci/pci.c | 2 +- hw/s390x/ccw-device.c | 2 +- hw/s390x/css.c | 4 +-- hw/s390x/s390-pci-bus.c | 2 +- hw/vfio/pci-quirks.c | 2 +- target/riscv/cpu.c | 28 +++++++++--------- target/sparc/cpu.c | 2 +- hw/display/apple-gfx.m | 2 +- 17 files changed, 72 insertions(+), 72 deletions(-)
include/hw/qdev-properties.h +1 -1
@@ -30,7 +30,7 @@ struct Property { };struct PropertyInfo { -const char *name; +const char *type;const char *description;const QEnumLookup *enum_table;bool realized_set_allowed;/* allow setting property on realized device */
backends/tpm/tpm_util.c +1 -1
@@ -76,7 +76,7 @@ static void release_tpm(Object *obj, const char *name, void *opaque) }const PropertyInfo qdev_prop_tpm = { - .name ="str" , + .type ="str" , .description ="ID of a tpm to use as a backend" , .get = get_tpm, .set = set_tpm,
hw/block/xen-block.c +1 -1
@@ -661,7 +661,7 @@ invalid:* https://xenbits.xen.org/docs/unstable/man/xen-vbd-interface.7.html */ static const PropertyInfo xen_block_prop_vdev = { - .name ="str" , + .type ="str" , .description ="Virtual Disk specifier: d*p*/xvd*/hd*/sd*" , .get = xen_block_get_vdev, .set = xen_block_set_vdev,
hw/core/qdev-properties-system.c +25 -25
200 lines not on this page · raw message
hw/core/qdev-properties.c +18 -18
@@ -169,7 +169,7 @@ static void set_default_value_bool(ObjectProperty *op, const Property *prop) }const PropertyInfo qdev_prop_bit = { - .name ="bool" , + .type ="bool" , .description ="on/off" , .get = prop_get_bit, .set = prop_set_bit,
@@ -218,7 +218,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, const char *name, }const PropertyInfo qdev_prop_bit64 = { - .name ="bool" , + .type ="bool" , .description ="on/off" , .get = prop_get_bit64, .set = prop_set_bit64,
@@ -246,7 +246,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, }const PropertyInfo qdev_prop_bool = { - .name ="bool" , + .type ="bool" , .get = get_bool, .set = set_bool, .set_default_value = set_default_value_bool,
@@ -285,7 +285,7 @@ void qdev_propinfo_set_default_value_uint(ObjectProperty *op, }const PropertyInfo qdev_prop_uint8 = { - .name ="uint8" , + .type ="uint8" , .get = get_uint8, .set = set_uint8, .set_default_value = qdev_propinfo_set_default_value_uint,
@@ -312,7 +312,7 @@ static void set_uint16(Object *obj, Visitor *v, const char *name, }const PropertyInfo qdev_prop_uint16 = { - .name ="uint16" , + .type ="uint16" , .get = get_uint16, .set = set_uint16, .set_default_value = qdev_propinfo_set_default_value_uint,
@@ -357,14 +357,14 @@ static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, }const PropertyInfo qdev_prop_uint32 = { - .name ="uint32" , + .type ="uint32" , .get = get_uint32, .set = set_uint32, .set_default_value = qdev_propinfo_set_default_value_uint, };const PropertyInfo qdev_prop_int32 = { - .name ="int32" , + .type ="int32" , .get = qdev_propinfo_get_int32, .set = set_int32, .set_default_value = qdev_propinfo_set_default_value_int,
@@ -409,14 +409,14 @@ static void set_int64(Object *obj, Visitor *v, const char *name, }const PropertyInfo qdev_prop_uint64 = { - .name ="uint64" , + .type ="uint64" , .get = get_uint64, .set = set_uint64, .set_default_value = qdev_propinfo_set_default_value_uint, };const PropertyInfo qdev_prop_int64 = { - .name ="int64" , + .type ="int64" , .get = get_int64, .set = set_int64, .set_default_value = qdev_propinfo_set_default_value_int,
@@ -436,7 +436,7 @@ static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name, }const PropertyInfo qdev_prop_uint64_checkmask = { - .name ="uint64" , + .type ="uint64" , .get = get_uint64, .set = set_uint64_checkmask, };
@@ -478,7 +478,7 @@ static void set_string(Object *obj, Visitor *v, const char *name, }const PropertyInfo qdev_prop_string = { - .name ="str" , + .type ="str" , .release = release_string, .get = get_string, .set = set_string,
@@ -487,7 +487,7 @@ const PropertyInfo qdev_prop_string = {/* --- on/off/auto --- */ const PropertyInfo qdev_prop_on_off_auto = { - .name ="OnOffAuto" , + .type ="OnOffAuto" , .description ="on/off/auto" , .enum_table = &OnOffAuto_lookup, .get = qdev_propinfo_get_enum,
@@ -530,7 +530,7 @@ static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, }const PropertyInfo qdev_prop_size32 = { - .name ="size" , + .type ="size" , .get = qdev_propinfo_get_size32, .set = set_size32, .set_default_value = qdev_propinfo_set_default_value_uint,
@@ -733,7 +733,7 @@ static void default_prop_array(ObjectProperty *op, const Property *prop) }const PropertyInfo qdev_prop_array = { - .name ="list" , + .type ="list" , .get = get_prop_array, .set = set_prop_array, .release = release_prop_array,
@@ -937,7 +937,7 @@ static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, }const PropertyInfo qdev_prop_size = { - .name ="size" , + .type ="size" , .get = get_size, .set = set_size, .set_default_value = qdev_propinfo_set_default_value_uint,
@@ -955,7 +955,7 @@ static ObjectProperty *create_link_property(ObjectClass *oc, const char *name, }const PropertyInfo qdev_prop_link = { - .name ="link" , + .type ="link" , .create = create_link_property, };
@@ -966,7 +966,7 @@ void qdev_property_add_static(DeviceState *dev, const Property *prop)assert (!prop->info->create); - op = object_property_add(obj, prop->name, prop->info->name, + op = object_property_add(obj, prop->name, prop->info->type, field_prop_getter(prop->info), field_prop_setter(prop->info), prop->info->release,
@@ -993,7 +993,7 @@ static void qdev_class_add_property(DeviceClass *klass, const char *name, op = prop->info->create (oc, name, prop); }else { op = object_class_property_add(oc, - name, prop->info->name, + name, prop->info->type, field_prop_getter(prop->info), field_prop_setter(prop->info), prop->info->release,
hw/misc/xlnx-versal-trng.c +1 -1
@@ -652,7 +652,7 @@ static void trng_prop_fault_event_set(Object *obj, Visitor *v, }static const PropertyInfo trng_prop_fault_events = { - .name ="uint32:bits" , + .type ="uint32:bits" , .description ="Set to trigger TRNG fault events" , .set = trng_prop_fault_event_set, .realized_set_allowed = true,
hw/nvme/nguid.c +1 -1
@@ -179,7 +179,7 @@ static void set_nguid(Object *obj, Visitor *v, const char *name, void *opaque, }const PropertyInfo qdev_prop_nguid = { - .name ="str" , + .type ="str" , .description ="NGUID or \"" NGUID_VALUE_AUTO "\" for random value" , .get = get_nguid,
hw/nvram/xlnx-bbram.c +1 -1
@@ -502,7 +502,7 @@ static void bbram_prop_release_drive(Object *obj, const char *name, }static const PropertyInfo bbram_prop_drive = { - .name ="str" , + .type ="str" , .description ="Node name or ID of a block device to use as BBRAM backend" , .realized_set_allowed = true, .get = bbram_prop_get_drive,
hw/nvram/xlnx-efuse.c +1 -1
@@ -257,7 +257,7 @@ static void efuse_prop_release_drive(Object *obj, const char *name, }static const PropertyInfo efuse_prop_drive = { - .name ="str" , + .type ="str" , .description ="Node name or ID of a block device to use as eFUSE backend" , .realized_set_allowed = true, .get = efuse_prop_get_drive,
hw/pci/pci.c +1 -1
@@ -77,7 +77,7 @@ static void prop_pci_busnr_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_pci_busnr = { - .name ="busnr" , + .type ="busnr" , .get = prop_pci_busnr_get, };
hw/s390x/ccw-device.c +1 -1
@@ -74,7 +74,7 @@ static void ccw_device_set_loadparm(Object *obj, Visitor *v, }const PropertyInfo ccw_loadparm = { - .name ="ccw_loadparm" , + .type ="ccw_loadparm" , .description ="Up to 8 chars in set of [A-Za-z0-9. ] to pass" " to the guest loader/kernel" , .get = ccw_device_get_loadparm,
hw/s390x/css.c +2 -2
@@ -2523,7 +2523,7 @@ out: }const PropertyInfo css_devid_propinfo = { - .name ="str" , + .type ="str" , .description ="Identifier of an I/O device in the channel " "subsystem, example: fe.1.23ab" , .get = get_css_devid,
@@ -2531,7 +2531,7 @@ const PropertyInfo css_devid_propinfo = { };const PropertyInfo css_devid_ro_propinfo = { - .name ="str" , + .type ="str" , .description ="Read-only identifier of an I/O device in the channel " "subsystem, example: fe.1.23ab" , .get = get_css_devid,
hw/s390x/s390-pci-bus.c +1 -1
@@ -1495,7 +1495,7 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, }static const PropertyInfo s390_pci_fid_propinfo = { - .name ="zpci_fid" , + .type ="zpci_fid" , .get = s390_pci_get_fid, .set = s390_pci_set_fid, };
hw/vfio/pci-quirks.c +1 -1
@@ -1480,7 +1480,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, }const PropertyInfo qdev_prop_nv_gpudirect_clique = { - .name ="uint4" , + .type ="uint4" , .description ="NVIDIA GPUDirect Clique ID (0 - 15)" , .get = get_nv_gpudirect_clique_id, .set = set_nv_gpudirect_clique_id,
target/riscv/cpu.c +14 -14
@@ -1817,7 +1817,7 @@ static void prop_pmu_num_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_pmu_num = { - .name ="pmu-num" , + .type ="pmu-num" , .get = prop_pmu_num_get, .set = prop_pmu_num_set, };
@@ -1858,7 +1858,7 @@ static void prop_pmu_mask_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_pmu_mask = { - .name ="pmu-mask" , + .type ="pmu-mask" , .get = prop_pmu_mask_get, .set = prop_pmu_mask_set, };
@@ -1889,7 +1889,7 @@ static void prop_mmu_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_mmu = { - .name ="mmu" , + .type ="mmu" , .get = prop_mmu_get, .set = prop_mmu_set, };
@@ -1920,7 +1920,7 @@ static void prop_pmp_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_pmp = { - .name ="pmp" , + .type ="pmp" , .get = prop_pmp_get, .set = prop_pmp_set, };
@@ -1994,7 +1994,7 @@ static void prop_priv_spec_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_priv_spec = { - .name ="priv_spec" , + .type ="priv_spec" , .get = prop_priv_spec_get, .set = prop_priv_spec_set, };
@@ -2025,7 +2025,7 @@ static void prop_vext_spec_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_vext_spec = { - .name ="vext_spec" , + .type ="vext_spec" , .get = prop_vext_spec_get, .set = prop_vext_spec_set, };
@@ -2065,7 +2065,7 @@ static void prop_vlen_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_vlen = { - .name ="vlen" , + .type ="vlen" , .get = prop_vlen_get, .set = prop_vlen_set, };
@@ -2105,7 +2105,7 @@ static void prop_elen_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_elen = { - .name ="elen" , + .type ="elen" , .get = prop_elen_get, .set = prop_elen_set, };
@@ -2140,7 +2140,7 @@ static void prop_cbom_blksize_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_cbom_blksize = { - .name ="cbom_blocksize" , + .type ="cbom_blocksize" , .get = prop_cbom_blksize_get, .set = prop_cbom_blksize_set, };
@@ -2175,7 +2175,7 @@ static void prop_cbop_blksize_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_cbop_blksize = { - .name ="cbop_blocksize" , + .type ="cbop_blocksize" , .get = prop_cbop_blksize_get, .set = prop_cbop_blksize_set, };
@@ -2210,7 +2210,7 @@ static void prop_cboz_blksize_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_cboz_blksize = { - .name ="cboz_blocksize" , + .type ="cboz_blocksize" , .get = prop_cboz_blksize_get, .set = prop_cboz_blksize_set, };
@@ -2245,7 +2245,7 @@ static void prop_mvendorid_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_mvendorid = { - .name ="mvendorid" , + .type ="mvendorid" , .get = prop_mvendorid_get, .set = prop_mvendorid_set, };
@@ -2280,7 +2280,7 @@ static void prop_mimpid_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_mimpid = { - .name ="mimpid" , + .type ="mimpid" , .get = prop_mimpid_get, .set = prop_mimpid_set, };
@@ -2336,7 +2336,7 @@ static void prop_marchid_get(Object *obj, Visitor *v, const char *name, }static const PropertyInfo prop_marchid = { - .name ="marchid" , + .type ="marchid" , .get = prop_marchid_get, .set = prop_marchid_set, };
target/sparc/cpu.c +1 -1
@@ -938,7 +938,7 @@ static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, }static const PropertyInfo qdev_prop_nwindows = { - .name ="int" , + .type ="int" , .get = sparc_get_nwindows, .set = sparc_set_nwindows, };
hw/display/apple-gfx.m +1 -1
@@ -871,7 +871,7 @@ static void apple_gfx_set_display_mode(Object *obj, Visitor *v, } const PropertyInfo qdev_prop_apple_gfx_display_mode = { - .name = "display_mode", + .type = "display_mode", .description = "Display mode in pixels and Hertz, as <width>x<height>@<refresh-rate> " "Example: 3840x2160@60",
Signature · 1 line
2.48.1
Re: [PATCH v2 3/6] qdev: Rename PropertyInfo member @name to @type
Quoted 16 lines · Markus Armbruster
PropertyInfo member @name becomes ObjectProperty member @type, while Property member @name becomes ObjectProperty member @name. Rename the former.
Signed-off-by Markus Armbruster <[email protected]>--- include/hw/qdev-properties.h | 2 +- backends/tpm/tpm_util.c | 2 +- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 50 ++++++++++++++++---------------- hw/core/qdev-properties.c | 36 +++++++++++------------ hw/misc/xlnx-versal-trng.c | 2 +- hw/nvme/nguid.c | 2 +- hw/nvram/xlnx-bbram.c | 2 +- hw/nvram/xlnx-efuse.c | 2 +- hw/pci/pci.c | 2 +-
Quoted 8 lines
hw/s390x/ccw-device.c | 2 +- hw/s390x/css.c | 4 +-- hw/s390x/s390-pci-bus.c | 2 +- hw/vfio/pci-quirks.c | 2 +- target/riscv/cpu.c | 28 +++++++++--------- target/sparc/cpu.c | 2 +- hw/display/apple-gfx.m | 2 +- 17 files changed, 72 insertions(+), 72 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v2 4/6 qdev: Change values of PropertyInfo member @type to be QAPI types
In reply to Markus ArmbrusterPropertyInfo member @type is externally visible via QMP device-list-properties and qom-list-properies.
Its meaning is not documented at its definition.
It gets passed to as @type argument to object_property_add() and object_class_property_add(). This argument's documentation isn't of much help, either:
* @type: the type name of the property. This namespace is pretty loosely
* defined. Sub namespaces are constructed by using a prefix and then * to angle brackets. For instance, the type 'virtio-net-pci' in the * 'link' namespace would be 'link<virtio-net-pci>'.
The two QMP commands document it as
# @type: the type of the property. This will typically come in one of
# four forms:
#
# 1) A primitive type such as 'u8', 'u16', 'bool', 'str', or
# 'double'. These types are mapped to the appropriate JSON
# type.
#
# 2) A child type in the form 'child<subtype>' where subtype is a
# qdev device type name. Child properties create the
# composition tree.
#
# 3) A link type in the form 'link<subtype>' where subtype is a
# qdev device type name. Link properties form the device model
# graph.
"Typically come in one of four forms" followed by three items inspires the level of trust that is appropriate here.
Clean up a bunch of funnies:
* qdev_prop_fdc_drive_type.type is "FdcDriveType". Its .enum_table refers to QAPI type "FloppyDriveType". So use that.
* qdev_prop_reserved_region is "reserved_region". Its only user is an array property called "reserved-regions". Its .set() visits str. So change @type to "str".
* trng_prop_fault_event_set.type is "uint32:bits". Its .set() visits uint32, so change @type to "uint32". If we believe mentioning it's actually bits is useful, the proper place would be .description.
* ccw_loadparm.type is "ccw_loadparm". It's users are properties called "loadparm". Its .set() visits str. So change @type to "str".
* qdev_prop_nv_gpudirect_clique.type is "uint4". Its set() visits uint8, so change @type to "uint8". If we believe mentioning the range is useful, the proper place would be .description.
* s390_pci_fid_propinfo.type is "zpci_fid". Its .set() visits uint32. So change type to that, and move the "zpci_fid" to .description. This is admittedly a lousy description, but it's still an improvement; for instance, output of -device zpci,help changes from
fid=<zpci_fid>
to
fid=<uint32> - zpci_fid
* Similarly for a raft of PropertyInfo in target/riscv/cpu.c.
--- hw/core/qdev-properties-system.c | 4 +-- hw/misc/xlnx-versal-trng.c | 2 +- hw/s390x/ccw-device.c | 2 +- hw/s390x/s390-pci-bus.c | 3 ++- hw/vfio/pci-quirks.c | 2 +- target/riscv/cpu.c | 44 ++++++++++++++++++++++---------- 6 files changed, 37 insertions(+), 20 deletions(-)
hw/core/qdev-properties-system.c +2 -2
@@ -667,7 +667,7 @@ const PropertyInfo qdev_prop_bios_chs_trans = {/* --- FDC default drive types */ const PropertyInfo qdev_prop_fdc_drive_type = { - .type ="FdcDriveType" , + .type ="FloppyDriveType" , .description ="FDC drive type, " "144/288/120/none/auto" , .enum_table = &FloppyDriveType_lookup,
@@ -801,7 +801,7 @@ out: }const PropertyInfo qdev_prop_reserved_region = { - .type ="reserved_region" , + .type ="str" , .description ="Reserved Region, example: 0xFEE00000:0xFEEFFFFF:0" , .get = get_reserved_region, .set = set_reserved_region,
hw/misc/xlnx-versal-trng.c +1 -1
@@ -652,7 +652,7 @@ static void trng_prop_fault_event_set(Object *obj, Visitor *v, }static const PropertyInfo trng_prop_fault_events = { - .type ="uint32:bits" , + .type ="uint32" , .description ="Set to trigger TRNG fault events" , .set = trng_prop_fault_event_set, .realized_set_allowed = true,
hw/s390x/ccw-device.c +1 -1
@@ -74,7 +74,7 @@ static void ccw_device_set_loadparm(Object *obj, Visitor *v, }const PropertyInfo ccw_loadparm = { - .type ="ccw_loadparm" , + .type ="str" , .description ="Up to 8 chars in set of [A-Za-z0-9. ] to pass" " to the guest loader/kernel" , .get = ccw_device_get_loadparm,
hw/s390x/s390-pci-bus.c +2 -1
@@ -1495,7 +1495,8 @@ static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, }static const PropertyInfo s390_pci_fid_propinfo = { - .type ="zpci_fid" , + .type ="uint32" , + .description ="zpci_fid" , .get = s390_pci_get_fid, .set = s390_pci_set_fid, };
hw/vfio/pci-quirks.c +1 -1
@@ -1480,7 +1480,7 @@ static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, }const PropertyInfo qdev_prop_nv_gpudirect_clique = { - .type ="uint4" , + .type ="uint8" , .description ="NVIDIA GPUDirect Clique ID (0 - 15)" , .get = get_nv_gpudirect_clique_id, .set = set_nv_gpudirect_clique_id,
target/riscv/cpu.c +30 -14
128 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v2 4/6] qdev: Change values of PropertyInfo member @type to be QAPI types
Quoted 6 lines · Markus Armbruster
PropertyInfo member @type is externally visible via QMP device-list-properties and qom-list-properies.
Its meaning is not documented at its definition.
It gets passed to as @type argument to
object_property_add()and
^^^^^ "passed as the @type argument" ?
Quoted 64 lines
object_class_property_add(). This argument's documentation isn't of much help, either:* @type: the type name of the property. This namespace is pretty loosely
* defined. Sub namespaces are constructed by using a prefix and then * to angle brackets. For instance, the type 'virtio-net-pci' in the * 'link' namespace would be 'link<virtio-net-pci>'.The two QMP commands document it as
# @type: the type of the property. This will typically come in one of
# four forms:
#
# 1) A primitive type such as 'u8', 'u16', 'bool', 'str', or
# 'double'. These types are mapped to the appropriate JSON
# type.
#
# 2) A child type in the form 'child<subtype>' where subtype is a
# qdev device type name. Child properties create the
# composition tree.
#
# 3) A link type in the form 'link<subtype>' where subtype is a
# qdev device type name. Link properties form the device model
# graph."Typically come in one of four forms" followed by three items inspires the level of trust that is appropriate here.
Clean up a bunch of funnies:
* qdev_prop_fdc_drive_type.type is "FdcDriveType". Its .enum_table refers to QAPI type "FloppyDriveType". So use that.
*
qdev_prop_reserved_regionis "reserved_region". Its only user is an array property called "reserved-regions". Its .set() visits str. So change @type to "str".* trng_prop_fault_event_set.type is "uint32:bits". Its .set() visits uint32, so change @type to "uint32". If we believe mentioning it's actually bits is useful, the proper place would be .description.
* ccw_loadparm.type is "
ccw_loadparm". It's users are properties called "loadparm". Its .set() visits str. So change @type to "str".* qdev_prop_nv_gpudirect_clique.type is "uint4". Its
set()visits uint8, so change @type to "uint8". If we believe mentioning the range is useful, the proper place would be .description.* s390_pci_fid_propinfo.type is "
zpci_fid". Its .set() visits uint32. So change type to that, and move the "zpci_fid" to .description. This is admittedly a lousy description, but it's still an improvement; for instance, output of -device zpci,help changes fromfid=<zpci_fid>to
fid=<uint32> -
zpci_fid* Similarly for a raft of PropertyInfo in
target/riscv/cpu.c.Signed-off-by Markus Armbruster <[email protected]>
Quoted 8 lines
--- hw/core/qdev-properties-system.c | 4 +-- hw/misc/xlnx-versal-trng.c | 2 +- hw/s390x/ccw-device.c | 2 +- hw/s390x/s390-pci-bus.c | 3 ++- hw/vfio/pci-quirks.c | 2 +- target/riscv/cpu.c | 44 ++++++++++++++++++++++---------- 6 files changed, 37 insertions(+), 20 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 4/6] qdev: Change values of PropertyInfo member @type to be QAPI types
Quoted 9 lines · Daniel P. Berrangé
Quoted 6 lines · Markus Armbruster
PropertyInfo member @type is externally visible via QMP device-list-properties and qom-list-properies.
Its meaning is not documented at its definition.
It gets passed to as @type argument to
object_property_add()and^^^^^ "passed as the @type argument" ?
Yes.
Quoted 2 lines
Quoted 2 lines
object_class_property_add(). This argument's documentation isn't of much help, either:
[...]
Quoted 1 line
Reviewed-by Daniel P. Berrangé <[email protected]>
Thank you!
PATCH v2 5/6 qdev: Improve PropertyInfo member @description for enum properties
In reply to Markus ArmbrusterConsistently use format "DESCRIPTION (VALUE/VALUE...)".
--- hw/core/qdev-properties-system.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
hw/core/qdev-properties-system.c +11 -15
@@ -603,6 +603,7 @@ QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));const PropertyInfo qdev_prop_losttickpolicy = { .type ="LostTickPolicy" , + .description ="Policy for handling lost ticks (discard/delay/slew)" , .enum_table = &LostTickPolicy_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_losttickpolicy,
@@ -642,8 +643,7 @@ QEMU_BUILD_BUG_ON(sizeof(BlockdevOnError) != sizeof(int));const PropertyInfo qdev_prop_blockdev_on_error = { .type ="BlockdevOnError" , - .description ="Error handling policy, " -"report/ignore/enospc/stop/auto" , + .description ="Error handling policy (report/ignore/enospc/stop/auto)" , .enum_table = &BlockdevOnError_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -656,8 +656,8 @@ QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));const PropertyInfo qdev_prop_bios_chs_trans = { .type ="BiosAtaTranslation" , - .description ="Logical CHS translation algorithm, " -"auto/none/lba/large/rechs" , + .description ="Logical CHS translation algorithm " +" (auto/none/lba/large/rechs)" , .enum_table = &BiosAtaTranslation_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -668,8 +668,7 @@ const PropertyInfo qdev_prop_bios_chs_trans = {const PropertyInfo qdev_prop_fdc_drive_type = { .type ="FloppyDriveType" , - .description ="FDC drive type, " -"144/288/120/none/auto" , + .description ="Floppy drive type (144/288/120/none/auto)" , .enum_table = &FloppyDriveType_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -680,8 +679,8 @@ const PropertyInfo qdev_prop_fdc_drive_type = {const PropertyInfo qdev_prop_multifd_compression = { .type ="MultiFDCompression" , - .description ="multifd_compression values, " -"none/zlib/zstd/qpl/uadk/qatzip" , + .description ="multifd_compression values" +" (none/zlib/zstd/qpl/uadk/qatzip)" , .enum_table = &MultiFDCompression_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -694,8 +693,7 @@ QEMU_BUILD_BUG_ON(sizeof(MigMode) != sizeof(int));const PropertyInfo qdev_prop_mig_mode = { .type ="MigMode" , - .description ="mig_mode values, " -"normal,cpr-reboot" , + .description ="Migration mode (normal/cpr-reboot)" , .enum_table = &MigMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -708,8 +706,7 @@ QEMU_BUILD_BUG_ON(sizeof(GranuleMode) != sizeof(int));const PropertyInfo qdev_prop_granule_mode = { .type ="GranuleMode" , - .description ="granule_mode values, " -"4k, 8k, 16k, 64k, host" , + .description ="Granule page size (4k/8k/16k/64k/host)" , .enum_table = &GranuleMode_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -718,8 +715,7 @@ const PropertyInfo qdev_prop_granule_mode = {const PropertyInfo qdev_prop_zero_page_detection = { .type ="ZeroPageDetection" , - .description ="zero_page_detection values, " -"none,legacy,multifd" , + .description ="Zero page detection (none/legacy/multifd)" , .enum_table = &ZeroPageDetection_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
@@ -1232,7 +1228,7 @@ QEMU_BUILD_BUG_ON(sizeof(S390CpuEntitlement) != sizeof(int));const PropertyInfo qdev_prop_cpus390entitlement = { .type ="S390CpuEntitlement" , - .description ="low/medium (default)/high" , + .description ="auto/low/medium/high (default medium)" , .enum_table = &S390CpuEntitlement_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum,
Signature · 1 line
2.48.1
Re: [PATCH v2 5/6] qdev: Improve PropertyInfo member @description for enum properties
Quoted 6 lines · Markus Armbruster
Consistently use format "DESCRIPTION (VALUE/VALUE...)".
Signed-off-by Markus Armbruster <[email protected]>--- hw/core/qdev-properties-system.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v2 6/6 qdev: Improve a few more PropertyInfo @description members
In reply to Markus Armbruster--- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 1 + hw/s390x/ccw-device.c | 4 ++-- target/sparc/cpu.c | 1 + 5 files changed, 6 insertions(+), 4 deletions(-)
hw/block/xen-block.c +1 -1
@@ -662,7 +662,7 @@ invalid:*/ static const PropertyInfo xen_block_prop_vdev = { .type ="str" , - .description ="Virtual Disk specifier: d*p*/xvd*/hd*/sd*" , + .description ="Virtual Disk specifier (d*p*/xvd*/hd*/sd*)" , .get = xen_block_get_vdev, .set = xen_block_set_vdev, };
hw/core/qdev-properties-system.c +1 -1
@@ -985,7 +985,7 @@ inval:const PropertyInfo qdev_prop_pci_host_devaddr = { .type ="str" , - .description ="Address (bus/device/function) of " + .description ="Address (bus:device.function) of " "the host device, example: 04:10.0" , .get = get_pci_host_devaddr, .set = set_pci_host_devaddr,
hw/core/qdev-properties.c +1 -0
@@ -247,6 +247,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,const PropertyInfo qdev_prop_bool = { .type ="bool" , + .description ="on/off" , .get = get_bool, .set = set_bool, .set_default_value = set_default_value_bool,
hw/s390x/ccw-device.c +2 -2
@@ -75,8 +75,8 @@ static void ccw_device_set_loadparm(Object *obj, Visitor *v,const PropertyInfo ccw_loadparm = { .type ="str" , - .description ="Up to 8 chars in set of [A-Za-z0-9. ] to pass" -" to the guest loader/kernel" , + .description ="Up to 8 chars in set of [A-Za-z0-9. ] to select" +" a guest kernel" , .get = ccw_device_get_loadparm, .set = ccw_device_set_loadparm, };
target/sparc/cpu.c +1 -0
@@ -939,6 +939,7 @@ static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name,static const PropertyInfo qdev_prop_nwindows = { .type ="int" , + .description ="Number of register windows" , .get = sparc_get_nwindows, .set = sparc_set_nwindows, };
Signature · 1 line
2.48.1
Re: [PATCH v2 6/6] qdev: Improve a few more PropertyInfo @description members
Quoted 8 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 1 + hw/s390x/ccw-device.c | 4 ++-- target/sparc/cpu.c | 1 + 5 files changed, 6 insertions(+), 4 deletions(-)
hw/core/qdev-properties.c static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, · line 250
Quoted 9 lines
hw/core/qdev-properties.c +1
-0@@ -247,6 +247,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,const PropertyInfo qdev_prop_bool = { .type ="bool" , + .description ="on/off" ,
Awkward as on/off for QemuOpts, but JSON true/false for QMP, but I guess clarifying this is beyond the scope of the .description field.
hw/core/qdev-properties.c static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, · line 253
Quoted 3 lines
hw/core/qdev-properties.c +0
-0.get = get_bool, .set = set_bool, .set_default_value = set_default_value_bool,
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v2 6/6] qdev: Improve a few more PropertyInfo @description members
Quoted 19 lines · Daniel P. Berrangé
Quoted 8 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 2 +- hw/core/qdev-properties.c | 1 + hw/s390x/ccw-device.c | 4 ++-- target/sparc/cpu.c | 1 + 5 files changed, 6 insertions(+), 4 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>Quoted 6 lines
hw/core/qdev-properties.c +0
-0@@ -247,6 +247,7 @@ static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque,
Quoted 6 lines
hw/core/qdev-properties.c static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, · line 250
Quoted 3 lines
hw/core/qdev-properties.c +1
-0const PropertyInfo qdev_prop_bool = { .type ="bool" , + .description ="on/off" ,Awkward as on/off for QemuOpts, but JSON true/false for QMP, but I guess clarifying this is beyond the scope of the .description field.
In my view, description applies to human-friendly dotted-keys syntax, not to JSON. Trying to make it work for both would result in verbose and confusing descriptions.
Thanks!