* [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
@ 2017-06-07 16:35 Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 01/43] qdev: remove PropertyInfo.qtype field Marc-André Lureau
` (45 more replies)
0 siblings, 46 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Hi,
In previously sent series "[PATCH 00/21] WIP: dump: add kaslr support
(for after 2.9)", I proposed changes to accept uint64 values from
json, by adding a QUint type. During review, it was suggested to
introduce a QNum type to hold various number representations.
This series introduces the QNum type, adds uint representation to it,
and make uint64 values over json possible (while keeping json negative
int for values >INT64_MAX to unsigned cast compatibility). It also
improves some int vs uint usage for object properties and other
QObject related clean-ups.
v3:
- rebased, drop the first keyval-related patches now upstream
- update "tests: Remove test cases for alternates of 'number' and 'int'"
commit message, and drop now useless conflict checks
- added "qapi: minor refactoring"
- add missing Author/Copyright lines lost during merge
- add qnum_get_try_(u)int() and simplify related code
- fix some code comments
- replace g_assert_not_reached() with assert(0) in qapi/
- replace qapi/qmp/types.h include with the min required headers
- add comment about changes in json serialization in "qapi: update the
qobject visitor to use QNUM_U64"
- update comment in "object: use more specific property type names"
with the externally visible changes
- split "qdev: make default property int" patch, rename macros
DEFINE_PROP_SIGNED/DEFINE_PROP_UNSIGNED
- in tests, compare with expected float value
- add r-b and suggested tags
v2:
- add set_default_value() callback in PropertyInfo
- use Markus version of "remove alt num-int cases"
- add more int/number ranges visitor checks
- replace Error usage for success bool return value in get_int/uint()
- various updated comments, patch and code reorganization
- avoid temporary regression from patch "json: learn to parse uint64
numbers", drop related patch
- split get_mmcfg_size() fix in a seperate patch
- added "apic-common: make "id" property a uint32" patch
- split the qdev uint proprety patch
- split "Use uint property getter/setter where appropriate" in various
patches
- add some qdict tests
- dropped s3/s4 bool patch
- add some r-b tags
Marc-André Lureau (43):
qdev: remove PropertyInfo.qtype field
object: fix potential leak in getters
tests: Remove test cases for alternates of 'number' and 'int'
tests: add more int/number ranges checks
qapi: minor refactoring
qapi: merge QInt and QFloat in QNum
qapi: Remove visit_start_alternate() parameter promote_int
tests: remove /{qnum,qlist,dict}/destroy test
qnum: add uint type
json: learn to parse uint64 numbers
qapi: update the qobject visitor to use QNUM_U64
object: add uint property setter/getter
q35: fix get_mmcfg_size to use uint64 visitor
object: use more specific property type names
qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
qdev: wrap default property value in an union
qdev: avoid type casts between signed and unsigned
apic-common: make "id" property a uint32
qdev: use appropriate getter/setters type
isa: use get_uint() for "io-base"
pc-dimm: use get_uint() for dimm properties
pc-dimm: make "size" property uint64
pcihp: use get_uint() for "bsel" property
aspeed: use {set,get}_uint() for "ram-size" property
bcm2835_fb: use {get,set}_uint() for "vcram-size" and "vcram-base"
platform-bus: use get_uint() for "addr" property
acpi: use get_uint() for "acpi-pcihp-io*" properties
acpi: use get_uint() for various acpi properties
acpi: use get_uint() for "pci-hole*" properties
pc: use get_uint() for "iobase" property
pc: use get_uint() for "apic-id" property
pc: use get_uint() for "hpet-intcap" property
xen: use get_uint() for "max-ram-below-4g" property
arm: use get_uint() for "mp-affinity" property
auxbus: use get_uint() for "addr" property
pvpanic: use get_uint() for "ioport" property
pnv-core: use get_uint() for "core-pir" property
numa: use get_uint() for "size" property
i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
console: use get_uint() for "head" property
tests/qdict: check more get_try_int() cases
RFC: qdict: add uint
qobject: move dump_qobject() from block/ to qobject/
include/qapi/visitor.h | 4 +-
include/qapi/visitor-impl.h | 2 +-
scripts/qapi.py | 36 +++--
scripts/qapi-visit.py | 12 +-
include/hw/isa/isa.h | 2 +-
include/hw/qdev-core.h | 7 +-
include/hw/qdev-properties.h | 50 ++++---
include/qapi/qmp/qdict.h | 10 +-
include/qapi/qmp/qfloat.h | 29 ----
include/qapi/qmp/qint.h | 28 ----
include/qapi/qmp/qlist.h | 5 +-
include/qapi/qmp/qnum.h | 53 ++++++++
include/qapi/qmp/qobject.h | 7 +
include/qapi/qmp/types.h | 3 +-
include/qapi/qobject-input-visitor.h | 6 +-
include/qapi/qobject-output-visitor.h | 8 +-
include/qom/object.h | 23 ++++
qapi/qapi-visit-core.c | 6 +-
backends/cryptodev.c | 2 +-
block/blkdebug.c | 1 -
block/nbd.c | 1 -
block/nfs.c | 1 -
block/qapi.c | 93 +------------
block/quorum.c | 1 -
block/sheepdog.c | 1 -
block/ssh.c | 1 -
block/vvfat.c | 1 -
blockdev.c | 8 +-
hw/acpi/memory_hotplug.c | 12 +-
hw/acpi/nvdimm.c | 18 +--
hw/acpi/pcihp.c | 7 +-
hw/arm/aspeed.c | 8 +-
hw/arm/bcm2835_peripherals.c | 9 +-
hw/arm/raspi.c | 4 +-
hw/block/fdc.c | 18 +--
hw/core/platform-bus.c | 2 +-
hw/core/qdev-properties.c | 40 +++++-
hw/core/qdev.c | 13 +-
hw/i386/acpi-build.c | 71 +++++-----
hw/i386/pc.c | 6 +-
hw/i386/xen/xen-hvm.c | 6 +-
hw/intc/apic_common.c | 10 +-
hw/intc/arm_gicv3_common.c | 2 +-
hw/mem/pc-dimm.c | 23 ++--
hw/misc/auxbus.c | 2 +-
hw/misc/pvpanic.c | 2 +-
hw/net/e1000e.c | 6 +-
hw/pci-host/gpex.c | 2 +-
hw/pci-host/piix.c | 8 +-
hw/pci-host/q35.c | 15 +--
hw/pci-host/xilinx-pcie.c | 2 +-
hw/ppc/pnv.c | 2 +-
hw/ppc/pnv_core.c | 2 +-
hw/ppc/spapr.c | 7 +-
hw/usb/xen-usb.c | 1 -
monitor.c | 2 +-
net/dump.c | 2 +-
net/filter-buffer.c | 2 +-
numa.c | 6 +-
qapi/qapi-clone-visitor.c | 2 +-
qapi/qapi-dealloc-visitor.c | 2 +-
qapi/qobject-input-visitor.c | 58 ++++----
qapi/qobject-output-visitor.c | 7 +-
qga/commands.c | 2 +-
qga/main.c | 1 -
qobject/json-lexer.c | 4 +
qobject/json-parser.c | 56 +++++---
qobject/qdict.c | 100 +++++++++++---
qobject/qfloat.c | 62 ---------
qobject/qint.c | 61 ---------
qobject/qjson.c | 37 +-----
qobject/qlist.c | 23 ++++
qobject/qnum.c | 221 +++++++++++++++++++++++++++++++
qobject/qobject.c | 22 ++-
qom/object.c | 51 +++++--
target/i386/cpu.c | 10 +-
tests/check-qdict.c | 80 ++++++++---
tests/check-qfloat.c | 53 --------
tests/check-qint.c | 87 ------------
tests/check-qjson.c | 154 +++++++++++++++------
tests/check-qlist.c | 40 ++----
tests/check-qnum.c | 170 ++++++++++++++++++++++++
tests/check-qstring.c | 9 --
tests/test-keyval.c | 4 +-
tests/test-qmp-commands.c | 8 +-
tests/test-qmp-event.c | 9 +-
tests/test-qobject-input-visitor.c | 110 ++++++++-------
tests/test-qobject-output-visitor.c | 91 ++++++++-----
tests/test-x86-cpuid-compat.c | 18 ++-
ui/console.c | 4 +-
ui/spice-core.c | 1 -
ui/vnc-enc-tight.c | 1 -
util/qemu-option.c | 24 ++--
MAINTAINERS | 3 +-
qapi/trace-events | 2 +-
qobject/Makefile.objs | 2 +-
scripts/coccinelle/qobject.cocci | 4 +-
tests/.gitignore | 3 +-
tests/Makefile.include | 13 +-
tests/qapi-schema/comments.out | 2 +-
tests/qapi-schema/doc-good.out | 2 +-
tests/qapi-schema/empty.out | 2 +-
tests/qapi-schema/event-case.out | 2 +-
tests/qapi-schema/ident-with-escape.out | 2 +-
tests/qapi-schema/include-relpath.out | 2 +-
tests/qapi-schema/include-repetition.out | 2 +-
tests/qapi-schema/include-simple.out | 2 +-
tests/qapi-schema/indented-expr.out | 2 +-
tests/qapi-schema/qapi-schema-test.json | 2 -
tests/qapi-schema/qapi-schema-test.out | 10 +-
110 files changed, 1331 insertions(+), 1019 deletions(-)
delete mode 100644 include/qapi/qmp/qfloat.h
delete mode 100644 include/qapi/qmp/qint.h
create mode 100644 include/qapi/qmp/qnum.h
delete mode 100644 qobject/qfloat.c
delete mode 100644 qobject/qint.c
create mode 100644 qobject/qnum.c
delete mode 100644 tests/check-qfloat.c
delete mode 100644 tests/check-qint.c
create mode 100644 tests/check-qnum.c
--
2.13.0.91.g00982b8dd
^ permalink raw reply [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 01/43] qdev: remove PropertyInfo.qtype field
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 02/43] object: fix potential leak in getters Marc-André Lureau
` (44 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
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>
---
include/hw/qdev-core.h | 2 +-
include/hw/qdev-properties.h | 5 -----
hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++++++++++++-
hw/core/qdev.c | 13 ++-----------
4 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index e69489ec6c..9523339762 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -226,7 +226,6 @@ struct Property {
PropertyInfo *info;
ptrdiff_t offset;
uint8_t bitnr;
- QType qtype;
int64_t defval;
int arrayoffset;
PropertyInfo *arrayinfo;
@@ -238,6 +237,7 @@ struct PropertyInfo {
const char *description;
const char * const *enum_table;
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
+ void (*set_default_value)(Object *obj, const Property *prop);
ObjectPropertyAccessor *get;
ObjectPropertyAccessor *set;
ObjectPropertyRelease *release;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index d206fc93dd..85e68998a9 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -42,7 +42,6 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(_prop), \
.offset = offsetof(_state, _field) \
+ type_check(_type,typeof_field(_state, _field)), \
- .qtype = QTYPE_QINT, \
.defval = (_type)_defval, \
}
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
@@ -51,7 +50,6 @@ extern PropertyInfo qdev_prop_arraylen;
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint32_t,typeof_field(_state, _field)), \
- .qtype = QTYPE_QBOOL, \
.defval = (bool)_defval, \
}
#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
@@ -60,7 +58,6 @@ extern PropertyInfo qdev_prop_arraylen;
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint64_t, typeof_field(_state, _field)), \
- .qtype = QTYPE_QBOOL, \
.defval = (bool)_defval, \
}
@@ -69,7 +66,6 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(qdev_prop_bool), \
.offset = offsetof(_state, _field) \
+ type_check(bool, typeof_field(_state, _field)), \
- .qtype = QTYPE_QBOOL, \
.defval = (bool)_defval, \
}
@@ -105,7 +101,6 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(qdev_prop_arraylen), \
.offset = offsetof(_state, _field) \
+ type_check(uint32_t, typeof_field(_state, _field)), \
- .qtype = QTYPE_QINT, \
.arrayinfo = &(_arrayprop), \
.arrayfieldsize = sizeof(_arraytype), \
.arrayoffset = offsetof(_state, _arrayfield), \
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,
};
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 0ce45a2019..849952a8d4 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);
}
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 02/43] object: fix potential leak in getters
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 01/43] qdev: remove PropertyInfo.qtype field Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 03/43] tests: Remove test cases for alternates of 'number' and 'int' Marc-André Lureau
` (43 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
If the property is not of the requested type, the getters will leak a
QObject.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
qom/object.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index eb4bc924ff..c7b8079df6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1122,7 +1122,7 @@ char *object_property_get_str(Object *obj, const char *name,
retval = g_strdup(qstring_get_str(qstring));
}
- QDECREF(qstring);
+ qobject_decref(ret);
return retval;
}
@@ -1183,7 +1183,7 @@ bool object_property_get_bool(Object *obj, const char *name,
retval = qbool_get_bool(qbool);
}
- QDECREF(qbool);
+ qobject_decref(ret);
return retval;
}
@@ -1214,7 +1214,7 @@ int64_t object_property_get_int(Object *obj, const char *name,
retval = qint_get_int(qint);
}
- QDECREF(qint);
+ qobject_decref(ret);
return retval;
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 03/43] tests: Remove test cases for alternates of 'number' and 'int'
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 01/43] qdev: remove PropertyInfo.qtype field Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 02/43] object: fix potential leak in getters Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks Marc-André Lureau
` (42 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Alternates with both a 'number' and an 'int' branch will become
invalid when the next patch merges of QFloat and QInt into QNum.
More sophisticated alternate code could keep them valid, but since
we have no users outside tests, simply drop the tests.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
tests/test-keyval.c | 4 ++--
tests/test-qobject-input-visitor.c | 26 --------------------------
tests/qapi-schema/qapi-schema-test.json | 2 --
tests/qapi-schema/qapi-schema-test.out | 8 --------
4 files changed, 2 insertions(+), 38 deletions(-)
diff --git a/tests/test-keyval.c b/tests/test-keyval.c
index c3be00524c..baf7e339ab 100644
--- a/tests/test-keyval.c
+++ b/tests/test-keyval.c
@@ -615,7 +615,7 @@ static void test_keyval_visit_alternate(void)
Visitor *v;
QDict *qdict;
AltStrObj *aso;
- AltNumInt *ani;
+ AltNumEnum *ane;
AltEnumBool *aeb;
/*
@@ -631,7 +631,7 @@ static void test_keyval_visit_alternate(void)
g_assert_cmpint(aso->type, ==, QTYPE_QSTRING);
g_assert_cmpstr(aso->u.s, ==, "1");
qapi_free_AltStrObj(aso);
- visit_type_AltNumInt(v, "b", &ani, &err);
+ visit_type_AltNumEnum(v, "b", &ane, &err);
error_free_or_abort(&err);
visit_type_AltEnumBool(v, "c", &aeb, &err);
error_free_or_abort(&err);
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 6b997a177d..83d663d11d 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -592,8 +592,6 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
AltEnumNum *aen;
AltNumEnum *ans;
AltEnumInt *asi;
- AltIntNum *ain;
- AltNumInt *ani;
/* Parsing an int */
@@ -620,18 +618,6 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
g_assert_cmpint(asi->u.i, ==, 42);
qapi_free_AltEnumInt(asi);
- v = visitor_input_test_init(data, "42");
- visit_type_AltIntNum(v, NULL, &ain, &error_abort);
- g_assert_cmpint(ain->type, ==, QTYPE_QINT);
- g_assert_cmpint(ain->u.i, ==, 42);
- qapi_free_AltIntNum(ain);
-
- v = visitor_input_test_init(data, "42");
- visit_type_AltNumInt(v, NULL, &ani, &error_abort);
- g_assert_cmpint(ani->type, ==, QTYPE_QINT);
- g_assert_cmpint(ani->u.i, ==, 42);
- qapi_free_AltNumInt(ani);
-
/* Parsing a double */
v = visitor_input_test_init(data, "42.5");
@@ -655,18 +641,6 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
visit_type_AltEnumInt(v, NULL, &asi, &err);
error_free_or_abort(&err);
qapi_free_AltEnumInt(asi);
-
- v = visitor_input_test_init(data, "42.5");
- visit_type_AltIntNum(v, NULL, &ain, &error_abort);
- g_assert_cmpint(ain->type, ==, QTYPE_QFLOAT);
- g_assert_cmpfloat(ain->u.n, ==, 42.5);
- qapi_free_AltIntNum(ain);
-
- v = visitor_input_test_init(data, "42.5");
- visit_type_AltNumInt(v, NULL, &ani, &error_abort);
- g_assert_cmpint(ani->type, ==, QTYPE_QFLOAT);
- g_assert_cmpfloat(ani->u.n, ==, 42.5);
- qapi_free_AltNumInt(ani);
}
static void test_native_list_integer_helper(TestInputVisitorData *data,
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 17649c6398..91ffb2648c 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -103,8 +103,6 @@
{ 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } }
{ 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } }
{ 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } }
-{ 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } }
-{ 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } }
# for testing use of 'str' within alternates
{ 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 9f68610dc2..e727a5a84c 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -10,18 +10,10 @@ alternate AltEnumNum
tag type
case e: EnumOne
case n: number
-alternate AltIntNum
- tag type
- case i: int
- case n: number
alternate AltNumEnum
tag type
case n: number
case e: EnumOne
-alternate AltNumInt
- tag type
- case n: number
- case i: int
alternate AltStrObj
tag type
case s: str
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (2 preceding siblings ...)
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 03/43] tests: Remove test cases for alternates of 'number' and 'int' Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-08 14:55 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring Marc-André Lureau
` (41 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
tests/test-qobject-input-visitor.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 83d663d11d..3a6ce2226c 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -107,6 +107,7 @@ static void test_visitor_in_int(TestInputVisitorData *data,
const void *unused)
{
int64_t res = 0;
+ double dbl;
int value = -42;
Visitor *v;
@@ -114,6 +115,9 @@ static void test_visitor_in_int(TestInputVisitorData *data,
visit_type_int(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, value);
+
+ visit_type_number(v, NULL, &dbl, &error_abort);
+ g_assert_cmpfloat(dbl, ==, -42.0);
}
static void test_visitor_in_uint(TestInputVisitorData *data,
@@ -121,6 +125,8 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
{
Error *err = NULL;
uint64_t res = 0;
+ int64_t i64;
+ double dbl;
int value = 42;
Visitor *v;
@@ -129,8 +135,13 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
visit_type_uint64(v, NULL, &res, &error_abort);
g_assert_cmpuint(res, ==, (uint64_t)value);
- /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */
+ visit_type_int(v, NULL, &i64, &error_abort);
+ g_assert_cmpint(i64, ==, value);
+
+ visit_type_number(v, NULL, &dbl, &error_abort);
+ g_assert_cmpfloat(dbl, ==, value);
+ /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */
v = visitor_input_test_init(data, "%d", -value);
visit_type_uint64(v, NULL, &res, &error_abort);
@@ -142,6 +153,8 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
visit_type_uint64(v, NULL, &res, &err);
error_free_or_abort(&err);
+
+ visit_type_number(v, NULL, &dbl, &error_abort);
}
static void test_visitor_in_int_overflow(TestInputVisitorData *data,
@@ -260,6 +273,27 @@ static void test_visitor_in_number(TestInputVisitorData *data,
g_assert_cmpfloat(res, ==, value);
}
+static void test_visitor_in_large_number(TestInputVisitorData *data,
+ const void *unused)
+{
+ Error *err = NULL;
+ double res = 0;
+ int64_t i64;
+ uint64_t u64;
+ Visitor *v;
+
+ v = visitor_input_test_init(data, "-18446744073709551616"); /* -2^64 */
+
+ visit_type_number(v, NULL, &res, &error_abort);
+ g_assert_cmpfloat(res, ==, -18446744073709552e3);
+
+ visit_type_int(v, NULL, &i64, &err);
+ error_free_or_abort(&err);
+
+ visit_type_uint64(v, NULL, &u64, &err);
+ error_free_or_abort(&err);
+}
+
static void test_visitor_in_number_keyval(TestInputVisitorData *data,
const void *unused)
{
@@ -1253,6 +1287,8 @@ int main(int argc, char **argv)
NULL, test_visitor_in_bool_str_fail);
input_visitor_test_add("/visitor/input/number",
NULL, test_visitor_in_number);
+ input_visitor_test_add("/visitor/input/large_number",
+ NULL, test_visitor_in_large_number);
input_visitor_test_add("/visitor/input/number_keyval",
NULL, test_visitor_in_number_keyval);
input_visitor_test_add("/visitor/input/number_str_keyval",
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (3 preceding siblings ...)
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-08 14:57 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum Marc-André Lureau
` (40 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Use the more common pattern to error out.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
qapi/qobject-input-visitor.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index eac40f618a..26ef49a60b 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -547,13 +547,13 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
}
qfloat = qobject_to_qfloat(qobj);
- if (qfloat) {
- *obj = qfloat_get_double(qobject_to_qfloat(qobj));
+ if (!qfloat) {
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+ full_name(qiv, name), "number");
return;
}
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
- full_name(qiv, name), "number");
+ *obj = qfloat_get_double(qobject_to_qfloat(qobj));
}
static void qobject_input_type_number_keyval(Visitor *v, const char *name,
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (4 preceding siblings ...)
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-08 15:54 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 07/43] qapi: Remove visit_start_alternate() parameter promote_int Marc-André Lureau
` (39 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
We would like to use a same QObject type to represent numbers, whether
they are int, uint, or floats. Getters will allow some compatibility
between the various types if the number fits other representations.
Add a few more tests while at it.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
scripts/qapi.py | 36 ++++---
scripts/qapi-visit.py | 2 +-
include/qapi/qmp/qdict.h | 3 +-
include/qapi/qmp/qfloat.h | 29 ------
include/qapi/qmp/qint.h | 28 ------
include/qapi/qmp/qlist.h | 3 +-
include/qapi/qmp/qnum.h | 46 +++++++++
include/qapi/qmp/types.h | 3 +-
include/qapi/qobject-input-visitor.h | 6 +-
include/qapi/qobject-output-visitor.h | 8 +-
block/blkdebug.c | 1 -
block/nbd.c | 1 -
block/nfs.c | 1 -
block/qapi.c | 13 +--
block/quorum.c | 1 -
block/sheepdog.c | 1 -
block/ssh.c | 1 -
block/vvfat.c | 1 -
blockdev.c | 8 +-
hw/acpi/pcihp.c | 1 -
hw/i386/acpi-build.c | 16 ++--
hw/usb/xen-usb.c | 1 -
monitor.c | 2 +-
qapi/qobject-input-visitor.c | 41 +++-----
qapi/qobject-output-visitor.c | 6 +-
qga/commands.c | 2 +-
qga/main.c | 1 -
qobject/json-parser.c | 30 +++---
qobject/qdict.c | 37 +++-----
qobject/qfloat.c | 62 ------------
qobject/qint.c | 61 ------------
qobject/qjson.c | 37 +-------
qobject/qnum.c | 157 +++++++++++++++++++++++++++++++
qobject/qobject.c | 3 +-
qom/object.c | 16 ++--
target/i386/cpu.c | 6 +-
tests/check-qdict.c | 25 +++--
tests/check-qfloat.c | 53 -----------
tests/check-qint.c | 87 -----------------
tests/check-qjson.c | 91 +++++++++---------
tests/check-qlist.c | 17 ++--
tests/check-qnum.c | 136 ++++++++++++++++++++++++++
tests/test-qmp-commands.c | 8 +-
tests/test-qmp-event.c | 9 +-
tests/test-qobject-input-visitor.c | 37 ++++----
tests/test-qobject-output-visitor.c | 71 ++++++++------
tests/test-x86-cpuid-compat.c | 18 ++--
ui/spice-core.c | 1 -
ui/vnc-enc-tight.c | 1 -
util/qemu-option.c | 24 ++---
MAINTAINERS | 3 +-
qobject/Makefile.objs | 2 +-
scripts/coccinelle/qobject.cocci | 4 +-
tests/.gitignore | 3 +-
tests/Makefile.include | 13 +--
tests/qapi-schema/comments.out | 2 +-
tests/qapi-schema/doc-good.out | 2 +-
tests/qapi-schema/empty.out | 2 +-
tests/qapi-schema/event-case.out | 2 +-
tests/qapi-schema/ident-with-escape.out | 2 +-
tests/qapi-schema/include-relpath.out | 2 +-
tests/qapi-schema/include-repetition.out | 2 +-
tests/qapi-schema/include-simple.out | 2 +-
tests/qapi-schema/indented-expr.out | 2 +-
tests/qapi-schema/qapi-schema-test.out | 2 +-
65 files changed, 629 insertions(+), 665 deletions(-)
delete mode 100644 include/qapi/qmp/qfloat.h
delete mode 100644 include/qapi/qmp/qint.h
create mode 100644 include/qapi/qmp/qnum.h
delete mode 100644 qobject/qfloat.c
delete mode 100644 qobject/qint.c
create mode 100644 qobject/qnum.c
delete mode 100644 tests/check-qfloat.c
delete mode 100644 tests/check-qint.c
create mode 100644 tests/check-qnum.c
diff --git a/scripts/qapi.py b/scripts/qapi.py
index b7a25e4759..0de809f56b 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -21,18 +21,18 @@ from ordereddict import OrderedDict
builtin_types = {
'str': 'QTYPE_QSTRING',
- 'int': 'QTYPE_QINT',
- 'number': 'QTYPE_QFLOAT',
+ 'int': 'QTYPE_QNUM',
+ 'number': 'QTYPE_QNUM',
'bool': 'QTYPE_QBOOL',
- 'int8': 'QTYPE_QINT',
- 'int16': 'QTYPE_QINT',
- 'int32': 'QTYPE_QINT',
- 'int64': 'QTYPE_QINT',
- 'uint8': 'QTYPE_QINT',
- 'uint16': 'QTYPE_QINT',
- 'uint32': 'QTYPE_QINT',
- 'uint64': 'QTYPE_QINT',
- 'size': 'QTYPE_QINT',
+ 'int8': 'QTYPE_QNUM',
+ 'int16': 'QTYPE_QNUM',
+ 'int32': 'QTYPE_QNUM',
+ 'int64': 'QTYPE_QNUM',
+ 'uint8': 'QTYPE_QNUM',
+ 'uint16': 'QTYPE_QNUM',
+ 'uint32': 'QTYPE_QNUM',
+ 'uint64': 'QTYPE_QNUM',
+ 'size': 'QTYPE_QNUM',
'any': None, # any QType possible, actually
'QType': 'QTYPE_QSTRING',
}
@@ -820,11 +820,9 @@ def check_alternate(expr, info):
if v in ['on', 'off']:
conflicting.add('QTYPE_QBOOL')
if re.match(r'[-+0-9.]', v): # lazy, could be tightened
- conflicting.add('QTYPE_QINT')
- conflicting.add('QTYPE_QFLOAT')
+ conflicting.add('QTYPE_QNUM')
else:
- conflicting.add('QTYPE_QINT')
- conflicting.add('QTYPE_QFLOAT')
+ conflicting.add('QTYPE_QNUM')
conflicting.add('QTYPE_QBOOL')
if conflicting & set(types_seen):
raise QAPISemError(info, "Alternate '%s' member '%s' can't "
@@ -1059,8 +1057,8 @@ class QAPISchemaType(QAPISchemaEntity):
def alternate_qtype(self):
json2qtype = {
'string': 'QTYPE_QSTRING',
- 'number': 'QTYPE_QFLOAT',
- 'int': 'QTYPE_QINT',
+ 'number': 'QTYPE_QNUM',
+ 'int': 'QTYPE_QNUM',
'boolean': 'QTYPE_QBOOL',
'object': 'QTYPE_QDICT'
}
@@ -1522,9 +1520,9 @@ class QAPISchema(object):
self.the_empty_object_type = QAPISchemaObjectType(
'q_empty', None, None, None, [], None)
self._def_entity(self.the_empty_object_type)
- qtype_values = self._make_enum_members(['none', 'qnull', 'qint',
+ qtype_values = self._make_enum_members(['none', 'qnull', 'qnum',
'qstring', 'qdict', 'qlist',
- 'qfloat', 'qbool'])
+ 'qbool'])
self._def_entity(QAPISchemaEnumType('QType', None, None,
qtype_values, 'QTYPE'))
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 5737aefa05..cc447ecacc 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -164,7 +164,7 @@ def gen_visit_alternate(name, variants):
promote_int = 'true'
ret = ''
for var in variants.variants:
- if var.type.alternate_qtype() == 'QTYPE_QINT':
+ if var.type.alternate_qtype() == 'QTYPE_QNUM':
promote_int = 'false'
ret += mcgen('''
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 188440a6a8..363e431106 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -15,6 +15,7 @@
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qnum.h"
#include "qemu/queue.h"
#define QDICT_BUCKET_MAX 512
@@ -54,7 +55,7 @@ void qdict_destroy_obj(QObject *obj);
/* Helpers for int, bool, and string */
#define qdict_put_int(qdict, key, value) \
- qdict_put(qdict, key, qint_from_int(value))
+ qdict_put(qdict, key, qnum_from_int(value))
#define qdict_put_bool(qdict, key, value) \
qdict_put(qdict, key, qbool_from_bool(value))
#define qdict_put_str(qdict, key, value) \
diff --git a/include/qapi/qmp/qfloat.h b/include/qapi/qmp/qfloat.h
deleted file mode 100644
index b5d15836b5..0000000000
--- a/include/qapi/qmp/qfloat.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * QFloat Module
- *
- * Copyright IBM, Corp. 2009
- *
- * Authors:
- * Anthony Liguori <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-
-#ifndef QFLOAT_H
-#define QFLOAT_H
-
-#include "qapi/qmp/qobject.h"
-
-typedef struct QFloat {
- QObject base;
- double value;
-} QFloat;
-
-QFloat *qfloat_from_double(double value);
-double qfloat_get_double(const QFloat *qi);
-QFloat *qobject_to_qfloat(const QObject *obj);
-void qfloat_destroy_obj(QObject *obj);
-
-#endif /* QFLOAT_H */
diff --git a/include/qapi/qmp/qint.h b/include/qapi/qmp/qint.h
deleted file mode 100644
index 3aaff768dd..0000000000
--- a/include/qapi/qmp/qint.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * QInt Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- * Luiz Capitulino <lcapitulino@redhat.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-
-#ifndef QINT_H
-#define QINT_H
-
-#include "qapi/qmp/qobject.h"
-
-typedef struct QInt {
- QObject base;
- int64_t value;
-} QInt;
-
-QInt *qint_from_int(int64_t value);
-int64_t qint_get_int(const QInt *qi);
-QInt *qobject_to_qint(const QObject *obj);
-void qint_destroy_obj(QObject *obj);
-
-#endif /* QINT_H */
diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
index 5dc4ed9616..c4b5fdad9b 100644
--- a/include/qapi/qmp/qlist.h
+++ b/include/qapi/qmp/qlist.h
@@ -14,6 +14,7 @@
#define QLIST_H
#include "qapi/qmp/qobject.h"
+#include "qapi/qmp/qnum.h"
#include "qemu/queue.h"
typedef struct QListEntry {
@@ -31,7 +32,7 @@ typedef struct QList {
/* Helpers for int, bool, and string */
#define qlist_append_int(qlist, value) \
- qlist_append(qlist, qint_from_int(value))
+ qlist_append(qlist, qnum_from_int(value))
#define qlist_append_bool(qlist, value) \
qlist_append(qlist, qbool_from_bool(value))
#define qlist_append_str(qlist, value) \
diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h
new file mode 100644
index 0000000000..e42b136141
--- /dev/null
+++ b/include/qapi/qmp/qnum.h
@@ -0,0 +1,46 @@
+/*
+ * QNum Module
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ * Luiz Capitulino <lcapitulino@redhat.com>
+ * Anthony Liguori <aliguori@us.ibm.com>
+ * Marc-André Lureau <marcandre.lureau@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ */
+
+#ifndef QNUM_H
+#define QNUM_H
+
+#include "qapi/qmp/qobject.h"
+
+typedef enum {
+ QNUM_I64,
+ QNUM_DOUBLE
+} QNumKind;
+
+typedef struct QNum {
+ QObject base;
+ QNumKind kind;
+ union {
+ int64_t i64;
+ double dbl;
+ } u;
+} QNum;
+
+QNum *qnum_from_int(int64_t value);
+QNum *qnum_from_double(double value);
+
+bool qnum_get_try_int(const QNum *qn, int64_t *val);
+int64_t qnum_get_int(const QNum *qn);
+double qnum_get_double(QNum *qn);
+
+char *qnum_to_string(QNum *qn);
+
+QNum *qobject_to_qnum(const QObject *obj);
+void qnum_destroy_obj(QObject *obj);
+
+#endif /* QNUM_H */
diff --git a/include/qapi/qmp/types.h b/include/qapi/qmp/types.h
index 27cfbd84e5..a4bc662bfb 100644
--- a/include/qapi/qmp/types.h
+++ b/include/qapi/qmp/types.h
@@ -14,8 +14,7 @@
#define QAPI_QMP_TYPES_H
#include "qapi/qmp/qobject.h"
-#include "qapi/qmp/qint.h"
-#include "qapi/qmp/qfloat.h"
+#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qdict.h"
diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h
index b399285c43..daee18c6ac 100644
--- a/include/qapi/qobject-input-visitor.h
+++ b/include/qapi/qobject-input-visitor.h
@@ -30,9 +30,9 @@ typedef struct QObjectInputVisitor QObjectInputVisitor;
* visit_type_FOO() creates an instance of QAPI type FOO. The visited
* QObject must match FOO. QDict matches struct/union types, QList
* matches list types, QString matches type 'str' and enumeration
- * types, QInt matches integer types, QFloat matches type 'number',
- * QBool matches type 'bool'. Type 'any' is matched by QObject. A
- * QAPI alternate type is matched when one of its member types is.
+ * types, QNum matches integer and float types, QBool matches type
+ * 'bool'. Type 'any' is matched by QObject. A QAPI alternate type
+ * is matched when one of its member types is.
*
* visit_start_struct() ... visit_end_struct() visits a QDict and
* creates a QAPI struct/union. Visits in between visit the
diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-output-visitor.h
index 9b990c318e..e5a3490812 100644
--- a/include/qapi/qobject-output-visitor.h
+++ b/include/qapi/qobject-output-visitor.h
@@ -28,10 +28,10 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor;
*
* visit_type_FOO() creates a QObject for QAPI type FOO. It creates a
* QDict for struct/union types, a QList for list types, QString for
- * type 'str' and enumeration types, QInt for integer types, QFloat
- * for type 'number', QBool for type 'bool'. For type 'any', it
- * increments the QObject's reference count. For QAPI alternate
- * types, it creates the QObject for the member that is in use.
+ * type 'str' and enumeration types, QNum for integer and float
+ * types, QBool for type 'bool'. For type 'any', it increments the
+ * QObject's reference count. For QAPI alternate types, it creates
+ * the QObject for the member that is in use.
*
* visit_start_struct() ... visit_end_struct() visits a QAPI
* struct/union and creates a QDict. Visits in between visit the
diff --git a/block/blkdebug.c b/block/blkdebug.c
index a5196e889d..0618fc71c6 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -31,7 +31,6 @@
#include "qemu/module.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#include "sysemu/qtest.h"
diff --git a/block/nbd.c b/block/nbd.c
index 975faab2c5..e946ea944d 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -37,7 +37,6 @@
#include "qapi/qobject-output-visitor.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qjson.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#include "qemu/cutils.h"
diff --git a/block/nfs.c b/block/nfs.c
index 848b2c0bb0..decefd15f1 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -36,7 +36,6 @@
#include "qemu/cutils.h"
#include "sysemu/sysemu.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#include "qapi-visit.h"
#include "qapi/qobject-input-visitor.h"
diff --git a/block/qapi.c b/block/qapi.c
index a40922ea26..2050df29e4 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -595,9 +595,11 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
int comp_indent, QObject *obj)
{
switch (qobject_type(obj)) {
- case QTYPE_QINT: {
- QInt *value = qobject_to_qint(obj);
- func_fprintf(f, "%" PRId64, qint_get_int(value));
+ case QTYPE_QNUM: {
+ QNum *value = qobject_to_qnum(obj);
+ char *tmp = qnum_to_string(value);
+ func_fprintf(f, "%s", tmp);
+ g_free(tmp);
break;
}
case QTYPE_QSTRING: {
@@ -615,11 +617,6 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
dump_qlist(func_fprintf, f, comp_indent, value);
break;
}
- case QTYPE_QFLOAT: {
- QFloat *value = qobject_to_qfloat(obj);
- func_fprintf(f, "%g", qfloat_get_double(value));
- break;
- }
case QTYPE_QBOOL: {
QBool *value = qobject_to_qbool(obj);
func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
diff --git a/block/quorum.c b/block/quorum.c
index 1b2a8c3937..55ba916655 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -19,7 +19,6 @@
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlist.h"
#include "qapi/qmp/qstring.h"
diff --git a/block/sheepdog.c b/block/sheepdog.c
index a18315a1ca..dea9000bdd 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -16,7 +16,6 @@
#include "qapi-visit.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qobject-input-visitor.h"
#include "qemu/uri.h"
#include "qemu/error-report.h"
diff --git a/block/ssh.c b/block/ssh.c
index 11203fc5a2..bac3453c3e 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -34,7 +34,6 @@
#include "qemu/sockets.h"
#include "qemu/uri.h"
#include "qapi-visit.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qobject-output-visitor.h"
diff --git a/block/vvfat.c b/block/vvfat.c
index 426ca70e35..8ab647c0c6 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -29,7 +29,6 @@
#include "qemu/module.h"
#include "qemu/bswap.h"
#include "migration/blocker.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
#include "qemu/cutils.h"
diff --git a/blockdev.c b/blockdev.c
index 892d768574..154c95d402 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -334,9 +334,11 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,
break;
}
- case QTYPE_QINT: {
- int64_t length = qint_get_int(qobject_to_qint(entry->value));
- if (length > 0 && length <= UINT_MAX) {
+ case QTYPE_QNUM: {
+ int64_t length;
+
+ if (qnum_get_try_int(qobject_to_qnum(entry->value), &length) &&
+ length > 0 && length <= UINT_MAX) {
block_acct_add_interval(stats, (unsigned) length);
} else {
error_setg(errp, "Invalid interval length: %" PRId64, length);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 2b0f3e1bfb..3a531a4416 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -37,7 +37,6 @@
#include "hw/pci/pci_bus.h"
#include "qapi/error.h"
#include "qom/qom-qobject.h"
-#include "qapi/qmp/qint.h"
//#define DEBUG
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index ce74c84460..d7d2b65fe4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -57,7 +57,6 @@
#include "hw/acpi/aml-build.h"
-#include "qapi/qmp/qint.h"
#include "qom/qom-qobject.h"
#include "hw/i386/amd_iommu.h"
#include "hw/i386/intel_iommu.h"
@@ -150,21 +149,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
/* Fill in optional s3/s4 related properties */
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
if (o) {
- pm->s3_disabled = qint_get_int(qobject_to_qint(o));
+ pm->s3_disabled = qnum_get_int(qobject_to_qnum(o));
} else {
pm->s3_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) {
- pm->s4_disabled = qint_get_int(qobject_to_qint(o));
+ pm->s4_disabled = qnum_get_int(qobject_to_qnum(o));
} else {
pm->s4_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) {
- pm->s4_val = qint_get_int(qobject_to_qint(o));
+ pm->s4_val = qnum_get_int(qobject_to_qnum(o));
} else {
pm->s4_val = false;
}
@@ -529,7 +528,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
if (bsel) {
- int64_t bsel_val = qint_get_int(qobject_to_qint(bsel));
+ int64_t bsel_val = qnum_get_int(qobject_to_qnum(bsel));
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
@@ -639,7 +638,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
/* If bus supports hotplug select it and notify about local events */
if (bsel) {
- int64_t bsel_val = qint_get_int(qobject_to_qint(bsel));
+ int64_t bsel_val = qnum_get_int(qobject_to_qnum(bsel));
+
aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
aml_append(method,
aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check */)
@@ -2614,12 +2614,12 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
if (!o) {
return false;
}
- mcfg->mcfg_base = qint_get_int(qobject_to_qint(o));
+ mcfg->mcfg_base = qnum_get_int(qobject_to_qnum(o));
qobject_decref(o);
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
- mcfg->mcfg_size = qint_get_int(qobject_to_qint(o));
+ mcfg->mcfg_size = qnum_get_int(qobject_to_qnum(o));
qobject_decref(o);
return true;
}
diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c
index fe62183fe3..584a6f2442 100644
--- a/hw/usb/xen-usb.c
+++ b/hw/usb/xen-usb.c
@@ -30,7 +30,6 @@
#include "hw/xen/xen_backend.h"
#include "monitor/qdev.h"
#include "qapi/qmp/qbool.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#include "hw/xen/io/ring.h"
diff --git a/monitor.c b/monitor.c
index 1e63ace2d4..901ef39c81 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2974,7 +2974,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,
monitor_printf(mon, "Unknown unit suffix\n");
goto fail;
}
- qdict_put(qdict, key, qfloat_from_double(val));
+ qdict_put(qdict, key, qnum_from_double(val));
}
break;
case 'b':
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 26ef49a60b..b24f99d698 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -378,9 +378,6 @@ static void qobject_input_start_alternate(Visitor *v, const char *name,
}
*obj = g_malloc0(size);
(*obj)->type = qobject_type(qobj);
- if (promote_int && (*obj)->type == QTYPE_QINT) {
- (*obj)->type = QTYPE_QFLOAT;
- }
}
static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
@@ -388,22 +385,18 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
- QInt *qint;
+ QNum *qnum;
if (!qobj) {
return;
}
- qint = qobject_to_qint(qobj);
- if (!qint) {
+ qnum = qobject_to_qnum(qobj);
+ if (!qnum || !qnum_get_try_int(qnum, obj)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "integer");
- return;
}
-
- *obj = qint_get_int(qint);
}
-
static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
int64_t *obj, Error **errp)
{
@@ -424,22 +417,21 @@ static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
static void qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
- /* FIXME: qobject_to_qint mishandles values over INT64_MAX */
+ /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
- QInt *qint;
+ QNum *qnum;
+ int64_t val;
if (!qobj) {
return;
}
- qint = qobject_to_qint(qobj);
- if (!qint) {
+ qnum = qobject_to_qnum(qobj);
+ if (!qnum || !qnum_get_try_int(qnum, &val)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "integer");
- return;
}
-
- *obj = qint_get_int(qint);
+ *obj = val;
}
static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,
@@ -534,26 +526,19 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
- QInt *qint;
- QFloat *qfloat;
+ QNum *qnum;
if (!qobj) {
return;
}
- qint = qobject_to_qint(qobj);
- if (qint) {
- *obj = qint_get_int(qobject_to_qint(qobj));
- return;
- }
-
- qfloat = qobject_to_qfloat(qobj);
- if (!qfloat) {
+ qnum = qobject_to_qnum(qobj);
+ if (!qnum) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "number");
return;
}
- *obj = qfloat_get_double(qobject_to_qfloat(qobj));
+ *obj = qnum_get_double(qnum);
}
static void qobject_input_type_number_keyval(Visitor *v, const char *name,
diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c
index 871127079d..2ca5093b22 100644
--- a/qapi/qobject-output-visitor.c
+++ b/qapi/qobject-output-visitor.c
@@ -144,7 +144,7 @@ static void qobject_output_type_int64(Visitor *v, const char *name,
int64_t *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
- qobject_output_add(qov, name, qint_from_int(*obj));
+ qobject_output_add(qov, name, qnum_from_int(*obj));
}
static void qobject_output_type_uint64(Visitor *v, const char *name,
@@ -152,7 +152,7 @@ static void qobject_output_type_uint64(Visitor *v, const char *name,
{
/* FIXME values larger than INT64_MAX become negative */
QObjectOutputVisitor *qov = to_qov(v);
- qobject_output_add(qov, name, qint_from_int(*obj));
+ qobject_output_add(qov, name, qnum_from_int(*obj));
}
static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
@@ -177,7 +177,7 @@ static void qobject_output_type_number(Visitor *v, const char *name,
double *obj, Error **errp)
{
QObjectOutputVisitor *qov = to_qov(v);
- qobject_output_add(qov, name, qfloat_from_double(*obj));
+ qobject_output_add(qov, name, qnum_from_double(*obj));
}
static void qobject_output_type_any(Visitor *v, const char *name,
diff --git a/qga/commands.c b/qga/commands.c
index 3333ed50b2..ff89e805cf 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -485,7 +485,7 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
{
/* Exploit the fact that we picked values to match QGA_SEEK_*. */
if (whence->type == QTYPE_QSTRING) {
- whence->type = QTYPE_QINT;
+ whence->type = QTYPE_QNUM;
whence->u.value = whence->u.name;
}
switch (whence->u.value) {
diff --git a/qga/main.c b/qga/main.c
index cc58d2b53d..405c1290f8 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -19,7 +19,6 @@
#endif
#include "qapi/qmp/json-streamer.h"
#include "qapi/qmp/json-parser.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qjson.h"
#include "qga/guest-agent-core.h"
#include "qemu/module.h"
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index c18e48ab94..5e808289f5 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -466,16 +466,16 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
} else if (!strcmp(token->str, "%i")) {
return QOBJECT(qbool_from_bool(va_arg(*ap, int)));
} else if (!strcmp(token->str, "%d")) {
- return QOBJECT(qint_from_int(va_arg(*ap, int)));
+ return QOBJECT(qnum_from_int(va_arg(*ap, int)));
} else if (!strcmp(token->str, "%ld")) {
- return QOBJECT(qint_from_int(va_arg(*ap, long)));
+ return QOBJECT(qnum_from_int(va_arg(*ap, long)));
} else if (!strcmp(token->str, "%lld") ||
!strcmp(token->str, "%I64d")) {
- return QOBJECT(qint_from_int(va_arg(*ap, long long)));
+ return QOBJECT(qnum_from_int(va_arg(*ap, long long)));
} else if (!strcmp(token->str, "%s")) {
return QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
} else if (!strcmp(token->str, "%f")) {
- return QOBJECT(qfloat_from_double(va_arg(*ap, double)));
+ return QOBJECT(qnum_from_double(va_arg(*ap, double)));
}
return NULL;
}
@@ -491,24 +491,22 @@ static QObject *parse_literal(JSONParserContext *ctxt)
case JSON_STRING:
return QOBJECT(qstring_from_escaped_str(ctxt, token));
case JSON_INTEGER: {
- /* A possibility exists that this is a whole-valued float where the
- * fractional part was left out due to being 0 (.0). It's not a big
- * deal to treat these as ints in the parser, so long as users of the
- * resulting QObject know to expect a QInt in place of a QFloat in
- * cases like these.
+ /*
+ * Represent JSON_INTEGER as QNUM_I64 if possible, else as
+ * QNUM_DOUBLE. Note that strtoll() fails with ERANGE when
+ * it's not possible.
*
- * However, in some cases these values will overflow/underflow a
- * QInt/int64 container, thus we should assume these are to be handled
- * as QFloats/doubles rather than silently changing their values.
- *
- * strtoll() indicates these instances by setting errno to ERANGE
+ * qnum_get_int() will then work for any signed 64-bit
+ * JSON_INTEGER, and qnum_get_double() both for any
+ * JSON_INTEGER and any JSON_FLOAT (with precision loss for
+ * integers beyond 53 bits)
*/
int64_t value;
errno = 0; /* strtoll doesn't set errno on success */
value = strtoll(token->str, NULL, 10);
if (errno != ERANGE) {
- return QOBJECT(qint_from_int(value));
+ return QOBJECT(qnum_from_int(value));
}
/* fall through to JSON_FLOAT */
}
@@ -516,7 +514,7 @@ static QObject *parse_literal(JSONParserContext *ctxt)
/* FIXME dependent on locale; a pervasive issue in QEMU */
/* FIXME our lexer matches RFC 7159 in forbidding Inf or NaN,
* but those might be useful extensions beyond JSON */
- return QOBJECT(qfloat_from_double(strtod(token->str, NULL)));
+ return QOBJECT(qnum_from_double(strtod(token->str, NULL)));
default:
abort();
}
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 88e2ecd658..576018e531 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -11,8 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "qapi/qmp/qint.h"
-#include "qapi/qmp/qfloat.h"
+#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
@@ -180,37 +179,26 @@ size_t qdict_size(const QDict *qdict)
/**
* qdict_get_double(): Get an number mapped by 'key'
*
- * This function assumes that 'key' exists and it stores a
- * QFloat or QInt object.
+ * This function assumes that 'key' exists and it stores a QNum.
*
* Return number mapped by 'key'.
*/
double qdict_get_double(const QDict *qdict, const char *key)
{
- QObject *obj = qdict_get(qdict, key);
-
- assert(obj);
- switch (qobject_type(obj)) {
- case QTYPE_QFLOAT:
- return qfloat_get_double(qobject_to_qfloat(obj));
- case QTYPE_QINT:
- return qint_get_int(qobject_to_qint(obj));
- default:
- abort();
- }
+ return qnum_get_double(qobject_to_qnum(qdict_get(qdict, key)));
}
/**
* qdict_get_int(): Get an integer mapped by 'key'
*
* This function assumes that 'key' exists and it stores a
- * QInt object.
+ * QNum representable as int.
*
* Return integer mapped by 'key'.
*/
int64_t qdict_get_int(const QDict *qdict, const char *key)
{
- return qint_get_int(qobject_to_qint(qdict_get(qdict, key)));
+ return qnum_get_int(qobject_to_qnum(qdict_get(qdict, key)));
}
/**
@@ -259,16 +247,21 @@ const char *qdict_get_str(const QDict *qdict, const char *key)
/**
* qdict_get_try_int(): Try to get integer mapped by 'key'
*
- * Return integer mapped by 'key', if it is not present in
- * the dictionary or if the stored object is not of QInt type
- * 'def_value' will be returned.
+ * Return integer mapped by 'key', if it is not present in the
+ * dictionary or if the stored object is not a QNum representing an
+ * integer, 'def_value' will be returned.
*/
int64_t qdict_get_try_int(const QDict *qdict, const char *key,
int64_t def_value)
{
- QInt *qint = qobject_to_qint(qdict_get(qdict, key));
+ QNum *qnum = qobject_to_qnum(qdict_get(qdict, key));
+ int64_t val;
+
+ if (!qnum || !qnum_get_try_int(qnum, &val)) {
+ return def_value;
+ }
- return qint ? qint_get_int(qint) : def_value;
+ return val;
}
/**
diff --git a/qobject/qfloat.c b/qobject/qfloat.c
deleted file mode 100644
index d5da847701..0000000000
--- a/qobject/qfloat.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * QFloat Module
- *
- * Copyright IBM, Corp. 2009
- *
- * Authors:
- * Anthony Liguori <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-
-#include "qemu/osdep.h"
-#include "qapi/qmp/qfloat.h"
-#include "qapi/qmp/qobject.h"
-#include "qemu-common.h"
-
-/**
- * qfloat_from_int(): Create a new QFloat from a float
- *
- * Return strong reference.
- */
-QFloat *qfloat_from_double(double value)
-{
- QFloat *qf;
-
- qf = g_malloc(sizeof(*qf));
- qobject_init(QOBJECT(qf), QTYPE_QFLOAT);
- qf->value = value;
-
- return qf;
-}
-
-/**
- * qfloat_get_double(): Get the stored float
- */
-double qfloat_get_double(const QFloat *qf)
-{
- return qf->value;
-}
-
-/**
- * qobject_to_qfloat(): Convert a QObject into a QFloat
- */
-QFloat *qobject_to_qfloat(const QObject *obj)
-{
- if (!obj || qobject_type(obj) != QTYPE_QFLOAT) {
- return NULL;
- }
- return container_of(obj, QFloat, base);
-}
-
-/**
- * qfloat_destroy_obj(): Free all memory allocated by a
- * QFloat object
- */
-void qfloat_destroy_obj(QObject *obj)
-{
- assert(obj != NULL);
- g_free(qobject_to_qfloat(obj));
-}
diff --git a/qobject/qint.c b/qobject/qint.c
deleted file mode 100644
index d7d1b3021f..0000000000
--- a/qobject/qint.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * QInt Module
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- * Luiz Capitulino <lcapitulino@redhat.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-
-#include "qemu/osdep.h"
-#include "qapi/qmp/qint.h"
-#include "qapi/qmp/qobject.h"
-#include "qemu-common.h"
-
-/**
- * qint_from_int(): Create a new QInt from an int64_t
- *
- * Return strong reference.
- */
-QInt *qint_from_int(int64_t value)
-{
- QInt *qi;
-
- qi = g_malloc(sizeof(*qi));
- qobject_init(QOBJECT(qi), QTYPE_QINT);
- qi->value = value;
-
- return qi;
-}
-
-/**
- * qint_get_int(): Get the stored integer
- */
-int64_t qint_get_int(const QInt *qi)
-{
- return qi->value;
-}
-
-/**
- * qobject_to_qint(): Convert a QObject into a QInt
- */
-QInt *qobject_to_qint(const QObject *obj)
-{
- if (!obj || qobject_type(obj) != QTYPE_QINT) {
- return NULL;
- }
- return container_of(obj, QInt, base);
-}
-
-/**
- * qint_destroy_obj(): Free all memory allocated by a
- * QInt object
- */
-void qint_destroy_obj(QObject *obj)
-{
- assert(obj != NULL);
- g_free(qobject_to_qint(obj));
-}
diff --git a/qobject/qjson.c b/qobject/qjson.c
index b2f3bfec53..2e0930884e 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -132,12 +132,11 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
case QTYPE_QNULL:
qstring_append(str, "null");
break;
- case QTYPE_QINT: {
- QInt *val = qobject_to_qint(obj);
- char buffer[1024];
-
- snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val));
+ case QTYPE_QNUM: {
+ QNum *val = qobject_to_qnum(obj);
+ char *buffer = qnum_to_string(val);
qstring_append(str, buffer);
+ g_free(buffer);
break;
}
case QTYPE_QSTRING: {
@@ -234,34 +233,6 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
qstring_append(str, "]");
break;
}
- case QTYPE_QFLOAT: {
- QFloat *val = qobject_to_qfloat(obj);
- char buffer[1024];
- int len;
-
- /* FIXME: snprintf() is locale dependent; but JSON requires
- * numbers to be formatted as if in the C locale. Dependence
- * on C locale is a pervasive issue in QEMU. */
- /* FIXME: This risks printing Inf or NaN, which are not valid
- * JSON values. */
- /* FIXME: the default precision of 6 for %f often causes
- * rounding errors; we should be using DBL_DECIMAL_DIG (17),
- * and only rounding to a shorter number if the result would
- * still produce the same floating point value. */
- len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val));
- while (len > 0 && buffer[len - 1] == '0') {
- len--;
- }
-
- if (len && buffer[len - 1] == '.') {
- buffer[len - 1] = 0;
- } else {
- buffer[len] = 0;
- }
-
- qstring_append(str, buffer);
- break;
- }
case QTYPE_QBOOL: {
QBool *val = qobject_to_qbool(obj);
diff --git a/qobject/qnum.c b/qobject/qnum.c
new file mode 100644
index 0000000000..d88e4f7a59
--- /dev/null
+++ b/qobject/qnum.c
@@ -0,0 +1,157 @@
+/*
+ * QNum Module
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ * Luiz Capitulino <lcapitulino@redhat.com>
+ * Anthony Liguori <aliguori@us.ibm.com>
+ * Marc-André Lureau <marcandre.lureau@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qnum.h"
+#include "qapi/qmp/qobject.h"
+#include "qemu-common.h"
+
+/**
+ * qnum_from_int(): Create a new QNum from an int64_t
+ *
+ * Return strong reference.
+ */
+QNum *qnum_from_int(int64_t value)
+{
+ QNum *qn = g_new(QNum, 1);
+
+ qobject_init(QOBJECT(qn), QTYPE_QNUM);
+ qn->kind = QNUM_I64;
+ qn->u.i64 = value;
+
+ return qn;
+}
+
+/**
+ * qnum_from_double(): Create a new QNum from a double
+ *
+ * Return strong reference.
+ */
+QNum *qnum_from_double(double value)
+{
+ QNum *qn = g_new(QNum, 1);
+
+ qobject_init(QOBJECT(qn), QTYPE_QNUM);
+ qn->kind = QNUM_DOUBLE;
+ qn->u.dbl = value;
+
+ return qn;
+}
+
+/**
+ * qnum_get_try_int(): Get an integer representation of the number
+ *
+ * Return true on success.
+ */
+bool qnum_get_try_int(const QNum *qn, int64_t *val)
+{
+ switch (qn->kind) {
+ case QNUM_I64:
+ *val = qn->u.i64;
+ return true;
+ case QNUM_DOUBLE:
+ return false;
+ }
+
+ assert(0);
+ return false;
+}
+
+/**
+ * qnum_get_int(): Get an integer representation of the number
+ *
+ * assert() on failure.
+ */
+int64_t qnum_get_int(const QNum *qn)
+{
+ int64_t val;
+ bool success = qnum_get_try_int(qn, &val);
+ assert(success);
+ return val;
+}
+
+/**
+ * qnum_get_double(): Get a float representation of the number
+ *
+ * qnum_get_double() loses precision for integers beyond 53 bits.
+ */
+double qnum_get_double(QNum *qn)
+{
+ switch (qn->kind) {
+ case QNUM_I64:
+ return qn->u.i64;
+ case QNUM_DOUBLE:
+ return qn->u.dbl;
+ }
+
+ assert(0);
+}
+
+char *qnum_to_string(QNum *qn)
+{
+ char *buffer;
+ int len;
+
+ switch (qn->kind) {
+ case QNUM_I64:
+ return g_strdup_printf("%" PRId64, qn->u.i64);
+ case QNUM_DOUBLE:
+ /* FIXME: snprintf() is locale dependent; but JSON requires
+ * numbers to be formatted as if in the C locale. Dependence
+ * on C locale is a pervasive issue in QEMU. */
+ /* FIXME: This risks printing Inf or NaN, which are not valid
+ * JSON values. */
+ /* FIXME: the default precision of 6 for %f often causes
+ * rounding errors; we should be using DBL_DECIMAL_DIG (17),
+ * and only rounding to a shorter number if the result would
+ * still produce the same floating point value. */
+ buffer = g_strdup_printf("%f" , qn->u.dbl);
+ len = strlen(buffer);
+ while (len > 0 && buffer[len - 1] == '0') {
+ len--;
+ }
+
+ if (len && buffer[len - 1] == '.') {
+ buffer[len - 1] = 0;
+ } else {
+ buffer[len] = 0;
+ }
+
+ return buffer;
+ }
+
+ assert(0);
+}
+
+/**
+ * qobject_to_qnum(): Convert a QObject into a QNum
+ */
+QNum *qobject_to_qnum(const QObject *obj)
+{
+ if (!obj || qobject_type(obj) != QTYPE_QNUM) {
+ return NULL;
+ }
+ return container_of(obj, QNum, base);
+}
+
+/**
+ * qnum_destroy_obj(): Free all memory allocated by a
+ * QNum object
+ */
+void qnum_destroy_obj(QObject *obj)
+{
+ assert(obj != NULL);
+ g_free(qobject_to_qnum(obj));
+}
diff --git a/qobject/qobject.c b/qobject/qobject.c
index fe4fa10989..b0cafb66f1 100644
--- a/qobject/qobject.c
+++ b/qobject/qobject.c
@@ -14,11 +14,10 @@
static void (*qdestroy[QTYPE__MAX])(QObject *) = {
[QTYPE_NONE] = NULL, /* No such object exists */
[QTYPE_QNULL] = NULL, /* qnull_ is indestructible */
- [QTYPE_QINT] = qint_destroy_obj,
+ [QTYPE_QNUM] = qnum_destroy_obj,
[QTYPE_QSTRING] = qstring_destroy_obj,
[QTYPE_QDICT] = qdict_destroy_obj,
[QTYPE_QLIST] = qlist_destroy_obj,
- [QTYPE_QFLOAT] = qfloat_destroy_obj,
[QTYPE_QBOOL] = qbool_destroy_obj,
};
diff --git a/qom/object.c b/qom/object.c
index c7b8079df6..dee7f7c1eb 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -27,7 +27,6 @@
#include "qom/qom-qobject.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp/qbool.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qstring.h"
#define MAX_INTERFACES 32
@@ -1190,28 +1189,27 @@ bool object_property_get_bool(Object *obj, const char *name,
void object_property_set_int(Object *obj, int64_t value,
const char *name, Error **errp)
{
- QInt *qint = qint_from_int(value);
- object_property_set_qobject(obj, QOBJECT(qint), name, errp);
+ QNum *qnum = qnum_from_int(value);
+ object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
- QDECREF(qint);
+ QDECREF(qnum);
}
int64_t object_property_get_int(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
- QInt *qint;
+ QNum *qnum;
int64_t retval;
if (!ret) {
return -1;
}
- qint = qobject_to_qint(ret);
- if (!qint) {
+
+ qnum = qobject_to_qnum(ret);
+ if (!qnum || !qnum_get_try_int(qnum, &retval)) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int");
retval = -1;
- } else {
- retval = qint_get_int(qint);
}
qobject_decref(ret);
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index ffb5267162..a91c0b6a64 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -29,11 +29,7 @@
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/qerror.h"
-#include "qapi/qmp/qstring.h"
-#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qbool.h"
-#include "qapi/qmp/qint.h"
-#include "qapi/qmp/qfloat.h"
+#include "qapi/qmp/types.h"
#include "qapi-types.h"
#include "qapi-visit.h"
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index be8d81f07b..f067c63275 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -11,7 +11,6 @@
*/
#include "qemu/osdep.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
#include "qapi/error.h"
@@ -39,7 +38,7 @@ static void qdict_new_test(void)
static void qdict_put_obj_test(void)
{
- QInt *qi;
+ QNum *qn;
QDict *qdict;
QDictEntry *ent;
const int num = 42;
@@ -51,11 +50,11 @@ static void qdict_put_obj_test(void)
g_assert(qdict_size(qdict) == 1);
ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]);
- qi = qobject_to_qint(ent->value);
- g_assert(qint_get_int(qi) == num);
+ qn = qobject_to_qnum(ent->value);
+ g_assert_cmpint(qnum_get_int(qn), ==, num);
// destroy doesn't exit yet
- QDECREF(qi);
+ QDECREF(qn);
g_free(ent->key);
g_free(ent);
g_free(qdict);
@@ -74,7 +73,7 @@ static void qdict_destroy_simple_test(void)
static void qdict_get_test(void)
{
- QInt *qi;
+ QNum *qn;
QObject *obj;
const int value = -42;
const char *key = "test";
@@ -85,8 +84,8 @@ static void qdict_get_test(void)
obj = qdict_get(tests_dict, key);
g_assert(obj != NULL);
- qi = qobject_to_qint(obj);
- g_assert(qint_get_int(qi) == value);
+ qn = qobject_to_qnum(obj);
+ g_assert_cmpint(qnum_get_int(qn), ==, value);
QDECREF(tests_dict);
}
@@ -329,7 +328,7 @@ static void qdict_array_split_test(void)
{
QDict *test_dict = qdict_new();
QDict *dict1, *dict2;
- QInt *int1;
+ QNum *int1;
QList *test_list;
/*
@@ -380,7 +379,7 @@ static void qdict_array_split_test(void)
dict1 = qobject_to_qdict(qlist_pop(test_list));
dict2 = qobject_to_qdict(qlist_pop(test_list));
- int1 = qobject_to_qint(qlist_pop(test_list));
+ int1 = qobject_to_qnum(qlist_pop(test_list));
g_assert(dict1);
g_assert(dict2);
@@ -402,7 +401,7 @@ static void qdict_array_split_test(void)
QDECREF(dict2);
- g_assert(qint_get_int(int1) == 66);
+ g_assert_cmpint(qnum_get_int(int1), ==, 66);
QDECREF(int1);
@@ -447,14 +446,14 @@ static void qdict_array_split_test(void)
qdict_array_split(test_dict, &test_list);
- int1 = qobject_to_qint(qlist_pop(test_list));
+ int1 = qobject_to_qnum(qlist_pop(test_list));
g_assert(int1);
g_assert(qlist_empty(test_list));
QDECREF(test_list);
- g_assert(qint_get_int(int1) == 42);
+ g_assert_cmpint(qnum_get_int(int1), ==, 42);
QDECREF(int1);
diff --git a/tests/check-qfloat.c b/tests/check-qfloat.c
deleted file mode 100644
index 1da2cdae08..0000000000
--- a/tests/check-qfloat.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * QFloat unit-tests.
- *
- * Copyright IBM, Corp. 2009
- *
- * Authors:
- * Anthony Liguori <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-#include "qemu/osdep.h"
-
-#include "qapi/qmp/qfloat.h"
-#include "qemu-common.h"
-
-/*
- * Public Interface test-cases
- *
- * (with some violations to access 'private' data)
- */
-
-static void qfloat_from_double_test(void)
-{
- QFloat *qf;
- const double value = -42.23423;
-
- qf = qfloat_from_double(value);
- g_assert(qf != NULL);
- g_assert(qf->value == value);
- g_assert(qf->base.refcnt == 1);
- g_assert(qobject_type(QOBJECT(qf)) == QTYPE_QFLOAT);
-
- // destroy doesn't exit yet
- g_free(qf);
-}
-
-static void qfloat_destroy_test(void)
-{
- QFloat *qf = qfloat_from_double(0.0);
- QDECREF(qf);
-}
-
-int main(int argc, char **argv)
-{
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/public/from_double", qfloat_from_double_test);
- g_test_add_func("/public/destroy", qfloat_destroy_test);
-
- return g_test_run();
-}
diff --git a/tests/check-qint.c b/tests/check-qint.c
deleted file mode 100644
index b6e4555115..0000000000
--- a/tests/check-qint.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * QInt unit-tests.
- *
- * Copyright (C) 2009 Red Hat Inc.
- *
- * Authors:
- * Luiz Capitulino <lcapitulino@redhat.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- */
-#include "qemu/osdep.h"
-
-#include "qapi/qmp/qint.h"
-#include "qemu-common.h"
-
-/*
- * Public Interface test-cases
- *
- * (with some violations to access 'private' data)
- */
-
-static void qint_from_int_test(void)
-{
- QInt *qi;
- const int value = -42;
-
- qi = qint_from_int(value);
- g_assert(qi != NULL);
- g_assert(qi->value == value);
- g_assert(qi->base.refcnt == 1);
- g_assert(qobject_type(QOBJECT(qi)) == QTYPE_QINT);
-
- // destroy doesn't exit yet
- g_free(qi);
-}
-
-static void qint_destroy_test(void)
-{
- QInt *qi = qint_from_int(0);
- QDECREF(qi);
-}
-
-static void qint_from_int64_test(void)
-{
- QInt *qi;
- const int64_t value = 0x1234567890abcdefLL;
-
- qi = qint_from_int(value);
- g_assert((int64_t) qi->value == value);
-
- QDECREF(qi);
-}
-
-static void qint_get_int_test(void)
-{
- QInt *qi;
- const int value = 123456;
-
- qi = qint_from_int(value);
- g_assert(qint_get_int(qi) == value);
-
- QDECREF(qi);
-}
-
-static void qobject_to_qint_test(void)
-{
- QInt *qi;
-
- qi = qint_from_int(0);
- g_assert(qobject_to_qint(QOBJECT(qi)) == qi);
-
- QDECREF(qi);
-}
-
-int main(int argc, char **argv)
-{
- g_test_init(&argc, &argv, NULL);
-
- g_test_add_func("/public/from_int", qint_from_int_test);
- g_test_add_func("/public/destroy", qint_destroy_test);
- g_test_add_func("/public/from_int64", qint_from_int64_test);
- g_test_add_func("/public/get_int", qint_get_int_test);
- g_test_add_func("/public/to_qint", qobject_to_qint_test);
-
- return g_test_run();
-}
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 963dd46f07..f0a89f7847 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -886,21 +886,23 @@ static void simple_number(void)
};
for (i = 0; test_cases[i].encoded; i++) {
- QInt *qint;
+ QNum *qnum;
+ int64_t val;
- qint = qobject_to_qint(qobject_from_json(test_cases[i].encoded,
+ qnum = qobject_to_qnum(qobject_from_json(test_cases[i].encoded,
&error_abort));
- g_assert(qint);
- g_assert(qint_get_int(qint) == test_cases[i].decoded);
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, test_cases[i].decoded);
if (test_cases[i].skip == 0) {
QString *str;
- str = qobject_to_json(QOBJECT(qint));
+ str = qobject_to_json(QOBJECT(qnum));
g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0);
QDECREF(str);
}
- QDECREF(qint);
+ QDECREF(qnum);
}
}
@@ -921,12 +923,12 @@ static void float_number(void)
for (i = 0; test_cases[i].encoded; i++) {
QObject *obj;
- QFloat *qfloat;
+ QNum *qnum;
obj = qobject_from_json(test_cases[i].encoded, &error_abort);
- qfloat = qobject_to_qfloat(obj);
- g_assert(qfloat);
- g_assert(qfloat_get_double(qfloat) == test_cases[i].decoded);
+ qnum = qobject_to_qnum(obj);
+ g_assert(qnum);
+ g_assert(qnum_get_double(qnum) == test_cases[i].decoded);
if (test_cases[i].skip == 0) {
QString *str;
@@ -936,29 +938,31 @@ static void float_number(void)
QDECREF(str);
}
- QDECREF(qfloat);
+ QDECREF(qnum);
}
}
static void vararg_number(void)
{
- QInt *qint;
- QFloat *qfloat;
+ QNum *qnum;
int value = 0x2342;
long long value_ll = 0x2342342343LL;
double valuef = 2.323423423;
+ int64_t val;
- qint = qobject_to_qint(qobject_from_jsonf("%d", value));
- g_assert(qint_get_int(qint) == value);
- QDECREF(qint);
+ qnum = qobject_to_qnum(qobject_from_jsonf("%d", value));
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, value);
+ QDECREF(qnum);
- qint = qobject_to_qint(qobject_from_jsonf("%lld", value_ll));
- g_assert(qint_get_int(qint) == value_ll);
- QDECREF(qint);
+ qnum = qobject_to_qnum(qobject_from_jsonf("%lld", value_ll));
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, value_ll);
+ QDECREF(qnum);
- qfloat = qobject_to_qfloat(qobject_from_jsonf("%f", valuef));
- g_assert(qfloat_get_double(qfloat) == valuef);
- QDECREF(qfloat);
+ qnum = qobject_to_qnum(qobject_from_jsonf("%f", valuef));
+ g_assert(qnum_get_double(qnum) == valuef);
+ QDECREF(qnum);
}
static void keyword_literal(void)
@@ -1019,7 +1023,7 @@ struct LiteralQObject
{
int type;
union {
- int64_t qint;
+ int64_t qnum;
const char *qstr;
LiteralQDictEntry *qdict;
LiteralQObject *qlist;
@@ -1032,7 +1036,7 @@ struct LiteralQDictEntry
LiteralQObject value;
};
-#define QLIT_QINT(val) (LiteralQObject){.type = QTYPE_QINT, .value.qint = (val)}
+#define QLIT_QNUM(val) (LiteralQObject){.type = QTYPE_QNUM, .value.qnum = (val)}
#define QLIT_QSTR(val) (LiteralQObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
#define QLIT_QDICT(val) (LiteralQObject){.type = QTYPE_QDICT, .value.qdict = (val)}
#define QLIT_QLIST(val) (LiteralQObject){.type = QTYPE_QLIST, .value.qlist = (val)}
@@ -1064,13 +1068,16 @@ static void compare_helper(QObject *obj, void *opaque)
static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs)
{
+ int64_t val;
+
if (!rhs || lhs->type != qobject_type(rhs)) {
return 0;
}
switch (lhs->type) {
- case QTYPE_QINT:
- return lhs->value.qint == qint_get_int(qobject_to_qint(rhs));
+ case QTYPE_QNUM:
+ g_assert(qnum_get_try_int(qobject_to_qnum(rhs), &val));
+ return lhs->value.qnum == val;
case QTYPE_QSTRING:
return (strcmp(lhs->value.qstr, qstring_get_str(qobject_to_qstring(rhs))) == 0);
case QTYPE_QDICT: {
@@ -1114,7 +1121,7 @@ static void simple_dict(void)
{
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
- { "foo", QLIT_QINT(42) },
+ { "foo", QLIT_QNUM(42) },
{ "bar", QLIT_QSTR("hello world") },
{ }
})),
@@ -1126,7 +1133,7 @@ static void simple_dict(void)
}, {
.encoded = "{\"foo\": 43}",
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
- { "foo", QLIT_QINT(43) },
+ { "foo", QLIT_QNUM(43) },
{ }
})),
},
@@ -1212,15 +1219,15 @@ static void simple_list(void)
{
.encoded = "[43,42]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(43),
- QLIT_QINT(42),
+ QLIT_QNUM(43),
+ QLIT_QNUM(42),
{ }
})),
},
{
.encoded = "[43]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(43),
+ QLIT_QNUM(43),
{ }
})),
},
@@ -1269,35 +1276,35 @@ static void simple_whitespace(void)
{
.encoded = " [ 43 , 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(43),
- QLIT_QINT(42),
+ QLIT_QNUM(43),
+ QLIT_QNUM(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(43),
+ QLIT_QNUM(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
- QLIT_QINT(42),
+ QLIT_QNUM(42),
{ }
})),
},
{
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
.decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(43),
+ QLIT_QNUM(43),
QLIT_QDICT(((LiteralQDictEntry[]){
{ "h", QLIT_QSTR("b") },
- { "a", QLIT_QINT(32) },
+ { "a", QLIT_QNUM(32) },
{ }})),
QLIT_QLIST(((LiteralQObject[]){
{ }})),
- QLIT_QINT(42),
+ QLIT_QNUM(42),
{ }
})),
},
@@ -1327,11 +1334,11 @@ static void simple_varargs(void)
QObject *embedded_obj;
QObject *obj;
LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(1),
- QLIT_QINT(2),
+ QLIT_QNUM(1),
+ QLIT_QNUM(2),
QLIT_QLIST(((LiteralQObject[]){
- QLIT_QINT(32),
- QLIT_QINT(42),
+ QLIT_QNUM(32),
+ QLIT_QNUM(42),
{}})),
{}}));
diff --git a/tests/check-qlist.c b/tests/check-qlist.c
index 4983867c27..a9b65c6239 100644
--- a/tests/check-qlist.c
+++ b/tests/check-qlist.c
@@ -11,7 +11,8 @@
*/
#include "qemu/osdep.h"
-#include "qapi/qmp/qint.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qlist.h"
/*
@@ -35,11 +36,11 @@ static void qlist_new_test(void)
static void qlist_append_test(void)
{
- QInt *qi;
+ QNum *qi;
QList *qlist;
QListEntry *entry;
- qi = qint_from_int(42);
+ qi = qnum_from_int(42);
qlist = qlist_new();
qlist_append(qlist, qi);
@@ -84,13 +85,17 @@ static const int iter_max = 42;
static void iter_func(QObject *obj, void *opaque)
{
- QInt *qi;
+ QNum *qi;
+ int64_t val;
g_assert(opaque == NULL);
- qi = qobject_to_qint(obj);
+ qi = qobject_to_qnum(obj);
g_assert(qi != NULL);
- g_assert((qint_get_int(qi) >= 0) && (qint_get_int(qi) <= iter_max));
+
+ g_assert(qnum_get_try_int(qi, &val));
+ g_assert_cmpint(val, >=, 0);
+ g_assert_cmpint(val, <=, iter_max);
iter_called++;
}
diff --git a/tests/check-qnum.c b/tests/check-qnum.c
new file mode 100644
index 0000000000..d94cea024b
--- /dev/null
+++ b/tests/check-qnum.c
@@ -0,0 +1,136 @@
+/*
+ * QNum unit-tests.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ * Copyright IBM, Corp. 2009
+ *
+ * Authors:
+ * Luiz Capitulino <lcapitulino@redhat.com>
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+
+#include "qapi/qmp/qnum.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+
+/*
+ * Public Interface test-cases
+ *
+ * (with some violations to access 'private' data)
+ */
+
+static void qnum_from_int_test(void)
+{
+ QNum *qn;
+ const int value = -42;
+
+ qn = qnum_from_int(value);
+ g_assert(qn != NULL);
+ g_assert_cmpint(qn->kind, ==, QNUM_I64);
+ g_assert_cmpint(qn->u.i64, ==, value);
+ g_assert_cmpint(qn->base.refcnt, ==, 1);
+ g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
+
+ // destroy doesn't exit yet
+ g_free(qn);
+}
+
+static void qnum_from_double_test(void)
+{
+ QNum *qn;
+ const double value = -42.23423;
+
+ qn = qnum_from_double(value);
+ g_assert(qn != NULL);
+ g_assert_cmpint(qn->kind, ==, QNUM_DOUBLE);
+ g_assert_cmpfloat(qn->u.dbl, ==, value);
+ g_assert_cmpint(qn->base.refcnt, ==, 1);
+ g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
+
+ // destroy doesn't exit yet
+ g_free(qn);
+}
+
+static void qnum_from_int64_test(void)
+{
+ QNum *qn;
+ const int64_t value = 0x1234567890abcdefLL;
+
+ qn = qnum_from_int(value);
+ g_assert_cmpint((int64_t) qn->u.i64, ==, value);
+
+ QDECREF(qn);
+}
+
+static void qnum_get_int_test(void)
+{
+ QNum *qn;
+ const int value = 123456;
+
+ qn = qnum_from_int(value);
+ g_assert_cmpint(qnum_get_int(qn), ==, value);
+
+ QDECREF(qn);
+}
+
+static void qobject_to_qnum_test(void)
+{
+ QNum *qn;
+
+ qn = qnum_from_int(0);
+ g_assert(qobject_to_qnum(QOBJECT(qn)) == qn);
+ QDECREF(qn);
+
+ qn = qnum_from_double(0);
+ g_assert(qobject_to_qnum(QOBJECT(qn)) == qn);
+ QDECREF(qn);
+}
+
+static void qnum_to_string_test(void)
+{
+ QNum *qn;
+ char *tmp;
+
+ qn = qnum_from_int(123456);
+ tmp = qnum_to_string(qn);
+ g_assert_cmpstr(tmp, ==, "123456");
+ g_free(tmp);
+ QDECREF(qn);
+
+ qn = qnum_from_double(0.42);
+ tmp = qnum_to_string(qn);
+ g_assert_cmpstr(tmp, ==, "0.42");
+ g_free(tmp);
+ QDECREF(qn);
+}
+
+static void qnum_destroy_test(void)
+{
+ QNum *qn;
+
+ qn = qnum_from_int(0);
+ QDECREF(qn);
+
+ qn = qnum_from_double(0.42);
+ QDECREF(qn);
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/qnum/from_int", qnum_from_int_test);
+ g_test_add_func("/qnum/from_double", qnum_from_double_test);
+ g_test_add_func("/qnum/destroy", qnum_destroy_test);
+ g_test_add_func("/qnum/from_int64", qnum_from_int64_test);
+ g_test_add_func("/qnum/get_int", qnum_get_int_test);
+ g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test);
+ g_test_add_func("/qnum/to_string", qnum_to_string_test);
+
+ return g_test_run();
+}
diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c
index acdded4d67..904c89d4d4 100644
--- a/tests/test-qmp-commands.c
+++ b/tests/test-qmp-commands.c
@@ -162,7 +162,8 @@ static void test_dispatch_cmd_io(void)
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
- QInt *ret3;
+ QNum *ret3;
+ int64_t val;
qdict_put_int(ud1a, "integer", 42);
qdict_put_str(ud1a, "string", "hello");
@@ -194,8 +195,9 @@ static void test_dispatch_cmd_io(void)
qdict_put(req, "arguments", args3);
qdict_put_str(req, "execute", "guest-get-time");
- ret3 = qobject_to_qint(test_qmp_dispatch(req));
- assert(qint_get_int(ret3) == 66);
+ ret3 = qobject_to_qnum(test_qmp_dispatch(req));
+ g_assert(qnum_get_try_int(ret3, &val));
+ g_assert_cmpint(val, ==, 66);
QDECREF(ret3);
QDECREF(req);
diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c
index 4c0f09601d..9fb3c5e81e 100644
--- a/tests/test-qmp-event.c
+++ b/tests/test-qmp-event.c
@@ -18,7 +18,6 @@
#include "test-qapi-visit.h"
#include "test-qapi-event.h"
#include "qapi/qmp/types.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qobject.h"
#include "qapi/qmp-event.h"
@@ -41,6 +40,7 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque)
{
QObject *obj2;
QDictCmpData d_new, *d = opaque;
+ int64_t val1, val2;
if (!d->result) {
return;
@@ -62,9 +62,10 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, void *opaque)
d->result = (qbool_get_bool(qobject_to_qbool(obj1)) ==
qbool_get_bool(qobject_to_qbool(obj2)));
return;
- case QTYPE_QINT:
- d->result = (qint_get_int(qobject_to_qint(obj1)) ==
- qint_get_int(qobject_to_qint(obj2)));
+ case QTYPE_QNUM:
+ g_assert(qnum_get_try_int(qobject_to_qnum(obj1), &val1));
+ g_assert(qnum_get_try_int(qobject_to_qnum(obj2), &val2));
+ d->result = val1 == val2;
return;
case QTYPE_QSTRING:
d->result = g_strcmp0(qstring_get_str(qobject_to_qstring(obj1)),
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 3a6ce2226c..9e3d4aa7e5 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -164,9 +164,9 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data,
Error *err = NULL;
Visitor *v;
- /* this will overflow a Qint/int64, so should be deserialized into
- * a QFloat/double field instead, leading to an error if we pass it
- * to visit_type_int. confirm this.
+ /* this will overflow a QNUM_I64, so should be deserialized into a
+ * QNUM_DOUBLE field instead, leading to an error if we pass it to
+ * visit_type_int. confirm this.
*/
v = visitor_input_test_init(data, "%f", DBL_MAX);
@@ -468,17 +468,19 @@ static void test_visitor_in_any(TestInputVisitorData *data,
{
QObject *res = NULL;
Visitor *v;
- QInt *qint;
+ QNum *qnum;
QBool *qbool;
QString *qstring;
QDict *qdict;
QObject *qobj;
+ int64_t val;
v = visitor_input_test_init(data, "-42");
visit_type_any(v, NULL, &res, &error_abort);
- qint = qobject_to_qint(res);
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, -42);
+ qnum = qobject_to_qnum(res);
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, -42);
qobject_decref(res);
v = visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo' }");
@@ -487,9 +489,10 @@ static void test_visitor_in_any(TestInputVisitorData *data,
g_assert(qdict && qdict_size(qdict) == 3);
qobj = qdict_get(qdict, "integer");
g_assert(qobj);
- qint = qobject_to_qint(qobj);
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, -42);
+ qnum = qobject_to_qnum(qobj);
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, -42);
qobj = qdict_get(qdict, "boolean");
g_assert(qobj);
qbool = qobject_to_qbool(qobj);
@@ -567,7 +570,7 @@ static void test_visitor_in_alternate(TestInputVisitorData *data,
v = visitor_input_test_init(data, "42");
visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort);
- g_assert_cmpint(tmp->type, ==, QTYPE_QINT);
+ g_assert_cmpint(tmp->type, ==, QTYPE_QNUM);
g_assert_cmpint(tmp->u.i, ==, 42);
qapi_free_UserDefAlternate(tmp);
@@ -595,7 +598,7 @@ static void test_visitor_in_alternate(TestInputVisitorData *data,
v = visitor_input_test_init(data, "{ 'alt': 42 }");
visit_type_WrapAlternate(v, NULL, &wrap, &error_abort);
- g_assert_cmpint(wrap->alt->type, ==, QTYPE_QINT);
+ g_assert_cmpint(wrap->alt->type, ==, QTYPE_QNUM);
g_assert_cmpint(wrap->alt->u.i, ==, 42);
qapi_free_WrapAlternate(wrap);
@@ -636,19 +639,19 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
v = visitor_input_test_init(data, "42");
visit_type_AltEnumNum(v, NULL, &aen, &error_abort);
- g_assert_cmpint(aen->type, ==, QTYPE_QFLOAT);
+ g_assert_cmpint(aen->type, ==, QTYPE_QNUM);
g_assert_cmpfloat(aen->u.n, ==, 42);
qapi_free_AltEnumNum(aen);
v = visitor_input_test_init(data, "42");
visit_type_AltNumEnum(v, NULL, &ans, &error_abort);
- g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
+ g_assert_cmpint(ans->type, ==, QTYPE_QNUM);
g_assert_cmpfloat(ans->u.n, ==, 42);
qapi_free_AltNumEnum(ans);
v = visitor_input_test_init(data, "42");
visit_type_AltEnumInt(v, NULL, &asi, &error_abort);
- g_assert_cmpint(asi->type, ==, QTYPE_QINT);
+ g_assert_cmpint(asi->type, ==, QTYPE_QNUM);
g_assert_cmpint(asi->u.i, ==, 42);
qapi_free_AltEnumInt(asi);
@@ -661,13 +664,13 @@ static void test_visitor_in_alternate_number(TestInputVisitorData *data,
v = visitor_input_test_init(data, "42.5");
visit_type_AltEnumNum(v, NULL, &aen, &error_abort);
- g_assert_cmpint(aen->type, ==, QTYPE_QFLOAT);
+ g_assert_cmpint(aen->type, ==, QTYPE_QNUM);
g_assert_cmpfloat(aen->u.n, ==, 42.5);
qapi_free_AltEnumNum(aen);
v = visitor_input_test_init(data, "42.5");
visit_type_AltNumEnum(v, NULL, &ans, &error_abort);
- g_assert_cmpint(ans->type, ==, QTYPE_QFLOAT);
+ g_assert_cmpint(ans->type, ==, QTYPE_QNUM);
g_assert_cmpfloat(ans->u.n, ==, 42.5);
qapi_free_AltNumEnum(ans);
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index 4e8fdf1397..a16c8f663f 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -58,13 +58,15 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
const void *unused)
{
int64_t value = -42;
- QInt *qint;
+ int64_t val;
+ QNum *qnum;
visit_type_int(data->ov, NULL, &value, &error_abort);
- qint = qobject_to_qint(visitor_get(data));
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, value);
+ qnum = qobject_to_qnum(visitor_get(data));
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, value);
}
static void test_visitor_out_bool(TestOutputVisitorData *data,
@@ -84,13 +86,13 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused)
{
double value = 3.14;
- QFloat *qfloat;
+ QNum *qnum;
visit_type_number(data->ov, NULL, &value, &error_abort);
- qfloat = qobject_to_qfloat(visitor_get(data));
- g_assert(qfloat);
- g_assert(qfloat_get_double(qfloat) == value);
+ qnum = qobject_to_qnum(visitor_get(data));
+ g_assert(qnum);
+ g_assert(qnum_get_double(qnum) == value);
}
static void test_visitor_out_string(TestOutputVisitorData *data,
@@ -329,16 +331,18 @@ static void test_visitor_out_any(TestOutputVisitorData *data,
const void *unused)
{
QObject *qobj;
- QInt *qint;
+ QNum *qnum;
QBool *qbool;
QString *qstring;
QDict *qdict;
+ int64_t val;
- qobj = QOBJECT(qint_from_int(-42));
+ qobj = QOBJECT(qnum_from_int(-42));
visit_type_any(data->ov, NULL, &qobj, &error_abort);
- qint = qobject_to_qint(visitor_get(data));
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, -42);
+ qnum = qobject_to_qnum(visitor_get(data));
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, -42);
qobject_decref(qobj);
visitor_reset(data);
@@ -351,9 +355,10 @@ static void test_visitor_out_any(TestOutputVisitorData *data,
qobject_decref(qobj);
qdict = qobject_to_qdict(visitor_get(data));
g_assert(qdict);
- qint = qobject_to_qint(qdict_get(qdict, "integer"));
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, -42);
+ qnum = qobject_to_qnum(qdict_get(qdict, "integer"));
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, -42);
qbool = qobject_to_qbool(qdict_get(qdict, "boolean"));
g_assert(qbool);
g_assert(qbool_get_bool(qbool) == true);
@@ -388,18 +393,20 @@ static void test_visitor_out_alternate(TestOutputVisitorData *data,
const void *unused)
{
UserDefAlternate *tmp;
- QInt *qint;
+ QNum *qnum;
QString *qstr;
QDict *qdict;
+ int64_t val;
tmp = g_new0(UserDefAlternate, 1);
- tmp->type = QTYPE_QINT;
+ tmp->type = QTYPE_QNUM;
tmp->u.i = 42;
visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort);
- qint = qobject_to_qint(visitor_get(data));
- g_assert(qint);
- g_assert_cmpint(qint_get_int(qint), ==, 42);
+ qnum = qobject_to_qnum(visitor_get(data));
+ g_assert(qnum);
+ g_assert(qnum_get_try_int(qnum, &val));
+ g_assert_cmpint(val, ==, 42);
qapi_free_UserDefAlternate(tmp);
@@ -603,18 +610,22 @@ static void check_native_list(QObject *qobj,
case USER_DEF_NATIVE_LIST_UNION_KIND_U16:
case USER_DEF_NATIVE_LIST_UNION_KIND_U32:
case USER_DEF_NATIVE_LIST_UNION_KIND_U64:
- /* all integer elements in JSON arrays get stored into QInts when
- * we convert to QObjects, so we can check them all in the same
- * fashion, so simply fall through here
+ /*
+ * All integer elements in JSON arrays get stored into QNums
+ * when we convert to QObjects, so we can check them all in
+ * the same fashion, so simply fall through here.
*/
case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER:
for (i = 0; i < 32; i++) {
QObject *tmp;
- QInt *qvalue;
+ QNum *qvalue;
+ int64_t val;
+
tmp = qlist_peek(qlist);
g_assert(tmp);
- qvalue = qobject_to_qint(tmp);
- g_assert_cmpint(qint_get_int(qvalue), ==, i);
+ qvalue = qobject_to_qnum(tmp);
+ g_assert(qnum_get_try_int(qvalue, &val));
+ g_assert_cmpint(val, ==, i);
qobject_decref(qlist_pop(qlist));
}
break;
@@ -645,15 +656,15 @@ static void check_native_list(QObject *qobj,
case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER:
for (i = 0; i < 32; i++) {
QObject *tmp;
- QFloat *qvalue;
+ QNum *qvalue;
GString *double_expected = g_string_new("");
GString *double_actual = g_string_new("");
tmp = qlist_peek(qlist);
g_assert(tmp);
- qvalue = qobject_to_qfloat(tmp);
+ qvalue = qobject_to_qnum(tmp);
g_string_printf(double_expected, "%.6f", (double)i / 3);
- g_string_printf(double_actual, "%.6f", qfloat_get_double(qvalue));
+ g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue));
g_assert_cmpstr(double_actual->str, ==, double_expected->str);
qobject_decref(qlist_pop(qlist));
diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c
index 4166ce54b7..58a2dd9fe8 100644
--- a/tests/test-x86-cpuid-compat.c
+++ b/tests/test-x86-cpuid-compat.c
@@ -1,9 +1,8 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "qapi/qmp/qlist.h"
-#include "qapi/qmp/qstring.h"
+#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qint.h"
+#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qbool.h"
#include "libqtest.h"
@@ -57,12 +56,14 @@ static void test_cpuid_prop(const void *data)
{
const CpuidTestArgs *args = data;
char *path;
- QInt *value;
+ QNum *value;
+ int64_t val;
qtest_start(args->cmdline);
path = get_cpu0_qom_path();
- value = qobject_to_qint(qom_get(path, args->property));
- g_assert_cmpint(qint_get_int(value), ==, args->expected_value);
+ value = qobject_to_qnum(qom_get(path, args->property));
+ g_assert(qnum_get_try_int(value, &val));
+ g_assert_cmpint(val, ==, args->expected_value);
qtest_end();
QDECREF(value);
@@ -109,12 +110,15 @@ static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx,
uint32_t reax = qdict_get_int(w, "cpuid-input-eax");
bool has_ecx = qdict_haskey(w, "cpuid-input-ecx");
uint32_t recx = 0;
+ int64_t val;
if (has_ecx) {
recx = qdict_get_int(w, "cpuid-input-ecx");
}
if (eax == reax && (!has_ecx || ecx == recx) && !strcmp(rreg, reg)) {
- return qint_get_int(qobject_to_qint(qdict_get(w, "features")));
+ g_assert(qnum_get_try_int(qobject_to_qnum(qdict_get(w, "features")),
+ &val));
+ return val;
}
}
return 0;
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 804abc5c0f..561d0649cf 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -30,7 +30,6 @@
#include "qemu-x509.h"
#include "qemu/sockets.h"
#include "qmp-commands.h"
-#include "qapi/qmp/qint.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qjson.h"
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 1e53b1cf84..89ab12c0d8 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -44,7 +44,6 @@
#endif
#include "qemu/bswap.h"
-#include "qapi/qmp/qint.h"
#include "vnc.h"
#include "vnc-enc-tight.h"
#include "vnc-palette.h"
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 5977bfc3e9..9b1dc8093b 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -941,9 +941,8 @@ typedef struct OptsFromQDictState {
static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
{
OptsFromQDictState *state = opaque;
- char buf[32];
+ char buf[32], *tmp = NULL;
const char *value;
- int n;
if (!strcmp(key, "id") || *state->errp) {
return;
@@ -953,17 +952,9 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
case QTYPE_QSTRING:
value = qstring_get_str(qobject_to_qstring(obj));
break;
- case QTYPE_QINT:
- n = snprintf(buf, sizeof(buf), "%" PRId64,
- qint_get_int(qobject_to_qint(obj)));
- assert(n < sizeof(buf));
- value = buf;
- break;
- case QTYPE_QFLOAT:
- n = snprintf(buf, sizeof(buf), "%.17g",
- qfloat_get_double(qobject_to_qfloat(obj)));
- assert(n < sizeof(buf));
- value = buf;
+ case QTYPE_QNUM:
+ tmp = qnum_to_string(qobject_to_qnum(obj));
+ value = tmp;
break;
case QTYPE_QBOOL:
pstrcpy(buf, sizeof(buf),
@@ -975,13 +966,14 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
}
qemu_opt_set(state->opts, key, value, state->errp);
+ g_free(tmp);
}
/*
* Create QemuOpts from a QDict.
- * Use value of key "id" as ID if it exists and is a QString.
- * Only QStrings, QInts, QFloats and QBools are copied. Entries with
- * other types are silently ignored.
+ * Use value of key "id" as ID if it exists and is a QString. Only
+ * QStrings, QNums and QBools are copied. Entries with other types
+ * are silently ignored.
*/
QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
Error **errp)
diff --git a/MAINTAINERS b/MAINTAINERS
index 120788d8fb..05e6e963ba 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1411,8 +1411,7 @@ F: include/qapi/qmp/
X: include/qapi/qmp/dispatch.h
F: scripts/coccinelle/qobject.cocci
F: tests/check-qdict.c
-F: tests/check-qfloat.c
-F: tests/check-qint.c
+F: tests/check-qnum.c
F: tests/check-qjson.c
F: tests/check-qlist.c
F: tests/check-qstring.c
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index bed55084bb..fc8885c9a4 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,2 +1,2 @@
-util-obj-y = qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
+util-obj-y = qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o
util-obj-y += qjson.o qobject.o json-lexer.o json-streamer.o json-parser.o
diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci
index 97703a438b..c3253deb1b 100644
--- a/scripts/coccinelle/qobject.cocci
+++ b/scripts/coccinelle/qobject.cocci
@@ -6,7 +6,7 @@ expression Obj, Key, E;
- qdict_put_obj(Obj, Key, QOBJECT(E));
+ qdict_put(Obj, Key, E);
|
-- qdict_put(Obj, Key, qint_from_int(E));
+- qdict_put(Obj, Key, qnum_from_int(E));
+ qdict_put_int(Obj, Key, E);
|
- qdict_put(Obj, Key, qbool_from_bool(E));
@@ -24,7 +24,7 @@ expression Obj, E;
- qlist_append_obj(Obj, QOBJECT(E));
+ qlist_append(Obj, E);
|
-- qlist_append(Obj, qint_from_int(E));
+- qlist_append(Obj, qnum_from_int(E));
+ qlist_append_int(Obj, E);
|
- qlist_append(Obj, qbool_from_bool(E));
diff --git a/tests/.gitignore b/tests/.gitignore
index 40c2e3e757..8e01b004f1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,7 +1,6 @@
atomic_add-bench
check-qdict
-check-qfloat
-check-qint
+check-qnum
check-qjson
check-qlist
check-qnull
diff --git a/tests/Makefile.include b/tests/Makefile.include
index f42f3dfa72..fec5af765a 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -10,10 +10,8 @@ check-unit-y = tests/check-qdict$(EXESUF)
gcov-files-check-qdict-y = qobject/qdict.c
check-unit-y += tests/test-char$(EXESUF)
gcov-files-check-qdict-y = chardev/char.c
-check-unit-y += tests/check-qfloat$(EXESUF)
-gcov-files-check-qfloat-y = qobject/qfloat.c
-check-unit-y += tests/check-qint$(EXESUF)
-gcov-files-check-qint-y = qobject/qint.c
+check-unit-y += tests/check-qnum$(EXESUF)
+gcov-files-check-qnum-y = qobject/qnum.c
check-unit-y += tests/check-qstring$(EXESUF)
gcov-files-check-qstring-y = qobject/qstring.c
check-unit-y += tests/check-qlist$(EXESUF)
@@ -506,8 +504,8 @@ GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \
tests/test-qmp-commands.h tests/test-qapi-event.h \
tests/test-qmp-introspect.h
-test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \
- tests/check-qlist.o tests/check-qfloat.o tests/check-qnull.o \
+test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \
+ tests/check-qlist.o tests/check-qnull.o \
tests/check-qjson.o \
tests/test-coroutine.o tests/test-string-output-visitor.o \
tests/test-string-input-visitor.o tests/test-qobject-output-visitor.o \
@@ -535,11 +533,10 @@ test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y)
test-io-obj-y = $(io-obj-y) $(test-crypto-obj-y)
test-block-obj-y = $(block-obj-y) $(test-io-obj-y) tests/iothread.o
-tests/check-qint$(EXESUF): tests/check-qint.o $(test-util-obj-y)
+tests/check-qnum$(EXESUF): tests/check-qnum.o $(test-util-obj-y)
tests/check-qstring$(EXESUF): tests/check-qstring.o $(test-util-obj-y)
tests/check-qdict$(EXESUF): tests/check-qdict.o $(test-util-obj-y)
tests/check-qlist$(EXESUF): tests/check-qlist.o $(test-util-obj-y)
-tests/check-qfloat$(EXESUF): tests/check-qfloat.o $(test-util-obj-y)
tests/check-qnull$(EXESUF): tests/check-qnull.o $(test-util-obj-y)
tests/check-qjson$(EXESUF): tests/check-qjson.o $(test-util-obj-y)
tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(test-qom-obj-y)
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index 5d7c13cad1..17e652535c 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 70c1252408..63ca25a8b9 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -6,7 +6,7 @@ object Object
tag base1
case one: Variant1
case two: Variant2
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
object SugaredUnion
member type: SugaredUnionKind optional=False
diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
index 8a5b034424..40b886ddae 100644
--- a/tests/qapi-schema/empty.out
+++ b/tests/qapi-schema/empty.out
@@ -1,3 +1,3 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
object q_empty
diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-case.out
index 5a0f2bf805..313c0fe7be 100644
--- a/tests/qapi-schema/event-case.out
+++ b/tests/qapi-schema/event-case.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
event oops None
boxed=False
diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/ident-with-escape.out
index 1d2722c02e..b5637cb2e0 100644
--- a/tests/qapi-schema/ident-with-escape.out
+++ b/tests/qapi-schema/ident-with-escape.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
command fooA q_obj_fooA-arg -> None
gen=True success_response=True boxed=False
diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out
index 5d7c13cad1..17e652535c 100644
--- a/tests/qapi-schema/include-relpath.out
+++ b/tests/qapi-schema/include-relpath.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty
diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out
index 5d7c13cad1..17e652535c 100644
--- a/tests/qapi-schema/include-repetition.out
+++ b/tests/qapi-schema/include-repetition.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty
diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/include-simple.out
index 5d7c13cad1..17e652535c 100644
--- a/tests/qapi-schema/include-simple.out
+++ b/tests/qapi-schema/include-simple.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty
diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indented-expr.out
index e8171c935f..586795f44d 100644
--- a/tests/qapi-schema/indented-expr.out
+++ b/tests/qapi-schema/indented-expr.out
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
command eins None -> None
gen=True success_response=True boxed=False
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index e727a5a84c..b88b8aae6f 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -50,7 +50,7 @@ object NestedEnumsOne
member enum4: EnumOne optional=True
enum QEnumTwo ['value1', 'value2']
prefix QENUM_TWO
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
prefix QTYPE
object TestStruct
member integer: int optional=False
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 07/43] qapi: Remove visit_start_alternate() parameter promote_int
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (5 preceding siblings ...)
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum Marc-André Lureau
@ 2017-06-07 16:35 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test Marc-André Lureau
` (38 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Before the previous commit, parameter promote_int = true made
visit_start_alternate() with an input visitor avoid QTYPE_QINT
variants and create QTYPE_QFLOAT variants instead. This was used
where QTYPE_QINT variants were invalid.
The previous commit fused QTYPE_QINT with QTYPE_QFLOAT, rendering
promote_int useless and unused.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/qapi/visitor.h | 4 +---
include/qapi/visitor-impl.h | 2 +-
scripts/qapi-visit.py | 12 +++---------
qapi/qapi-visit-core.c | 6 +++---
qapi/qapi-clone-visitor.c | 2 +-
qapi/qapi-dealloc-visitor.c | 2 +-
qapi/qobject-input-visitor.c | 2 +-
tests/test-qobject-input-visitor.c | 2 +-
qapi/trace-events | 2 +-
9 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h
index 4721c39ae3..74768aabda 100644
--- a/include/qapi/visitor.h
+++ b/include/qapi/visitor.h
@@ -410,15 +410,13 @@ void visit_end_list(Visitor *v, void **list);
* the qtype of the next thing to be visited, stored in (*@obj)->type.
* Other visitors will leave @obj unchanged.
*
- * If @promote_int, treat integers as QTYPE_FLOAT.
- *
* If successful, this must be paired with visit_end_alternate() with
* the same @obj to clean up, even if visiting the contents of the
* alternate fails.
*/
void visit_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp);
+ Error **errp);
/*
* Finish visiting an alternate type.
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index e87709db5c..dcd656ab76 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -71,7 +71,7 @@ struct Visitor
* optional for output visitors. */
void (*start_alternate)(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp);
+ Error **errp);
/* Optional, needed for dealloc visitor */
void (*end_alternate)(Visitor *v, void **obj);
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index cc447ecacc..bd0b742236 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -161,20 +161,14 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error
def gen_visit_alternate(name, variants):
- promote_int = 'true'
- ret = ''
- for var in variants.variants:
- if var.type.alternate_qtype() == 'QTYPE_QNUM':
- promote_int = 'false'
-
- ret += mcgen('''
+ ret = mcgen('''
void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp)
{
Error *err = NULL;
visit_start_alternate(v, name, (GenericAlternate **)obj, sizeof(**obj),
- %(promote_int)s, &err);
+ &err);
if (err) {
goto out;
}
@@ -183,7 +177,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
}
switch ((*obj)->type) {
''',
- c_name=c_name(name), promote_int=promote_int)
+ c_name=c_name(name))
for var in variants.variants:
ret += mcgen('''
diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 43a09d147d..935a2c5bc9 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -106,15 +106,15 @@ void visit_end_list(Visitor *v, void **obj)
void visit_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp)
+ Error **errp)
{
Error *err = NULL;
assert(obj && size >= sizeof(GenericAlternate));
assert(!(v->type & VISITOR_OUTPUT) || *obj);
- trace_visit_start_alternate(v, name, obj, size, promote_int);
+ trace_visit_start_alternate(v, name, obj, size);
if (v->start_alternate) {
- v->start_alternate(v, name, obj, size, promote_int, &err);
+ v->start_alternate(v, name, obj, size, &err);
}
if (v->type & VISITOR_INPUT) {
assert(v->start_alternate && !err != !*obj);
diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c
index de756bfb33..ed16d3a17f 100644
--- a/qapi/qapi-clone-visitor.c
+++ b/qapi/qapi-clone-visitor.c
@@ -70,7 +70,7 @@ static GenericList *qapi_clone_next_list(Visitor *v, GenericList *tail,
static void qapi_clone_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp)
+ Error **errp)
{
qapi_clone_start_struct(v, name, (void **)obj, size, errp);
}
diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index e39457bc79..fd6f9fb61c 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -38,7 +38,7 @@ static void qapi_dealloc_end_struct(Visitor *v, void **obj)
static void qapi_dealloc_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp)
+ Error **errp)
{
}
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index b24f99d698..539b3b825d 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -367,7 +367,7 @@ static void qobject_input_end_list(Visitor *v, void **obj)
static void qobject_input_start_alternate(Visitor *v, const char *name,
GenericAlternate **obj, size_t size,
- bool promote_int, Error **errp)
+ Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, false, errp);
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 9e3d4aa7e5..40a135db89 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -1103,7 +1103,7 @@ static void test_visitor_in_fail_struct_missing(TestInputVisitorData *data,
error_free_or_abort(&err);
visit_start_list(v, "list", NULL, 0, &err);
error_free_or_abort(&err);
- visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err);
+ visit_start_alternate(v, "alternate", &alt, sizeof(*alt), &err);
error_free_or_abort(&err);
visit_optional(v, "optional", &present);
g_assert(!present);
diff --git a/qapi/trace-events b/qapi/trace-events
index 339cacf0ad..3b57abaa37 100644
--- a/qapi/trace-events
+++ b/qapi/trace-events
@@ -11,7 +11,7 @@ visit_next_list(void *v, void *tail, size_t size) "v=%p tail=%p size=%zu"
visit_check_list(void *v) "v=%p"
visit_end_list(void *v, void *obj) "v=%p obj=%p"
-visit_start_alternate(void *v, const char *name, void *obj, size_t size, bool promote_int) "v=%p name=%s obj=%p size=%zu promote_int=%d"
+visit_start_alternate(void *v, const char *name, void *obj, size_t size) "v=%p name=%s obj=%p size=%zu"
visit_end_alternate(void *v, void *obj) "v=%p obj=%p"
visit_optional(void *v, const char *name, bool *present) "v=%p name=%s present=%p"
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (6 preceding siblings ...)
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 07/43] qapi: Remove visit_start_alternate() parameter promote_int Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 15:00 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 09/43] qnum: add uint type Marc-André Lureau
` (37 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
The tests aren't really useful, or already covered by other simple tests.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
tests/check-qdict.c | 9 ++-------
tests/check-qlist.c | 23 ++---------------------
tests/check-qnum.c | 18 ++----------------
tests/check-qstring.c | 9 ---------
4 files changed, 6 insertions(+), 53 deletions(-)
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index f067c63275..5eca1b5449 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -32,8 +32,7 @@ static void qdict_new_test(void)
g_assert(qdict->base.refcnt == 1);
g_assert(qobject_type(QOBJECT(qdict)) == QTYPE_QDICT);
- // destroy doesn't exit yet
- g_free(qdict);
+ QDECREF(qdict);
}
static void qdict_put_obj_test(void)
@@ -53,11 +52,7 @@ static void qdict_put_obj_test(void)
qn = qobject_to_qnum(ent->value);
g_assert_cmpint(qnum_get_int(qn), ==, num);
- // destroy doesn't exit yet
- QDECREF(qn);
- g_free(ent->key);
- g_free(ent);
- g_free(qdict);
+ QDECREF(qdict);
}
static void qdict_destroy_simple_test(void)
diff --git a/tests/check-qlist.c b/tests/check-qlist.c
index a9b65c6239..894e9915e5 100644
--- a/tests/check-qlist.c
+++ b/tests/check-qlist.c
@@ -30,8 +30,7 @@ static void qlist_new_test(void)
g_assert(qlist->base.refcnt == 1);
g_assert(qobject_type(QOBJECT(qlist)) == QTYPE_QLIST);
- // destroy doesn't exist yet
- g_free(qlist);
+ QDECREF(qlist);
}
static void qlist_append_test(void)
@@ -49,10 +48,7 @@ static void qlist_append_test(void)
g_assert(entry != NULL);
g_assert(entry->value == QOBJECT(qi));
- // destroy doesn't exist yet
- QDECREF(qi);
- g_free(entry);
- g_free(qlist);
+ QDECREF(qlist);
}
static void qobject_to_qlist_test(void)
@@ -63,20 +59,6 @@ static void qobject_to_qlist_test(void)
g_assert(qobject_to_qlist(QOBJECT(qlist)) == qlist);
- // destroy doesn't exist yet
- g_free(qlist);
-}
-
-static void qlist_destroy_test(void)
-{
- int i;
- QList *qlist;
-
- qlist = qlist_new();
-
- for (i = 0; i < 42; i++)
- qlist_append_int(qlist, i);
-
QDECREF(qlist);
}
@@ -125,7 +107,6 @@ int main(int argc, char **argv)
g_test_add_func("/public/new", qlist_new_test);
g_test_add_func("/public/append", qlist_append_test);
g_test_add_func("/public/to_qlist", qobject_to_qlist_test);
- g_test_add_func("/public/destroy", qlist_destroy_test);
g_test_add_func("/public/iter", qlist_iter_test);
return g_test_run();
diff --git a/tests/check-qnum.c b/tests/check-qnum.c
index d94cea024b..da7e0b0a9a 100644
--- a/tests/check-qnum.c
+++ b/tests/check-qnum.c
@@ -36,8 +36,7 @@ static void qnum_from_int_test(void)
g_assert_cmpint(qn->base.refcnt, ==, 1);
g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
- // destroy doesn't exit yet
- g_free(qn);
+ QDECREF(qn);
}
static void qnum_from_double_test(void)
@@ -52,8 +51,7 @@ static void qnum_from_double_test(void)
g_assert_cmpint(qn->base.refcnt, ==, 1);
g_assert_cmpint(qobject_type(QOBJECT(qn)), ==, QTYPE_QNUM);
- // destroy doesn't exit yet
- g_free(qn);
+ QDECREF(qn);
}
static void qnum_from_int64_test(void)
@@ -109,24 +107,12 @@ static void qnum_to_string_test(void)
QDECREF(qn);
}
-static void qnum_destroy_test(void)
-{
- QNum *qn;
-
- qn = qnum_from_int(0);
- QDECREF(qn);
-
- qn = qnum_from_double(0.42);
- QDECREF(qn);
-}
-
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
g_test_add_func("/qnum/from_int", qnum_from_int_test);
g_test_add_func("/qnum/from_double", qnum_from_double_test);
- g_test_add_func("/qnum/destroy", qnum_destroy_test);
g_test_add_func("/qnum/from_int64", qnum_from_int64_test);
g_test_add_func("/qnum/get_int", qnum_get_int_test);
g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test);
diff --git a/tests/check-qstring.c b/tests/check-qstring.c
index 239e9d9da3..112ec08967 100644
--- a/tests/check-qstring.c
+++ b/tests/check-qstring.c
@@ -31,14 +31,6 @@ static void qstring_from_str_test(void)
g_assert(strcmp(str, qstring->string) == 0);
g_assert(qobject_type(QOBJECT(qstring)) == QTYPE_QSTRING);
- // destroy doesn't exit yet
- g_free(qstring->string);
- g_free(qstring);
-}
-
-static void qstring_destroy_test(void)
-{
- QString *qstring = qstring_from_str("destroy test");
QDECREF(qstring);
}
@@ -97,7 +89,6 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
g_test_add_func("/public/from_str", qstring_from_str_test);
- g_test_add_func("/public/destroy", qstring_destroy_test);
g_test_add_func("/public/get_str", qstring_get_str_test);
g_test_add_func("/public/append_chr", qstring_append_chr_test);
g_test_add_func("/public/from_substr", qstring_from_substr_test);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 09/43] qnum: add uint type
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (7 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers Marc-André Lureau
` (36 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
In order to store integer values between INT64_MAX and UINT64_MAX, add
a uint64_t internal representation.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/qapi/qmp/qnum.h | 7 ++++++
qobject/qnum.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/check-qnum.c | 48 +++++++++++++++++++++++++++++++++++++
3 files changed, 119 insertions(+)
diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h
index e42b136141..09d745c490 100644
--- a/include/qapi/qmp/qnum.h
+++ b/include/qapi/qmp/qnum.h
@@ -19,6 +19,7 @@
typedef enum {
QNUM_I64,
+ QNUM_U64,
QNUM_DOUBLE
} QNumKind;
@@ -27,15 +28,21 @@ typedef struct QNum {
QNumKind kind;
union {
int64_t i64;
+ uint64_t u64;
double dbl;
} u;
} QNum;
QNum *qnum_from_int(int64_t value);
+QNum *qnum_from_uint(uint64_t value);
QNum *qnum_from_double(double value);
bool qnum_get_try_int(const QNum *qn, int64_t *val);
int64_t qnum_get_int(const QNum *qn);
+
+bool qnum_get_try_uint(const QNum *qn, uint64_t *val);
+uint64_t qnum_get_uint(const QNum *qn);
+
double qnum_get_double(QNum *qn);
char *qnum_to_string(QNum *qn);
diff --git a/qobject/qnum.c b/qobject/qnum.c
index d88e4f7a59..52918ac20e 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -35,6 +35,22 @@ QNum *qnum_from_int(int64_t value)
}
/**
+ * qnum_from_uint(): Create a new QNum from an uint64_t
+ *
+ * Return strong reference.
+ */
+QNum *qnum_from_uint(uint64_t value)
+{
+ QNum *qn = g_new(QNum, 1);
+
+ qobject_init(QOBJECT(qn), QTYPE_QNUM);
+ qn->kind = QNUM_U64;
+ qn->u.u64 = value;
+
+ return qn;
+}
+
+/**
* qnum_from_double(): Create a new QNum from a double
*
* Return strong reference.
@@ -61,6 +77,12 @@ bool qnum_get_try_int(const QNum *qn, int64_t *val)
case QNUM_I64:
*val = qn->u.i64;
return true;
+ case QNUM_U64:
+ if (qn->u.u64 > INT64_MAX) {
+ return false;
+ }
+ *val = qn->u.u64;
+ return true;
case QNUM_DOUBLE:
return false;
}
@@ -83,6 +105,44 @@ int64_t qnum_get_int(const QNum *qn)
}
/**
+ * qnum_get_uint(): Get an unsigned integer from the number
+ *
+ * Return true on success.
+ */
+bool qnum_get_try_uint(const QNum *qn, uint64_t *val)
+{
+ switch (qn->kind) {
+ case QNUM_I64:
+ if (qn->u.i64 < 0) {
+ return false;
+ }
+ *val = qn->u.i64;
+ return true;
+ case QNUM_U64:
+ *val = qn->u.u64;
+ return true;
+ case QNUM_DOUBLE:
+ return false;
+ }
+
+ assert(0);
+ return false;
+}
+
+/**
+ * qnum_get_uint(): Get an unsigned integer from the number
+ *
+ * assert() on failure.
+ */
+uint64_t qnum_get_uint(const QNum *qn)
+{
+ uint64_t val;
+ bool success = qnum_get_try_uint(qn, &val);
+ assert(success);
+ return val;
+}
+
+/**
* qnum_get_double(): Get a float representation of the number
*
* qnum_get_double() loses precision for integers beyond 53 bits.
@@ -92,6 +152,8 @@ double qnum_get_double(QNum *qn)
switch (qn->kind) {
case QNUM_I64:
return qn->u.i64;
+ case QNUM_U64:
+ return qn->u.u64;
case QNUM_DOUBLE:
return qn->u.dbl;
}
@@ -107,6 +169,8 @@ char *qnum_to_string(QNum *qn)
switch (qn->kind) {
case QNUM_I64:
return g_strdup_printf("%" PRId64, qn->u.i64);
+ case QNUM_U64:
+ return g_strdup_printf("%" PRIu64, qn->u.u64);
case QNUM_DOUBLE:
/* FIXME: snprintf() is locale dependent; but JSON requires
* numbers to be formatted as if in the C locale. Dependence
diff --git a/tests/check-qnum.c b/tests/check-qnum.c
index da7e0b0a9a..d702d5da9c 100644
--- a/tests/check-qnum.c
+++ b/tests/check-qnum.c
@@ -39,6 +39,21 @@ static void qnum_from_int_test(void)
QDECREF(qn);
}
+static void qnum_from_uint_test(void)
+{
+ QNum *qn;
+ const uint64_t value = UINT64_MAX;
+
+ qn = qnum_from_uint(value);
+ g_assert(qn != NULL);
+ g_assert_cmpint(qn->kind, ==, QNUM_U64);
+ g_assert(qn->u.u64 == value);
+ g_assert(qn->base.refcnt == 1);
+ g_assert(qobject_type(QOBJECT(qn)) == QTYPE_QNUM);
+
+ QDECREF(qn);
+}
+
static void qnum_from_double_test(void)
{
QNum *qn;
@@ -76,6 +91,37 @@ static void qnum_get_int_test(void)
QDECREF(qn);
}
+static void qnum_get_uint_test(void)
+{
+ QNum *qn;
+ const int value = 123456;
+ uint64_t val;
+ int64_t ival;
+
+ qn = qnum_from_uint(value);
+ g_assert(qnum_get_try_uint(qn, &val));
+ g_assert_cmpuint(val, ==, value);
+ QDECREF(qn);
+
+ qn = qnum_from_int(value);
+ g_assert(qnum_get_try_uint(qn, &val));
+ g_assert_cmpuint(val, ==, value);
+ QDECREF(qn);
+
+ /* invalid cases */
+ qn = qnum_from_int(-1);
+ g_assert(!qnum_get_try_uint(qn, &val));
+ QDECREF(qn);
+
+ qn = qnum_from_uint(-1ULL);
+ g_assert(!qnum_get_try_int(qn, &ival));
+ QDECREF(qn);
+
+ qn = qnum_from_double(0.42);
+ g_assert(!qnum_get_try_uint(qn, &val));
+ QDECREF(qn);
+}
+
static void qobject_to_qnum_test(void)
{
QNum *qn;
@@ -112,9 +158,11 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
g_test_add_func("/qnum/from_int", qnum_from_int_test);
+ g_test_add_func("/qnum/from_uint", qnum_from_uint_test);
g_test_add_func("/qnum/from_double", qnum_from_double_test);
g_test_add_func("/qnum/from_int64", qnum_from_int64_test);
g_test_add_func("/qnum/get_int", qnum_get_int_test);
+ g_test_add_func("/qnum/get_uint", qnum_get_uint_test);
g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test);
g_test_add_func("/qnum/to_string", qnum_to_string_test);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (8 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 09/43] qnum: add uint type Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 16:27 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64 Marc-André Lureau
` (35 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Switch strtoll() usage to qemu_strtoi64() helper while at it.
Add a few tests for large numbers.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
qobject/json-lexer.c | 4 ++++
qobject/json-parser.c | 36 ++++++++++++++++++++++++++++--------
tests/check-qjson.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 8 deletions(-)
diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c
index af4a75e05b..980ba159d6 100644
--- a/qobject/json-lexer.c
+++ b/qobject/json-lexer.c
@@ -227,15 +227,18 @@ static const uint8_t json_lexer[][256] = {
/* escape */
[IN_ESCAPE_LL] = {
['d'] = JSON_ESCAPE,
+ ['u'] = JSON_ESCAPE,
},
[IN_ESCAPE_L] = {
['d'] = JSON_ESCAPE,
['l'] = IN_ESCAPE_LL,
+ ['u'] = JSON_ESCAPE,
},
[IN_ESCAPE_I64] = {
['d'] = JSON_ESCAPE,
+ ['u'] = JSON_ESCAPE,
},
[IN_ESCAPE_I6] = {
@@ -251,6 +254,7 @@ static const uint8_t json_lexer[][256] = {
['i'] = JSON_ESCAPE,
['p'] = JSON_ESCAPE,
['s'] = JSON_ESCAPE,
+ ['u'] = JSON_ESCAPE,
['f'] = JSON_ESCAPE,
['l'] = IN_ESCAPE_L,
['I'] = IN_ESCAPE_I,
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 5e808289f5..7a417f20cd 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "qapi/error.h"
#include "qemu-common.h"
#include "qapi/qmp/types.h"
@@ -472,6 +473,13 @@ static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap)
} else if (!strcmp(token->str, "%lld") ||
!strcmp(token->str, "%I64d")) {
return QOBJECT(qnum_from_int(va_arg(*ap, long long)));
+ } else if (!strcmp(token->str, "%u")) {
+ return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned int)));
+ } else if (!strcmp(token->str, "%lu")) {
+ return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned long)));
+ } else if (!strcmp(token->str, "%llu") ||
+ !strcmp(token->str, "%I64u")) {
+ return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned long long)));
} else if (!strcmp(token->str, "%s")) {
return QOBJECT(qstring_from_str(va_arg(*ap, const char *)));
} else if (!strcmp(token->str, "%f")) {
@@ -493,21 +501,33 @@ static QObject *parse_literal(JSONParserContext *ctxt)
case JSON_INTEGER: {
/*
* Represent JSON_INTEGER as QNUM_I64 if possible, else as
- * QNUM_DOUBLE. Note that strtoll() fails with ERANGE when
- * it's not possible.
+ * QNUM_U64, else as QNUM_DOUBLE. Note that qemu_strtoi64()
+ * and qemu_strtou64() fail with ERANGE when it's not
+ * possible.
*
* qnum_get_int() will then work for any signed 64-bit
- * JSON_INTEGER, and qnum_get_double() both for any
- * JSON_INTEGER and any JSON_FLOAT (with precision loss for
- * integers beyond 53 bits)
+ * JSON_INTEGER, qnum_get_uint() for any unsigned 64-bit
+ * integer, and qnum_get_double() both for any JSON_INTEGER
+ * and any JSON_FLOAT (with precision loss for integers beyond
+ * 53 bits)
*/
+ int ret;
int64_t value;
+ uint64_t uvalue;
- errno = 0; /* strtoll doesn't set errno on success */
- value = strtoll(token->str, NULL, 10);
- if (errno != ERANGE) {
+ ret = qemu_strtoi64(token->str, NULL, 10, &value);
+ if (!ret) {
return QOBJECT(qnum_from_int(value));
}
+ assert(ret == -ERANGE);
+
+ if (token->str[0] != '-') {
+ ret = qemu_strtou64(token->str, NULL, 10, &uvalue);
+ if (!ret) {
+ return QOBJECT(qnum_from_uint(uvalue));
+ }
+ assert(ret == -ERANGE);
+ }
/* fall through to JSON_FLOAT */
}
case JSON_FLOAT:
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index f0a89f7847..53f2275b9b 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -906,6 +906,49 @@ static void simple_number(void)
}
}
+static void large_number(void)
+{
+ const char *maxu64 = "18446744073709551615"; /* 2^64-1 */
+ const char *gtu64 = "18446744073709551616"; /* 2^64 */
+ const char *lti64 = "-9223372036854775809"; /* -2^63 - 1 */
+ QNum *qnum;
+ QString *str;
+ uint64_t val;
+ int64_t ival;
+
+ qnum = qobject_to_qnum(qobject_from_json(maxu64, &error_abort));
+ g_assert(qnum);
+ g_assert_cmpuint(qnum_get_uint(qnum), ==, 18446744073709551615U);
+ g_assert(!qnum_get_try_int(qnum, &ival));
+
+ str = qobject_to_json(QOBJECT(qnum));
+ g_assert_cmpstr(qstring_get_str(str), ==, maxu64);
+ QDECREF(str);
+ QDECREF(qnum);
+
+ qnum = qobject_to_qnum(qobject_from_json(gtu64, &error_abort));
+ g_assert(qnum);
+ g_assert_cmpfloat(qnum_get_double(qnum), ==, 18446744073709552e3);
+ g_assert(!qnum_get_try_uint(qnum, &val));
+ g_assert(!qnum_get_try_int(qnum, &ival));
+
+ str = qobject_to_json(QOBJECT(qnum));
+ g_assert_cmpstr(qstring_get_str(str), ==, gtu64);
+ QDECREF(str);
+ QDECREF(qnum);
+
+ qnum = qobject_to_qnum(qobject_from_json(lti64, &error_abort));
+ g_assert(qnum);
+ g_assert_cmpfloat(qnum_get_double(qnum), ==, -92233720368547758e2);
+ g_assert(!qnum_get_try_uint(qnum, &val));
+ g_assert(!qnum_get_try_int(qnum, &ival));
+
+ str = qobject_to_json(QOBJECT(qnum));
+ g_assert_cmpstr(qstring_get_str(str), ==, "-9223372036854775808");
+ QDECREF(str);
+ QDECREF(qnum);
+}
+
static void float_number(void)
{
int i;
@@ -1475,6 +1518,7 @@ int main(int argc, char **argv)
g_test_add_func("/literals/string/vararg", vararg_string);
g_test_add_func("/literals/number/simple", simple_number);
+ g_test_add_func("/literals/number/large", large_number);
g_test_add_func("/literals/number/float", float_number);
g_test_add_func("/literals/number/vararg", vararg_number);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (9 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 16:36 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 12/43] object: add uint property setter/getter Marc-André Lureau
` (34 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Switch to use QNum/uint where appropriate to remove i64 limitation.
The input visitor will cast i64 input to u64 for compatibility
reasons (existing json QMP client already use negative i64 for large
u64, and expect an implicit cast in qemu).
Note: before the patch, uint64_t values above INT64_MAX are sent over
json QMP as negative values, e.g. UINT64_MAX is sent as -1. After the
patch, they are sent unmodified. Clearly a bug fix, but we have to
consider compatibility issues anyway. libvirt should cope fine,
because its parsing of unsigned integers accepts negative values
modulo 2^64. There's hope that other clients will, too.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
hw/i386/acpi-build.c | 2 +-
qapi/qobject-input-visitor.c | 21 ++++++++++++++++-----
qapi/qobject-output-visitor.c | 3 +--
tests/test-qobject-input-visitor.c | 7 ++-----
tests/test-qobject-output-visitor.c | 20 ++++++++++++++++----
5 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d7d2b65fe4..3eb43677f0 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2614,7 +2614,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
if (!o) {
return false;
}
- mcfg->mcfg_base = qnum_get_int(qobject_to_qnum(o));
+ mcfg->mcfg_base = qnum_get_uint(qobject_to_qnum(o));
qobject_decref(o);
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 539b3b825d..35aff78f2b 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -417,7 +417,6 @@ static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
static void qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
- /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QNum *qnum;
@@ -427,11 +426,23 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
return;
}
qnum = qobject_to_qnum(qobj);
- if (!qnum || !qnum_get_try_int(qnum, &val)) {
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
- full_name(qiv, name), "integer");
+ if (!qnum) {
+ goto err;
+ }
+
+ if (qnum_get_try_uint(qnum, obj)) {
+ return;
}
- *obj = val;
+
+ /* Need to accept negative values for backward compatibility */
+ if (qnum_get_try_int(qnum, &val)) {
+ *obj = val;
+ return;
+ }
+
+err:
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ full_name(qiv, name), "uint64");
}
static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,
diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c
index 2ca5093b22..70be84ccb5 100644
--- a/qapi/qobject-output-visitor.c
+++ b/qapi/qobject-output-visitor.c
@@ -150,9 +150,8 @@ static void qobject_output_type_int64(Visitor *v, const char *name,
static void qobject_output_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
- /* FIXME values larger than INT64_MAX become negative */
QObjectOutputVisitor *qov = to_qov(v);
- qobject_output_add(qov, name, qnum_from_int(*obj));
+ qobject_output_add(qov, name, qnum_from_uint(*obj));
}
static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 40a135db89..3bcdb9a045 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -123,7 +123,6 @@ static void test_visitor_in_int(TestInputVisitorData *data,
static void test_visitor_in_uint(TestInputVisitorData *data,
const void *unused)
{
- Error *err = NULL;
uint64_t res = 0;
int64_t i64;
double dbl;
@@ -147,12 +146,10 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
visit_type_uint64(v, NULL, &res, &error_abort);
g_assert_cmpuint(res, ==, (uint64_t)-value);
- /* BUG: value between INT64_MAX+1 and UINT64_MAX rejected */
-
v = visitor_input_test_init(data, "18446744073709551574");
- visit_type_uint64(v, NULL, &res, &err);
- error_free_or_abort(&err);
+ visit_type_uint64(v, NULL, &res, &error_abort);
+ g_assert_cmpuint(res, ==, 18446744073709551574U);
visit_type_number(v, NULL, &dbl, &error_abort);
}
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index a16c8f663f..d23c8eb352 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -602,14 +602,26 @@ static void check_native_list(QObject *qobj,
qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data")));
switch (kind) {
- case USER_DEF_NATIVE_LIST_UNION_KIND_S8:
- case USER_DEF_NATIVE_LIST_UNION_KIND_S16:
- case USER_DEF_NATIVE_LIST_UNION_KIND_S32:
- case USER_DEF_NATIVE_LIST_UNION_KIND_S64:
case USER_DEF_NATIVE_LIST_UNION_KIND_U8:
case USER_DEF_NATIVE_LIST_UNION_KIND_U16:
case USER_DEF_NATIVE_LIST_UNION_KIND_U32:
case USER_DEF_NATIVE_LIST_UNION_KIND_U64:
+ for (i = 0; i < 32; i++) {
+ QObject *tmp;
+ QNum *qvalue;
+
+ tmp = qlist_peek(qlist);
+ g_assert(tmp);
+ qvalue = qobject_to_qnum(tmp);
+ g_assert_cmpuint(qnum_get_uint(qvalue), ==, i);
+ qobject_decref(qlist_pop(qlist));
+ }
+ break;
+
+ case USER_DEF_NATIVE_LIST_UNION_KIND_S8:
+ case USER_DEF_NATIVE_LIST_UNION_KIND_S16:
+ case USER_DEF_NATIVE_LIST_UNION_KIND_S32:
+ case USER_DEF_NATIVE_LIST_UNION_KIND_S64:
/*
* All integer elements in JSON arrays get stored into QNums
* when we convert to QObjects, so we can check them all in
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 12/43] object: add uint property setter/getter
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (10 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64 Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 13/43] q35: fix get_mmcfg_size to use uint64 visitor Marc-André Lureau
` (33 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/qom/object.h | 23 +++++++++++++++++++++++
qom/object.c | 29 +++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index cd0f412ce9..abaeb8cf4e 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1094,6 +1094,29 @@ int64_t object_property_get_int(Object *obj, const char *name,
Error **errp);
/**
+ * object_property_set_uint:
+ * @value: the value to be written to the property
+ * @name: the name of the property
+ * @errp: returns an error if this function fails
+ *
+ * Writes an unsigned integer value to a property.
+ */
+void object_property_set_uint(Object *obj, uint64_t value,
+ const char *name, Error **errp);
+
+/**
+ * object_property_get_uint:
+ * @obj: the object
+ * @name: the name of the property
+ * @errp: returns an error if this function fails
+ *
+ * Returns: the value of the property, converted to an unsigned integer, or 0
+ * an error occurs (including when the property value is not an integer).
+ */
+uint64_t object_property_get_uint(Object *obj, const char *name,
+ Error **errp);
+
+/**
* object_property_get_enum:
* @obj: the object
* @name: the name of the property
diff --git a/qom/object.c b/qom/object.c
index dee7f7c1eb..5f6fdfa6e6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1216,6 +1216,35 @@ int64_t object_property_get_int(Object *obj, const char *name,
return retval;
}
+void object_property_set_uint(Object *obj, uint64_t value,
+ const char *name, Error **errp)
+{
+ QNum *qnum = qnum_from_uint(value);
+
+ object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
+ QDECREF(qnum);
+}
+
+uint64_t object_property_get_uint(Object *obj, const char *name,
+ Error **errp)
+{
+ QObject *ret = object_property_get_qobject(obj, name, errp);
+ QNum *qnum;
+ uint64_t retval;
+
+ if (!ret) {
+ return 0;
+ }
+ qnum = qobject_to_qnum(ret);
+ if (!qnum || !qnum_get_try_uint(qnum, &retval)) {
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint");
+ retval = 0;
+ }
+
+ qobject_decref(ret);
+ return retval;
+}
+
typedef struct EnumProperty {
const char * const *strings;
int (*get)(Object *, Error **);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 13/43] q35: fix get_mmcfg_size to use uint64 visitor
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (11 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 12/43] object: add uint property setter/getter Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 14/43] object: use more specific property type names Marc-André Lureau
` (32 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
e->size is hwaddr, i.e. uint64_t. We silently truncate.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
hw/pci-host/q35.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index cd5c49616e..e8a04d31d1 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -129,9 +129,8 @@ static void q35_host_get_mmcfg_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
PCIExpressHost *e = PCIE_HOST_BRIDGE(obj);
- uint32_t value = e->size;
- visit_type_uint32(v, name, &value, errp);
+ visit_type_uint64(v, name, &e->size, errp);
}
static Property mch_props[] = {
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 14/43] object: use more specific property type names
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (12 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 13/43] q35: fix get_mmcfg_size to use uint64 visitor Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED() Marc-André Lureau
` (31 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Use the actual unsigned integer type name.
The type name change impacts the following externally visible area:
* vl.c's machine_help_func() puts it in help for -machine NAME,help.
* QMP command qom-list exposes it in ObjectPropertyInfo member @type.
* QMP command device-list-properties exposes it in DevicePropertyInfo
member @type.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
backends/cryptodev.c | 2 +-
hw/pci-host/piix.c | 8 ++++----
hw/pci-host/q35.c | 10 +++++-----
hw/ppc/pnv.c | 2 +-
net/dump.c | 2 +-
net/filter-buffer.c | 2 +-
6 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index 832f056266..1764c179fe 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -222,7 +222,7 @@ cryptodev_backend_can_be_deleted(UserCreatable *uc, Error **errp)
static void cryptodev_backend_instance_init(Object *obj)
{
- object_property_add(obj, "queues", "int",
+ object_property_add(obj, "queues", "uint32",
cryptodev_backend_get_queues,
cryptodev_backend_set_queues,
NULL, NULL, NULL);
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 4ce201ea65..a2c1033dbe 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -273,19 +273,19 @@ static void i440fx_pcihost_initfn(Object *obj)
memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s,
"pci-conf-data", 4);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
i440fx_pcihost_get_pci_hole_start,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
i440fx_pcihost_get_pci_hole_end,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
i440fx_pcihost_get_pci_hole64_start,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
i440fx_pcihost_get_pci_hole64_end,
NULL, NULL, NULL, NULL);
}
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index e8a04d31d1..c2f2af5d9a 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -175,23 +175,23 @@ static void q35_host_initfn(Object *obj)
qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
q35_host_get_pci_hole_start,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32",
q35_host_get_pci_hole_end,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
q35_host_get_pci_hole64_start,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int",
+ object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
q35_host_get_pci_hole64_end,
NULL, NULL, NULL, NULL);
- object_property_add(obj, PCIE_HOST_MCFG_SIZE, "int",
+ object_property_add(obj, PCIE_HOST_MCFG_SIZE, "uint64",
q35_host_get_mmcfg_size,
NULL, NULL, NULL, NULL);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 89b6801f67..a4cd733cba 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1111,7 +1111,7 @@ static void powernv_machine_initfn(Object *obj)
static void powernv_machine_class_props_init(ObjectClass *oc)
{
- object_class_property_add(oc, "num-chips", "uint32_t",
+ object_class_property_add(oc, "num-chips", "uint32",
pnv_get_num_chips, pnv_set_num_chips,
NULL, NULL, NULL);
object_class_property_set_description(oc, "num-chips",
diff --git a/net/dump.c b/net/dump.c
index 442eb532f9..15df9a4973 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -328,7 +328,7 @@ static void filter_dump_instance_init(Object *obj)
nfds->maxlen = 65536;
- object_property_add(obj, "maxlen", "int", filter_dump_get_maxlen,
+ object_property_add(obj, "maxlen", "uint32", filter_dump_get_maxlen,
filter_dump_set_maxlen, NULL, NULL, NULL);
object_property_add_str(obj, "file", file_dump_get_filename,
file_dump_set_filename, NULL);
diff --git a/net/filter-buffer.c b/net/filter-buffer.c
index cc6bd94445..9ce96aaa35 100644
--- a/net/filter-buffer.c
+++ b/net/filter-buffer.c
@@ -191,7 +191,7 @@ out:
static void filter_buffer_init(Object *obj)
{
- object_property_add(obj, "interval", "int",
+ object_property_add(obj, "interval", "uint32",
filter_buffer_get_interval,
filter_buffer_set_interval, NULL, NULL, NULL);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (13 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 14/43] object: use more specific property type names Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 16:42 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union Marc-André Lureau
` (30 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Prepare for the next patch's DEFINE_PROP_UNSIGNED().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/qdev-properties.h | 26 +++++++++++++-------------
hw/block/fdc.c | 18 +++++++++---------
hw/net/e1000e.c | 6 +++---
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 85e68998a9..05603805cb 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -37,7 +37,7 @@ extern PropertyInfo qdev_prop_arraylen;
.offset = offsetof(_state, _field) \
+ type_check(_type, typeof_field(_state, _field)), \
}
-#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
+#define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) { \
.name = (_name), \
.info = &(_prop), \
.offset = offsetof(_state, _field) \
@@ -107,19 +107,19 @@ extern PropertyInfo qdev_prop_arraylen;
}
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
#define DEFINE_PROP_INT32(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
#define DEFINE_PROP_SIZE(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_size, uint64_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
/*
* Please avoid pointer properties. If you must use them, you must
@@ -153,17 +153,17 @@ extern PropertyInfo qdev_prop_arraylen;
#define DEFINE_PROP_MACADDR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
#define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto)
#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
LostTickPolicy)
#define DEFINE_PROP_BLOCKDEV_ON_ERROR(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \
BlockdevOnError)
#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
+ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \
- DEFINE_PROP_DEFAULT(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
+ DEFINE_PROP_SIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 2e629b398b..28f6b6ee35 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -511,7 +511,7 @@ typedef struct FloppyDrive {
static Property floppy_drive_properties[] = {
DEFINE_PROP_UINT32("unit", FloppyDrive, unit, -1),
DEFINE_BLOCK_PROPERTIES(FloppyDrive, conf),
- DEFINE_PROP_DEFAULT("drive-type", FloppyDrive, type,
+ DEFINE_PROP_SIGNED("drive-type", FloppyDrive, type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
@@ -2805,13 +2805,13 @@ static Property isa_fdc_properties[] = {
DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.qdev_for_drives[1].blk),
DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate,
0, true),
- DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].type,
+ DEFINE_PROP_SIGNED("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
- DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type,
+ DEFINE_PROP_SIGNED("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
- DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ DEFINE_PROP_SIGNED("fallback", FDCtrlISABus, state.fallback,
FLOPPY_DRIVE_TYPE_288, qdev_prop_fdc_drive_type,
FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
@@ -2862,13 +2862,13 @@ static const VMStateDescription vmstate_sysbus_fdc ={
static Property sysbus_fdc_properties[] = {
DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.qdev_for_drives[0].blk),
DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.qdev_for_drives[1].blk),
- DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type,
+ DEFINE_PROP_SIGNED("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
- DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type,
+ DEFINE_PROP_SIGNED("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
- DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ DEFINE_PROP_SIGNED("fallback", FDCtrlISABus, state.fallback,
FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
@@ -2891,10 +2891,10 @@ static const TypeInfo sysbus_fdc_info = {
static Property sun4m_fdc_properties[] = {
DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.qdev_for_drives[0].blk),
- DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type,
+ DEFINE_PROP_SIGNED("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type,
FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
FloppyDriveType),
- DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback,
+ DEFINE_PROP_SIGNED("fallback", FDCtrlISABus, state.fallback,
FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type,
FloppyDriveType),
DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
index 6e234938db..0e0a1dc888 100644
--- a/hw/net/e1000e.c
+++ b/hw/net/e1000e.c
@@ -645,12 +645,12 @@ static PropertyInfo e1000e_prop_disable_vnet,
static Property e1000e_properties[] = {
DEFINE_NIC_PROPERTIES(E1000EState, conf),
- DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, false,
+ DEFINE_PROP_SIGNED("disable_vnet_hdr", E1000EState, disable_vnet, false,
e1000e_prop_disable_vnet, bool),
- DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
+ DEFINE_PROP_SIGNED("subsys_ven", E1000EState, subsys_ven,
PCI_VENDOR_ID_INTEL,
e1000e_prop_subsys_ven, uint16_t),
- DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
+ DEFINE_PROP_SIGNED("subsys", E1000EState, subsys, 0,
e1000e_prop_subsys, uint16_t),
DEFINE_PROP_END_OF_LIST(),
};
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (14 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED() Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 17:01 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned Marc-André Lureau
` (29 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Wrap the Property default value (an int64_t) in a union, to prepare
for the next patch adding a uint64_t.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/qdev-core.h | 4 +++-
include/hw/qdev-properties.h | 8 ++++----
hw/core/qdev-properties.c | 6 +++---
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 9523339762..784971b8d8 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -226,7 +226,9 @@ struct Property {
PropertyInfo *info;
ptrdiff_t offset;
uint8_t bitnr;
- int64_t defval;
+ union {
+ int64_t i;
+ } defval;
int arrayoffset;
PropertyInfo *arrayinfo;
int arrayfieldsize;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 05603805cb..34524d0bfe 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -42,7 +42,7 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(_prop), \
.offset = offsetof(_state, _field) \
+ type_check(_type,typeof_field(_state, _field)), \
- .defval = (_type)_defval, \
+ .defval.i = (_type)_defval, \
}
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
.name = (_name), \
@@ -50,7 +50,7 @@ extern PropertyInfo qdev_prop_arraylen;
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint32_t,typeof_field(_state, _field)), \
- .defval = (bool)_defval, \
+ .defval.i = (bool)_defval, \
}
#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
.name = (_name), \
@@ -58,7 +58,7 @@ extern PropertyInfo qdev_prop_arraylen;
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint64_t, typeof_field(_state, _field)), \
- .defval = (bool)_defval, \
+ .defval.i = (bool)_defval, \
}
#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \
@@ -66,7 +66,7 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(qdev_prop_bool), \
.offset = offsetof(_state, _field) \
+ type_check(bool, typeof_field(_state, _field)), \
- .defval = (bool)_defval, \
+ .defval.i = (bool)_defval, \
}
#define PROP_ARRAY_LEN_PREFIX "len-"
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index c5e028a45e..f3f682c611 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_default_value_enum(Object *obj, const Property *prop)
{
- object_property_set_str(obj, prop->info->enum_table[prop->defval],
+ object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
prop->name, &error_abort);
}
@@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
static void set_default_value_bool(Object *obj, const Property *prop)
{
- object_property_set_bool(obj, prop->defval, prop->name, &error_abort);
+ object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort);
}
PropertyInfo qdev_prop_bit = {
@@ -261,7 +261,7 @@ static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_default_value_int(Object *obj, const Property *prop)
{
- object_property_set_int(obj, prop->defval, prop->name, &error_abort);
+ object_property_set_int(obj, prop->defval.i, prop->name, &error_abort);
}
PropertyInfo qdev_prop_uint8 = {
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (15 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 17:08 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32 Marc-André Lureau
` (28 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Modify the unsigned type for various properties to use QNUM_U64, to
avoid type casts.
There are a few empty lines added to improve code reading/style.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/qdev-core.h | 1 +
include/hw/qdev-properties.h | 29 ++++++++++++++++++++---------
hw/core/qdev-properties.c | 23 ++++++++++++++---------
3 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 784971b8d8..9d7c1c0e9b 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -228,6 +228,7 @@ struct Property {
uint8_t bitnr;
union {
int64_t i;
+ uint64_t u;
} defval;
int arrayoffset;
PropertyInfo *arrayinfo;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 34524d0bfe..1e5c928f32 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -37,6 +37,7 @@ extern PropertyInfo qdev_prop_arraylen;
.offset = offsetof(_state, _field) \
+ type_check(_type, typeof_field(_state, _field)), \
}
+
#define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) { \
.name = (_name), \
.info = &(_prop), \
@@ -44,21 +45,31 @@ extern PropertyInfo qdev_prop_arraylen;
+ type_check(_type,typeof_field(_state, _field)), \
.defval.i = (_type)_defval, \
}
+
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
.name = (_name), \
.info = &(qdev_prop_bit), \
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint32_t,typeof_field(_state, _field)), \
- .defval.i = (bool)_defval, \
+ .defval.u = (bool)_defval, \
+ }
+
+#define DEFINE_PROP_UNSIGNED(_name, _state, _field, _defval, _prop, _type) { \
+ .name = (_name), \
+ .info = &(_prop), \
+ .offset = offsetof(_state, _field) \
+ + type_check(_type, typeof_field(_state, _field)), \
+ .defval.u = (_type)_defval, \
}
+
#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
.name = (_name), \
.info = &(qdev_prop_bit64), \
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint64_t, typeof_field(_state, _field)), \
- .defval.i = (bool)_defval, \
+ .defval.u = (bool)_defval, \
}
#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \
@@ -66,7 +77,7 @@ extern PropertyInfo qdev_prop_arraylen;
.info = &(qdev_prop_bool), \
.offset = offsetof(_state, _field) \
+ type_check(bool, typeof_field(_state, _field)), \
- .defval.i = (bool)_defval, \
+ .defval.u = (bool)_defval, \
}
#define PROP_ARRAY_LEN_PREFIX "len-"
@@ -107,17 +118,17 @@ extern PropertyInfo qdev_prop_arraylen;
}
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
- DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
#define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
- DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
#define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
- DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
#define DEFINE_PROP_INT32(_n, _s, _f, _d) \
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
#define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
- DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
#define DEFINE_PROP_SIZE(_n, _s, _f, _d) \
- DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
@@ -163,7 +174,7 @@ extern PropertyInfo qdev_prop_arraylen;
#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \
- DEFINE_PROP_SIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index f3f682c611..a8f09c13e2 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_default_value_enum(Object *obj, const Property *prop)
{
- object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
+ object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
prop->name, &error_abort);
}
@@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
static void set_default_value_bool(Object *obj, const Property *prop)
{
- object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort);
+ object_property_set_bool(obj, prop->defval.u, prop->name, &error_abort);
}
PropertyInfo qdev_prop_bit = {
@@ -264,11 +264,16 @@ 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_int,
+ .set_default_value = set_default_value_uint,
};
/* --- 16bit integer --- */
@@ -302,7 +307,7 @@ PropertyInfo qdev_prop_uint16 = {
.name = "uint16",
.get = get_uint16,
.set = set_uint16,
- .set_default_value = set_default_value_int,
+ .set_default_value = set_default_value_uint,
};
/* --- 32bit integer --- */
@@ -361,7 +366,7 @@ PropertyInfo qdev_prop_uint32 = {
.name = "uint32",
.get = get_uint32,
.set = set_uint32,
- .set_default_value = set_default_value_int,
+ .set_default_value = set_default_value_uint,
};
PropertyInfo qdev_prop_int32 = {
@@ -402,7 +407,7 @@ PropertyInfo qdev_prop_uint64 = {
.name = "uint64",
.get = get_uint64,
.set = set_uint64,
- .set_default_value = set_default_value_int,
+ .set_default_value = set_default_value_uint,
};
/* --- string --- */
@@ -725,7 +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_int,
+ .set_default_value = set_default_value_uint,
};
/* --- pci host address --- */
@@ -948,7 +953,7 @@ PropertyInfo qdev_prop_arraylen = {
.name = "uint32",
.get = get_uint32,
.set = set_prop_arraylen,
- .set_default_value = set_default_value_int,
+ .set_default_value = set_default_value_uint,
};
/* --- public helpers --- */
@@ -1185,5 +1190,5 @@ PropertyInfo qdev_prop_size = {
.name = "size",
.get = get_size,
.set = set_size,
- .set_default_value = set_default_value_int,
+ .set_default_value = set_default_value_uint,
};
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (16 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 16:39 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type Marc-André Lureau
` (27 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
The getter and setter of TYPE_APIC_COMMON property "id" are
apic_common_get_id() and apic_common_set_id().
apic_common_get_id() reads either APICCommonState member uint32_t
initial_apic_id or uint8_t id into an int64_t local variable. It then
passes this variable to visit_type_int().
apic_common_set_id() uses visit_type_int() to read the value into a
local variable, which it then assigns both to initial_apic_id and id.
While the state backing the property is two unsigned members, 8 and 32
bits wide, the actual visitor is 64 bits signed.
Change getter and setter to use visit_type_uint32(). Then everything's
uint32_t, except for @id.
Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/intc/apic_common.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 1ef56f8d10..e1ac33042f 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -450,10 +450,10 @@ static void apic_common_get_id(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
APICCommonState *s = APIC_COMMON(obj);
- int64_t value;
+ uint32_t value;
value = s->apicbase & MSR_IA32_APICBASE_EXTD ? s->initial_apic_id : s->id;
- visit_type_int(v, name, &value, errp);
+ visit_type_uint32(v, name, &value, errp);
}
static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
@@ -462,14 +462,14 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
APICCommonState *s = APIC_COMMON(obj);
DeviceState *dev = DEVICE(obj);
Error *local_err = NULL;
- int64_t value;
+ uint32_t value;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
- visit_type_int(v, name, &value, &local_err);
+ visit_type_uint32(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -484,7 +484,7 @@ static void apic_common_initfn(Object *obj)
APICCommonState *s = APIC_COMMON(obj);
s->id = s->initial_apic_id = -1;
- object_property_add(obj, "id", "int",
+ object_property_add(obj, "id", "uint32",
apic_common_get_id,
apic_common_set_id, NULL, NULL, NULL);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (17 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32 Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 17:23 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 20/43] isa: use get_uint() for "io-base" Marc-André Lureau
` (26 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Based on the underlying type of the data accessed, use the appropriate
getters/setters.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/acpi-build.c | 12 ++++++------
hw/pci-host/gpex.c | 2 +-
hw/pci-host/q35.c | 2 +-
hw/pci-host/xilinx-pcie.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3eb43677f0..b2dc3d8580 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -149,21 +149,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
/* Fill in optional s3/s4 related properties */
o = object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL);
if (o) {
- pm->s3_disabled = qnum_get_int(qobject_to_qnum(o));
+ pm->s3_disabled = qnum_get_uint(qobject_to_qnum(o));
} else {
pm->s3_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL);
if (o) {
- pm->s4_disabled = qnum_get_int(qobject_to_qnum(o));
+ pm->s4_disabled = qnum_get_uint(qobject_to_qnum(o));
} else {
pm->s4_disabled = false;
}
qobject_decref(o);
o = object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL);
if (o) {
- pm->s4_val = qnum_get_int(qobject_to_qnum(o));
+ pm->s4_val = qnum_get_uint(qobject_to_qnum(o));
} else {
pm->s4_val = false;
}
@@ -528,7 +528,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
if (bsel) {
- int64_t bsel_val = qnum_get_int(qobject_to_qnum(bsel));
+ uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel));
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
@@ -638,7 +638,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
/* If bus supports hotplug select it and notify about local events */
if (bsel) {
- int64_t bsel_val = qnum_get_int(qobject_to_qnum(bsel));
+ uint64_t bsel_val = qnum_get_uint(qobject_to_qnum(bsel));
aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
aml_append(method,
@@ -2619,7 +2619,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
assert(o);
- mcfg->mcfg_size = qnum_get_int(qobject_to_qnum(o));
+ mcfg->mcfg_size = qnum_get_uint(qobject_to_qnum(o));
qobject_decref(o);
return true;
}
diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c
index e2629ce70d..83084b9aab 100644
--- a/hw/pci-host/gpex.c
+++ b/hw/pci-host/gpex.c
@@ -94,7 +94,7 @@ static void gpex_host_initfn(Object *obj)
object_initialize(root, sizeof(*root), TYPE_GPEX_ROOT_DEVICE);
object_property_add_child(obj, "gpex_root", OBJECT(root), NULL);
- qdev_prop_set_uint32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
+ qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(root), "multifunction", false);
}
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index c2f2af5d9a..564f6cbb14 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -172,7 +172,7 @@ static void q35_host_initfn(Object *obj)
object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE);
object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
- qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
+ qdev_prop_set_int32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c
index a968cea2af..2c78dcfc26 100644
--- a/hw/pci-host/xilinx-pcie.c
+++ b/hw/pci-host/xilinx-pcie.c
@@ -150,7 +150,7 @@ static void xilinx_pcie_host_init(Object *obj)
object_initialize(root, sizeof(*root), TYPE_XILINX_PCIE_ROOT);
object_property_add_child(obj, "root", OBJECT(root), NULL);
- qdev_prop_set_uint32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
+ qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(root), "multifunction", false);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 20/43] isa: use get_uint() for "io-base"
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (18 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 21/43] pc-dimm: use get_uint() for dimm properties Marc-André Lureau
` (25 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
The property is defined with DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/isa/isa.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index c2fdd70cdc..95593408ef 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -29,7 +29,7 @@ static inline uint16_t applesmc_port(void)
Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL);
if (obj) {
- return object_property_get_int(obj, APPLESMC_PROP_IO_BASE, NULL);
+ return object_property_get_uint(obj, APPLESMC_PROP_IO_BASE, NULL);
}
return 0;
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 21/43] pc-dimm: use get_uint() for dimm properties
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (19 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 20/43] isa: use get_uint() for "io-base" Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 22/43] pc-dimm: make "size" property uint64 Marc-André Lureau
` (24 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_PC_DIMM's property PC_DIMM_ADDR_PROP is defined with
DEFINE_PROP_UINT64().
TYPE_PC_DIMM's property PC_DIMM_NODE_PROP is defined with
DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/acpi/memory_hotplug.c | 7 ++++---
hw/acpi/nvdimm.c | 10 +++++-----
hw/mem/pc-dimm.c | 5 +++--
hw/ppc/spapr.c | 7 ++++---
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 210073d283..d2a96569ba 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -83,11 +83,12 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
o = OBJECT(mdev->dimm);
switch (addr) {
case 0x0: /* Lo part of phys address where DIMM is mapped */
- val = o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) : 0;
+ val = o ? object_property_get_uint(o, PC_DIMM_ADDR_PROP, NULL) : 0;
trace_mhp_acpi_read_addr_lo(mem_st->selector, val);
break;
case 0x4: /* Hi part of phys address where DIMM is mapped */
- val = o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) >> 32 : 0;
+ val =
+ o ? object_property_get_uint(o, PC_DIMM_ADDR_PROP, NULL) >> 32 : 0;
trace_mhp_acpi_read_addr_hi(mem_st->selector, val);
break;
case 0x8: /* Lo part of DIMM size */
@@ -99,7 +100,7 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
trace_mhp_acpi_read_size_hi(mem_st->selector, val);
break;
case 0x10: /* node proximity for _PXM method */
- val = o ? object_property_get_int(o, PC_DIMM_NODE_PROP, NULL) : 0;
+ val = o ? object_property_get_uint(o, PC_DIMM_NODE_PROP, NULL) : 0;
trace_mhp_acpi_read_pxm(mem_st->selector, val);
break;
case 0x14: /* pack and return is_* fields */
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 8e7d6ec034..e57027149d 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -236,14 +236,14 @@ static void
nvdimm_build_structure_spa(GArray *structures, DeviceState *dev)
{
NvdimmNfitSpa *nfit_spa;
- uint64_t addr = object_property_get_int(OBJECT(dev), PC_DIMM_ADDR_PROP,
- NULL);
+ uint64_t addr = object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_PROP,
+ NULL);
uint64_t size = object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PROP,
NULL);
- uint32_t node = object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP,
- NULL);
+ uint32_t node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
+ NULL);
int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
- NULL);
+ NULL);
nfit_spa = acpi_data_push(structures, sizeof(*nfit_spa));
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 9e8dab0e89..f6def8c239 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -46,7 +46,8 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
uint64_t existing_dimms_capacity = 0;
uint64_t addr;
- addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);
+ addr = object_property_get_uint(OBJECT(dimm),
+ PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
@@ -73,7 +74,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState *hpms,
goto out;
}
- object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
+ object_property_set_uint(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
goto out;
}
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 91b4057933..bae26e2a56 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2582,7 +2582,8 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
goto out;
}
- addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err);
+ addr = object_property_get_uint(OBJECT(dimm),
+ PC_DIMM_ADDR_PROP, &local_err);
if (local_err) {
pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr);
goto out;
@@ -2741,7 +2742,7 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
sPAPRDRConnectorClass *drck;
sPAPRDIMMState *ds;
- addr_start = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
+ addr_start = object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP,
&local_err);
if (local_err) {
goto out;
@@ -2980,7 +2981,7 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
error_setg(errp, "Memory hotplug not supported for this machine");
return;
}
- node = object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP, errp);
+ node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP, errp);
if (*errp) {
return;
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 22/43] pc-dimm: make "size" property uint64
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (20 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 21/43] pc-dimm: use get_uint() for dimm properties Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 23/43] pcihp: use get_uint() for "bsel" property Marc-André Lureau
` (23 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
This carries the memory_region_size() value without implicit cast.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/acpi/memory_hotplug.c | 5 +++--
hw/acpi/nvdimm.c | 8 ++++----
hw/mem/pc-dimm.c | 18 +++++++++---------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index d2a96569ba..cda2c9dd06 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -92,11 +92,12 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
trace_mhp_acpi_read_addr_hi(mem_st->selector, val);
break;
case 0x8: /* Lo part of DIMM size */
- val = o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) : 0;
+ val = o ? object_property_get_uint(o, PC_DIMM_SIZE_PROP, NULL) : 0;
trace_mhp_acpi_read_size_lo(mem_st->selector, val);
break;
case 0xc: /* Hi part of DIMM size */
- val = o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) >> 32 : 0;
+ val =
+ o ? object_property_get_uint(o, PC_DIMM_SIZE_PROP, NULL) >> 32 : 0;
trace_mhp_acpi_read_size_hi(mem_st->selector, val);
break;
case 0x10: /* node proximity for _PXM method */
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index e57027149d..4e4cf1472f 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -238,8 +238,8 @@ nvdimm_build_structure_spa(GArray *structures, DeviceState *dev)
NvdimmNfitSpa *nfit_spa;
uint64_t addr = object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_PROP,
NULL);
- uint64_t size = object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PROP,
- NULL);
+ uint64_t size = object_property_get_uint(OBJECT(dev), PC_DIMM_SIZE_PROP,
+ NULL);
uint32_t node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
NULL);
int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
@@ -284,8 +284,8 @@ static void
nvdimm_build_structure_memdev(GArray *structures, DeviceState *dev)
{
NvdimmNfitMemDev *nfit_memdev;
- uint64_t size = object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PROP,
- NULL);
+ uint64_t size = object_property_get_uint(OBJECT(dev), PC_DIMM_SIZE_PROP,
+ NULL);
int slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
NULL);
uint32_t handle = nvdimm_slot_to_handle(slot);
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index f6def8c239..b72258e28f 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -136,7 +136,7 @@ static int pc_existing_dimms_capacity_internal(Object *obj, void *opaque)
DeviceState *dev = DEVICE(obj);
if (dev->realized) {
- (*size) += object_property_get_int(obj, PC_DIMM_SIZE_PROP,
+ (*size) += object_property_get_uint(obj, PC_DIMM_SIZE_PROP,
cap->errp);
}
@@ -182,8 +182,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
di->addr = dimm->addr;
di->slot = dimm->slot;
di->node = dimm->node;
- di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
- NULL);
+ di->size = object_property_get_uint(OBJECT(dimm), PC_DIMM_SIZE_PROP,
+ NULL);
di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
info->u.dimm.data = di;
@@ -314,9 +314,9 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
/* find address range that will fit new DIMM */
for (item = list; item; item = g_slist_next(item)) {
PCDIMMDevice *dimm = item->data;
- uint64_t dimm_size = object_property_get_int(OBJECT(dimm),
- PC_DIMM_SIZE_PROP,
- errp);
+ uint64_t dimm_size = object_property_get_uint(OBJECT(dimm),
+ PC_DIMM_SIZE_PROP,
+ errp);
if (errp && *errp) {
goto out;
}
@@ -356,7 +356,7 @@ static Property pc_dimm_properties[] = {
static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
void *opaque, Error **errp)
{
- int64_t value;
+ uint64_t value;
MemoryRegion *mr;
PCDIMMDevice *dimm = PC_DIMM(obj);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(obj);
@@ -364,7 +364,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name,
mr = ddc->get_memory_region(dimm);
value = memory_region_size(mr);
- visit_type_int(v, name, &value, errp);
+ visit_type_uint64(v, name, &value, errp);
}
static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name,
@@ -387,7 +387,7 @@ static void pc_dimm_init(Object *obj)
{
PCDIMMDevice *dimm = PC_DIMM(obj);
- object_property_add(obj, PC_DIMM_SIZE_PROP, "int", pc_dimm_get_size,
+ object_property_add(obj, PC_DIMM_SIZE_PROP, "uint64", pc_dimm_get_size,
NULL, NULL, NULL, &error_abort);
object_property_add_link(obj, PC_DIMM_MEMDEV_PROP, TYPE_MEMORY_BACKEND,
(Object **)&dimm->hostmem,
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 23/43] pcihp: use get_uint() for "bsel" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (21 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 22/43] pc-dimm: make "size" property uint64 Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 24/43] aspeed: use {set, get}_uint() for "ram-size" property Marc-André Lureau
` (22 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
The property is defined with object_property_add_uint32_ptr()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/acpi/pcihp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 3a531a4416..c420a388ea 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -62,10 +62,10 @@ typedef struct AcpiPciHpFind {
static int acpi_pcihp_get_bsel(PCIBus *bus)
{
Error *local_err = NULL;
- int64_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
- &local_err);
+ uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+ &local_err);
- if (local_err || bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
+ if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
if (local_err) {
error_free(local_err);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 24/43] aspeed: use {set, get}_uint() for "ram-size" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (22 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 23/43] pcihp: use get_uint() for "bsel" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 25/43] bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base" Marc-André Lureau
` (21 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
This property is an alias for device TYPE_ASPEED_SDMC's property
"ram-size", which is defined with DEFINE_PROP_UINT64().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/arm/aspeed.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index e824ea87a9..dd16df22ed 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -180,8 +180,8 @@ static void aspeed_board_init(MachineState *machine,
sc = ASPEED_SOC_GET_CLASS(&bmc->soc);
- object_property_set_int(OBJECT(&bmc->soc), ram_size, "ram-size",
- &error_abort);
+ object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size",
+ &error_abort);
object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1",
&error_abort);
object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs",
@@ -193,8 +193,8 @@ static void aspeed_board_init(MachineState *machine,
* Allocate RAM after the memory controller has checked the size
* was valid. If not, a default value is used.
*/
- ram_size = object_property_get_int(OBJECT(&bmc->soc), "ram-size",
- &error_abort);
+ ram_size = object_property_get_uint(OBJECT(&bmc->soc), "ram-size",
+ &error_abort);
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
memory_region_add_subregion(get_system_memory(), sc->info->sdram_base,
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 25/43] bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base"
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (23 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 24/43] aspeed: use {set, get}_uint() for "ram-size" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 26/43] platform-bus: use get_uint() for "addr" property Marc-André Lureau
` (20 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Both properties are defined with DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/arm/bcm2835_peripherals.c | 9 ++++-----
hw/arm/raspi.c | 4 ++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 502f04c02a..12e0dd11af 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -125,7 +125,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
Object *obj;
MemoryRegion *ram;
Error *err = NULL;
- uint32_t ram_size, vcram_size;
+ uint64_t ram_size, vcram_size;
int n;
obj = object_property_get_link(OBJECT(dev), "ram", &err);
@@ -207,15 +207,14 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
INTERRUPT_ARM_MAILBOX));
/* Framebuffer */
- vcram_size = (uint32_t)object_property_get_int(OBJECT(s), "vcram-size",
- &err);
+ vcram_size = object_property_get_uint(OBJECT(s), "vcram-size", &err);
if (err) {
error_propagate(errp, err);
return;
}
- object_property_set_int(OBJECT(&s->fb), ram_size - vcram_size,
- "vcram-base", &err);
+ object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size,
+ "vcram-base", &err);
if (err) {
error_propagate(errp, err);
return;
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 2b295f14c4..32cdc98c6d 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -153,8 +153,8 @@ static void raspi2_init(MachineState *machine)
qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal);
- vcram_size = object_property_get_int(OBJECT(&s->soc), "vcram-size",
- &error_abort);
+ vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size",
+ &error_abort);
setup_boot(machine, 2, machine->ram_size - vcram_size);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 26/43] platform-bus: use get_uint() for "addr" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (24 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 25/43] bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base" Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 27/43] acpi: use get_uint() for "acpi-pcihp-io*" properties Marc-André Lureau
` (19 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
This is TYPE_MEMORY_REGION's property. Its getter
memory_region_get_addr() uses visit_type_uint64().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/core/platform-bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 329ac670c0..33d32fbf22 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)
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 27/43] acpi: use get_uint() for "acpi-pcihp-io*" properties
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (25 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 26/43] platform-bus: use get_uint() for "addr" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 28/43] acpi: use get_uint() for various acpi properties Marc-André Lureau
` (18 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Those are defined with object_property_add_uint16_ptr()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/acpi-build.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b2dc3d8580..d1ffce7ce3 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -136,9 +136,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
obj = piix;
pm->cpu_hp_io_base = PIIX4_CPU_HOTPLUG_IO_BASE;
pm->pcihp_io_base =
- object_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);
+ object_property_get_uint(obj, ACPI_PCIHP_IO_BASE_PROP, NULL);
pm->pcihp_io_len =
- object_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
+ object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
}
if (lpc) {
obj = lpc;
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 28/43] acpi: use get_uint() for various acpi properties
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (26 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 27/43] acpi: use get_uint() for "acpi-pcihp-io*" properties Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 29/43] acpi: use get_uint() for "pci-hole*" properties Marc-André Lureau
` (17 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
PIIX4: piix4_pm_add_propeties() defines these with
object_property_add_uint*_ptr().
Q35: ich9_lpc_add_properties() and ich9_pm_add_properties() define them
similarly, except for ACPI_PM_PROP_GPE0_BLK(). That one's getter
ich9_pm_get_gpe0_blk() uses visit_type_uint32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/acpi-build.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index d1ffce7ce3..7c4c61290f 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -170,20 +170,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
qobject_decref(o);
/* Fill in mandatory properties */
- pm->sci_int = object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NULL);
-
- pm->acpi_enable_cmd = object_property_get_int(obj,
- ACPI_PM_PROP_ACPI_ENABLE_CMD,
- NULL);
- pm->acpi_disable_cmd = object_property_get_int(obj,
- ACPI_PM_PROP_ACPI_DISABLE_CMD,
- NULL);
- pm->io_base = object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE,
- NULL);
- pm->gpe0_blk = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK,
+ pm->sci_int = object_property_get_uint(obj, ACPI_PM_PROP_SCI_INT, NULL);
+
+ pm->acpi_enable_cmd = object_property_get_uint(obj,
+ ACPI_PM_PROP_ACPI_ENABLE_CMD,
+ NULL);
+ pm->acpi_disable_cmd =
+ object_property_get_uint(obj,
+ ACPI_PM_PROP_ACPI_DISABLE_CMD,
+ NULL);
+ pm->io_base = object_property_get_uint(obj, ACPI_PM_PROP_PM_IO_BASE,
NULL);
- pm->gpe0_blk_len = object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
- NULL);
+ pm->gpe0_blk = object_property_get_uint(obj, ACPI_PM_PROP_GPE0_BLK,
+ NULL);
+ pm->gpe0_blk_len = object_property_get_uint(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
+ NULL);
pm->pcihp_bridge_en =
object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
NULL);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 29/43] acpi: use get_uint() for "pci-hole*" properties
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (27 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 28/43] acpi: use get_uint() for various acpi properties Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 30/43] pc: use get_uint() for "iobase" property Marc-André Lureau
` (16 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Those properties use visit_type_uint*()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/acpi-build.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7c4c61290f..0b8bc62b99 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -237,19 +237,19 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64)
g_assert(pci_host);
range_set_bounds1(hole,
- object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_START,
- NULL),
- object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE_END,
- NULL));
+ object_property_get_uint(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_START,
+ NULL),
+ object_property_get_uint(pci_host,
+ PCI_HOST_PROP_PCI_HOLE_END,
+ NULL));
range_set_bounds1(hole64,
- object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_START,
- NULL),
- object_property_get_int(pci_host,
- PCI_HOST_PROP_PCI_HOLE64_END,
- NULL));
+ object_property_get_uint(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_START,
+ NULL),
+ object_property_get_uint(pci_host,
+ PCI_HOST_PROP_PCI_HOLE64_END,
+ NULL));
}
#define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 30/43] pc: use get_uint() for "iobase" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (28 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 29/43] acpi: use get_uint() for "pci-hole*" properties Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 31/43] pc: use get_uint() for "apic-id" property Marc-André Lureau
` (15 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_ISA_FDC's property "iobase" is defined with DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/pc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 5b8c6fbbea..f670ecb7f2 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -347,7 +347,7 @@ static int check_fdc(Object *obj, void *opaque)
return 0;
}
- iobase = object_property_get_int(obj, "iobase", &local_err);
+ iobase = object_property_get_uint(obj, "iobase", &local_err);
if (local_err || iobase != 0x3f0) {
error_free(local_err);
return 0;
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 31/43] pc: use get_uint() for "apic-id" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (29 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 30/43] pc: use get_uint() for "iobase" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 32/43] pc: use get_uint() for "hpet-intcap" property Marc-André Lureau
` (14 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_X86_CPU's property "apic-id" is defined with DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/pc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f670ecb7f2..f6d5717f8b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1098,7 +1098,7 @@ static void pc_new_cpu(const char *typename, int64_t apic_id, Error **errp)
cpu = object_new(typename);
- object_property_set_int(cpu, apic_id, "apic-id", &local_err);
+ object_property_set_uint(cpu, apic_id, "apic-id", &local_err);
object_property_set_bool(cpu, true, "realized", &local_err);
object_unref(cpu);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 32/43] pc: use get_uint() for "hpet-intcap" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (30 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 31/43] pc: use get_uint() for "apic-id" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 33/43] xen: use get_uint() for "max-ram-below-4g" property Marc-André Lureau
` (13 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_HPET's property HPET_INTCAP is defined with DEFINE_PROP_UINT32().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/pc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f6d5717f8b..02f9a8fe91 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1558,7 +1558,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
* and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23,
* IRQ8 and IRQ2.
*/
- uint8_t compat = object_property_get_int(OBJECT(hpet),
+ uint8_t compat = object_property_get_uint(OBJECT(hpet),
HPET_INTCAP, NULL);
if (!compat) {
qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 33/43] xen: use get_uint() for "max-ram-below-4g" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (31 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 32/43] pc: use get_uint() for "hpet-intcap" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 34/43] arm: use get_uint() for "mp-affinity" property Marc-André Lureau
` (12 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_PC_MACHINE's property PC_MACHINE_MAX_RAM_BELOW_4G's getter and
setter pc_machine_get_max_ram_below_4g() and
pc_machine_set_max_ram_below_4g() use visit_type_size()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/i386/xen/xen-hvm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 1acd4de405..cffa7e2017 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -182,9 +182,9 @@ static void xen_ram_init(PCMachineState *pcms,
{
MemoryRegion *sysmem = get_system_memory();
ram_addr_t block_len;
- uint64_t user_lowmem = object_property_get_int(qdev_get_machine(),
- PC_MACHINE_MAX_RAM_BELOW_4G,
- &error_abort);
+ uint64_t user_lowmem = object_property_get_uint(qdev_get_machine(),
+ PC_MACHINE_MAX_RAM_BELOW_4G,
+ &error_abort);
/* Handle the machine opt max-ram-below-4g. It is basically doing
* min(xen limit, user limit).
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 34/43] arm: use get_uint() for "mp-affinity" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (32 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 33/43] xen: use get_uint() for "max-ram-below-4g" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 35/43] auxbus: use get_uint() for "addr" property Marc-André Lureau
` (11 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_ARM_CPU's property "mp-affinity" is defined with
DEFINE_PROP_UINT64().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/intc/arm_gicv3_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index c6493d6c07..e2064cd8c5 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -267,7 +267,7 @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp)
* VLPIS == 0 (virtual LPIs not supported)
* PLPIS == 0 (physical LPIs not supported)
*/
- cpu_affid = object_property_get_int(OBJECT(cpu), "mp-affinity", NULL);
+ cpu_affid = object_property_get_uint(OBJECT(cpu), "mp-affinity", NULL);
last = (i == s->num_cpu - 1);
/* The CPU mp-affinity property is in MPIDR register format; squash
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 35/43] auxbus: use get_uint() for "addr" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (33 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 34/43] arm: use get_uint() for "mp-affinity" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 36/43] pvpanic: use get_uint() for "ioport" property Marc-André Lureau
` (10 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
This is TYPE_MEMORY_REGION's property. Its getter
memory_region_get_addr() uses visit_type_uint64().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/misc/auxbus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c
index e4a7ba41de..8a90ddda84 100644
--- a/hw/misc/auxbus.c
+++ b/hw/misc/auxbus.c
@@ -244,7 +244,7 @@ static void aux_slave_dev_print(Monitor *mon, DeviceState *dev, int indent)
monitor_printf(mon, "%*smemory " TARGET_FMT_plx "/" TARGET_FMT_plx "\n",
indent, "",
- object_property_get_int(OBJECT(s->mmio), "addr", NULL),
+ object_property_get_uint(OBJECT(s->mmio), "addr", NULL),
memory_region_size(s->mmio));
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 36/43] pvpanic: use get_uint() for "ioport" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (34 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 35/43] auxbus: use get_uint() for "addr" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 37/43] pnv-core: use get_uint() for "core-pir" property Marc-André Lureau
` (9 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_ISA_PVPANIC_DEVICE's property PVPANIC_IOPORT_PROP is defined with
DEFINE_PROP_UINT16().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/misc/pvpanic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 57da7f2199..2b1e9a6450 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -111,7 +111,7 @@ uint16_t pvpanic_port(void)
if (!o) {
return 0;
}
- return object_property_get_int(o, PVPANIC_IOPORT_PROP, NULL);
+ return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
}
static Property pvpanic_isa_properties[] = {
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 37/43] pnv-core: use get_uint() for "core-pir" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (35 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 36/43] pvpanic: use get_uint() for "ioport" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 38/43] numa: use get_uint() for "size" property Marc-André Lureau
` (8 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
This is an alias of TYPE_PNV_CORE's property "pir", which is defined
with DEFINE_PROP_UINT32()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/ppc/pnv_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 1b7ec70f03..142bad1e57 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -51,7 +51,7 @@ static void powernv_cpu_init(PowerPCCPU *cpu, Error **errp)
int thread_index = 0; /* TODO: TCG supports only one thread */
ppc_spr_t *pir = &env->spr_cb[SPR_PIR];
- core_pir = object_property_get_int(OBJECT(cpu), "core-pir", &error_abort);
+ core_pir = object_property_get_uint(OBJECT(cpu), "core-pir", &error_abort);
/*
* The PIR of a thread is the core PIR + the thread index. We will
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 38/43] numa: use get_uint() for "size" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (36 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 37/43] pnv-core: use get_uint() for "core-pir" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 39/43] i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties Marc-André Lureau
` (7 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
"size" is a property of TYPE_MEMORY_BACKEND.
host_memory_backend_get_size() and host_memory_backend_set_size() use
visit_type_size().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
numa.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/numa.c b/numa.c
index 65701cb6c8..b0e75f6268 100644
--- a/numa.c
+++ b/numa.c
@@ -216,7 +216,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
}
object_ref(o);
- numa_info[nodenr].node_mem = object_property_get_int(o, "size", NULL);
+ numa_info[nodenr].node_mem = object_property_get_uint(o, "size", NULL);
numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);
}
numa_info[nodenr].present = true;
@@ -641,8 +641,8 @@ static int query_memdev(Object *obj, void *opaque)
m->value->id = object_property_get_str(obj, "id", NULL);
m->value->has_id = !!m->value->id;
- m->value->size = object_property_get_int(obj, "size",
- &error_abort);
+ m->value->size = object_property_get_uint(obj, "size",
+ &error_abort);
m->value->merge = object_property_get_bool(obj, "merge",
&error_abort);
m->value->dump = object_property_get_bool(obj, "dump",
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 39/43] i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (37 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 38/43] numa: use get_uint() for "size" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 40/43] console: use get_uint() for "head" property Marc-André Lureau
` (6 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
These are properties of TYPE_X86_CPU, defined with DEFINE_PROP_UINT32()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
target/i386/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a91c0b6a64..52bda7b3f6 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -2324,8 +2324,8 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)
*/
/* CPU models only set _minimum_ values for level/xlevel: */
- object_property_set_int(OBJECT(cpu), def->level, "min-level", errp);
- object_property_set_int(OBJECT(cpu), def->xlevel, "min-xlevel", errp);
+ object_property_set_uint(OBJECT(cpu), def->level, "min-level", errp);
+ object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel", errp);
object_property_set_int(OBJECT(cpu), def->family, "family", errp);
object_property_set_int(OBJECT(cpu), def->model, "model", errp);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 40/43] console: use get_uint() for "head" property
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (38 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 39/43] i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 41/43] tests/qdict: check more get_try_int() cases Marc-André Lureau
` (5 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
TYPE_QEMU_CONSOLE property "head" is defined with
object_property_add_uint*_ptr().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/console.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/console.c b/ui/console.c
index d914cced53..40572c9254 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1872,8 +1872,8 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head)
if (DEVICE(obj) != dev) {
continue;
}
- h = object_property_get_int(OBJECT(consoles[i]),
- "head", &error_abort);
+ h = object_property_get_uint(OBJECT(consoles[i]),
+ "head", &error_abort);
if (h != head) {
continue;
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 41/43] tests/qdict: check more get_try_int() cases
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (39 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 40/43] console: use get_uint() for "head" property Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint Marc-André Lureau
` (4 subsequent siblings)
45 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
tests/check-qdict.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index 5eca1b5449..35405778cc 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -108,10 +108,17 @@ static void qdict_get_try_int_test(void)
QDict *tests_dict = qdict_new();
qdict_put_int(tests_dict, key, value);
+ qdict_put_str(tests_dict, "string", "test");
ret = qdict_get_try_int(tests_dict, key, 0);
g_assert(ret == value);
+ ret = qdict_get_try_int(tests_dict, "missing", -42);
+ g_assert_cmpuint(ret, ==, -42);
+
+ ret = qdict_get_try_int(tests_dict, "string", -42);
+ g_assert_cmpuint(ret, ==, -42);
+
QDECREF(tests_dict);
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (40 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 41/43] tests/qdict: check more get_try_int() cases Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 17:25 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/ Marc-André Lureau
` (3 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Similar to int support, add uint support.
Note this is RFC because this is currently unused in qemu, I haven't
found a good user for it yet (kaslr qemu-ga code did use it though).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/qapi/qmp/qdict.h | 5 +++++
qobject/qdict.c | 33 +++++++++++++++++++++++++++++++++
tests/check-qdict.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+)
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 363e431106..8c7c2b762b 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -56,6 +56,8 @@ void qdict_destroy_obj(QObject *obj);
/* Helpers for int, bool, and string */
#define qdict_put_int(qdict, key, value) \
qdict_put(qdict, key, qnum_from_int(value))
+#define qdict_put_uint(qdict, key, value) \
+ qdict_put(qdict, key, qnum_from_uint(value))
#define qdict_put_bool(qdict, key, value) \
qdict_put(qdict, key, qbool_from_bool(value))
#define qdict_put_str(qdict, key, value) \
@@ -64,12 +66,15 @@ void qdict_destroy_obj(QObject *obj);
/* High level helpers */
double qdict_get_double(const QDict *qdict, const char *key);
int64_t qdict_get_int(const QDict *qdict, const char *key);
+uint64_t qdict_get_uint(const QDict *qdict, const char *key);
bool qdict_get_bool(const QDict *qdict, const char *key);
QList *qdict_get_qlist(const QDict *qdict, const char *key);
QDict *qdict_get_qdict(const QDict *qdict, const char *key);
const char *qdict_get_str(const QDict *qdict, const char *key);
int64_t qdict_get_try_int(const QDict *qdict, const char *key,
int64_t def_value);
+uint64_t qdict_get_try_uint(const QDict *qdict, const char *key,
+ uint64_t def_value);
bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_value);
const char *qdict_get_try_str(const QDict *qdict, const char *key);
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 576018e531..65069baa1b 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -202,6 +202,19 @@ int64_t qdict_get_int(const QDict *qdict, const char *key)
}
/**
+ * qdict_get_uint(): Get an unsigned integer mapped by 'key'
+ *
+ * This function assumes that 'key' exists and it stores a
+ * QNum int object.
+ *
+ * Return unsigned integer mapped by 'key'.
+ */
+uint64_t qdict_get_uint(const QDict *qdict, const char *key)
+{
+ return qnum_get_uint(qobject_to_qnum(qdict_get(qdict, key)));
+}
+
+/**
* qdict_get_bool(): Get a bool mapped by 'key'
*
* This function assumes that 'key' exists and it stores a
@@ -265,6 +278,26 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,
}
/**
+ * qdict_get_try_uint(): Try to get usigned integer mapped by 'key'
+ *
+ * Return unsigned integer mapped by 'key', if it is not present in
+ * the dictionary or if the stored object is not of QNum type
+ * 'def_value' will be returned.
+ */
+uint64_t qdict_get_try_uint(const QDict *qdict, const char *key,
+ uint64_t def_value)
+{
+ QNum *qnum = qobject_to_qnum(qdict_get(qdict, key));
+ uint64_t val;
+
+ if (!qnum || !qnum_get_try_uint(qnum, &val)) {
+ val = def_value;
+ }
+
+ return val;
+}
+
+/**
* qdict_get_try_bool(): Try to get a bool mapped by 'key'
*
* Return bool mapped by 'key', if it is not present in the
diff --git a/tests/check-qdict.c b/tests/check-qdict.c
index 35405778cc..34392869ac 100644
--- a/tests/check-qdict.c
+++ b/tests/check-qdict.c
@@ -100,6 +100,21 @@ static void qdict_get_int_test(void)
QDECREF(tests_dict);
}
+static void qdict_get_uint_test(void)
+{
+ uint64_t ret;
+ const uint64_t value = UINT64_MAX;
+ const char *key = "uint";
+ QDict *tests_dict = qdict_new();
+
+ qdict_put_uint(tests_dict, key, value);
+
+ ret = qdict_get_uint(tests_dict, key);
+ g_assert(ret == value);
+
+ QDECREF(tests_dict);
+}
+
static void qdict_get_try_int_test(void)
{
int ret;
@@ -122,6 +137,28 @@ static void qdict_get_try_int_test(void)
QDECREF(tests_dict);
}
+static void qdict_get_try_uint_test(void)
+{
+ uint64_t ret;
+ const uint64_t value = UINT64_MAX;
+ const char *key = "uint";
+ QDict *tests_dict = qdict_new();
+
+ qdict_put_uint(tests_dict, key, value);
+ qdict_put_str(tests_dict, "string", "test");
+
+ ret = qdict_get_try_uint(tests_dict, key, 0);
+ g_assert_cmpuint(ret, ==, value);
+
+ ret = qdict_get_try_uint(tests_dict, "missing", 42);
+ g_assert_cmpuint(ret, ==, 42);
+
+ ret = qdict_get_try_uint(tests_dict, "string", 42);
+ g_assert_cmpuint(ret, ==, 42);
+
+ QDECREF(tests_dict);
+}
+
static void qdict_get_str_test(void)
{
const char *p;
@@ -854,7 +891,9 @@ int main(int argc, char **argv)
/* Continue, but now with fixtures */
g_test_add_func("/public/get", qdict_get_test);
g_test_add_func("/public/get_int", qdict_get_int_test);
+ g_test_add_func("/public/get_uint", qdict_get_uint_test);
g_test_add_func("/public/get_try_int", qdict_get_try_int_test);
+ g_test_add_func("/public/get_try_uint", qdict_get_try_uint_test);
g_test_add_func("/public/get_str", qdict_get_str_test);
g_test_add_func("/public/get_try_str", qdict_get_try_str_test);
g_test_add_func("/public/defaults", qdict_defaults_test);
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (41 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint Marc-André Lureau
@ 2017-06-07 16:36 ` Marc-André Lureau
2017-06-08 17:43 ` Markus Armbruster
2017-06-07 20:41 ` [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type no-reply
` (2 subsequent siblings)
45 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:36 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
The dump functions could be generally useful for any qobject user or for
debugging etc.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/qapi/qmp/qdict.h | 2 ++
include/qapi/qmp/qlist.h | 2 ++
include/qapi/qmp/qobject.h | 7 ++++
block/qapi.c | 90 +++-------------------------------------------
qobject/qdict.c | 30 ++++++++++++++++
qobject/qlist.c | 23 ++++++++++++
qobject/qobject.c | 19 ++++++++++
tests/check-qjson.c | 19 ++++++++++
8 files changed, 106 insertions(+), 86 deletions(-)
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 8c7c2b762b..1ef3bc8cda 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -91,4 +91,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp);
void qdict_join(QDict *dest, QDict *src, bool overwrite);
+char *qdict_to_string(QDict *dict, int indent);
+
#endif /* QDICT_H */
diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
index c4b5fdad9b..c93ac3e15b 100644
--- a/include/qapi/qmp/qlist.h
+++ b/include/qapi/qmp/qlist.h
@@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist);
QList *qobject_to_qlist(const QObject *obj);
void qlist_destroy_obj(QObject *obj);
+char *qlist_to_string(QList *list, int indent);
+
static inline const QListEntry *qlist_first(const QList *qlist)
{
return QTAILQ_FIRST(&qlist->head);
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index b8ddbca405..0d6ae5048a 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -101,4 +101,11 @@ static inline QObject *qnull(void)
return &qnull_;
}
+char *qobject_to_string_indent(QObject *obj, int indent);
+
+static inline char *qobject_to_string(QObject *obj)
+{
+ return qobject_to_string_indent(obj, 0);
+}
+
#endif /* QOBJECT_H */
diff --git a/block/qapi.c b/block/qapi.c
index 2050df29e4..9b7d42e50a 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -586,101 +586,19 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,
}
}
-static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
- QDict *dict);
-static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
- QList *list);
-
-static void dump_qobject(fprintf_function func_fprintf, void *f,
- int comp_indent, QObject *obj)
-{
- switch (qobject_type(obj)) {
- case QTYPE_QNUM: {
- QNum *value = qobject_to_qnum(obj);
- char *tmp = qnum_to_string(value);
- func_fprintf(f, "%s", tmp);
- g_free(tmp);
- break;
- }
- case QTYPE_QSTRING: {
- QString *value = qobject_to_qstring(obj);
- func_fprintf(f, "%s", qstring_get_str(value));
- break;
- }
- case QTYPE_QDICT: {
- QDict *value = qobject_to_qdict(obj);
- dump_qdict(func_fprintf, f, comp_indent, value);
- break;
- }
- case QTYPE_QLIST: {
- QList *value = qobject_to_qlist(obj);
- dump_qlist(func_fprintf, f, comp_indent, value);
- break;
- }
- case QTYPE_QBOOL: {
- QBool *value = qobject_to_qbool(obj);
- func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
- break;
- }
- default:
- abort();
- }
-}
-
-static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
- QList *list)
-{
- const QListEntry *entry;
- int i = 0;
-
- for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
- QType type = qobject_type(entry->value);
- bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
- func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i,
- composite ? '\n' : ' ');
- dump_qobject(func_fprintf, f, indentation + 1, entry->value);
- if (!composite) {
- func_fprintf(f, "\n");
- }
- }
-}
-
-static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
- QDict *dict)
-{
- const QDictEntry *entry;
-
- for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
- QType type = qobject_type(entry->value);
- bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
- char *key = g_malloc(strlen(entry->key) + 1);
- int i;
-
- /* replace dashes with spaces in key (variable) names */
- for (i = 0; entry->key[i]; i++) {
- key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
- }
- key[i] = 0;
- func_fprintf(f, "%*s%s:%c", indentation * 4, "", key,
- composite ? '\n' : ' ');
- dump_qobject(func_fprintf, f, indentation + 1, entry->value);
- if (!composite) {
- func_fprintf(f, "\n");
- }
- g_free(key);
- }
-}
-
void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
ImageInfoSpecific *info_spec)
{
QObject *obj, *data;
Visitor *v = qobject_output_visitor_new(&obj);
+ char *tmp;
visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
visit_complete(v, &obj);
data = qdict_get(qobject_to_qdict(obj), "data");
- dump_qobject(func_fprintf, f, 1, data);
+ tmp = qobject_to_string_indent(data, 1);
+ func_fprintf(f, "%s", tmp);
+ g_free(tmp);
qobject_decref(obj);
visit_free(v);
}
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 65069baa1b..7e5a945c5e 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -1055,3 +1055,33 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite)
entry = next;
}
}
+
+char *qdict_to_string(QDict *dict, int indent)
+{
+ const QDictEntry *entry;
+ GString *str = g_string_new(NULL);
+
+ for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
+ QType type = qobject_type(entry->value);
+ bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
+ char *key = g_malloc(strlen(entry->key) + 1);
+ char *val = qobject_to_string_indent(entry->value, indent + 1);
+ int i;
+
+ /* replace dashes with spaces in key (variable) names */
+ for (i = 0; entry->key[i]; i++) {
+ key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
+ }
+ key[i] = 0;
+ g_string_append_printf(str, "%*s%s:", indent * 4, "", key);
+ g_string_append_c(str, composite ? '\n' : ' ');
+ g_string_append(str, val);
+ if (!composite) {
+ g_string_append_c(str, '\n');
+ }
+ g_free(val);
+ g_free(key);
+ }
+
+ return g_string_free(str, false);
+}
diff --git a/qobject/qlist.c b/qobject/qlist.c
index 86b60cb88c..b769248290 100644
--- a/qobject/qlist.c
+++ b/qobject/qlist.c
@@ -158,3 +158,26 @@ void qlist_destroy_obj(QObject *obj)
g_free(qlist);
}
+
+char *qlist_to_string(QList *list, int indent)
+{
+ GString *str = g_string_new(NULL);
+ const QListEntry *entry;
+ int i = 0;
+
+ for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
+ QType type = qobject_type(entry->value);
+ bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
+ char *val = qobject_to_string_indent(entry->value, indent + 1);
+
+ g_string_append_printf(str, "%*s[%i]:", indent * 4, "", i);
+ g_string_append_c(str, composite ? '\n' : ' ');
+ g_string_append(str, val);
+ if (!composite) {
+ g_string_append_c(str, '\n');
+ }
+ g_free(val);
+ }
+
+ return g_string_free(str, false);
+}
diff --git a/qobject/qobject.c b/qobject/qobject.c
index b0cafb66f1..64e959c54f 100644
--- a/qobject/qobject.c
+++ b/qobject/qobject.c
@@ -27,3 +27,22 @@ void qobject_destroy(QObject *obj)
assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
qdestroy[obj->type](obj);
}
+
+char *qobject_to_string_indent(QObject *obj, int indent)
+{
+ switch (qobject_type(obj)) {
+ case QTYPE_QNUM:
+ return qnum_to_string(qobject_to_qnum(obj));
+ case QTYPE_QSTRING:
+ return g_strdup(qstring_get_str(qobject_to_qstring(obj)));
+ case QTYPE_QDICT:
+ return qdict_to_string(qobject_to_qdict(obj), indent);
+ case QTYPE_QLIST:
+ return qlist_to_string(qobject_to_qlist(obj), indent);
+ case QTYPE_QBOOL:
+ return g_strdup(qbool_get_bool(qobject_to_qbool(obj)) ?
+ "true" : "false");
+ default:
+ abort();
+ }
+}
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 53f2275b9b..dd3c102bc0 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1372,6 +1372,23 @@ static void simple_whitespace(void)
}
}
+static void qobject_to_string_test(void)
+{
+ QObject *obj;
+ char *tmp;
+
+ obj = qobject_from_json("[ 43, { 'c': { 'd' : 12 } }, [ 1, 2 ], 42 ]",
+ &error_abort);
+ tmp = qobject_to_string(obj);
+ g_assert_cmpstr(tmp, ==,
+ "[0]: 43\n"
+ "[1]:\n c:\n d: 12\n"
+ "[2]:\n [0]: 1\n [1]: 2\n"
+ "[3]: 42\n");
+ g_free(tmp);
+ qobject_decref(obj);
+}
+
static void simple_varargs(void)
{
QObject *embedded_obj;
@@ -1545,5 +1562,7 @@ int main(int argc, char **argv)
g_test_add_func("/errors/unterminated/literal", unterminated_literal);
g_test_add_func("/errors/limits/nesting", limits_nesting);
+ g_test_add_func("/qobject/to_string", qobject_to_string_test);
+
return g_test_run();
}
--
2.13.0.91.g00982b8dd
^ permalink raw reply related [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (42 preceding siblings ...)
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/ Marc-André Lureau
@ 2017-06-07 20:41 ` no-reply
2017-06-08 1:47 ` no-reply
2017-06-09 12:32 ` Markus Armbruster
45 siblings, 0 replies; 70+ messages in thread
From: no-reply @ 2017-06-07 20:41 UTC (permalink / raw)
To: marcandre.lureau; +Cc: famz, qemu-devel, armbru
Hi,
This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.
Type: series
Subject: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
Message-id: 20170607163635.17635-1-marcandre.lureau@redhat.com
=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-mingw@fedora
time make docker-test-build@min-glib
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
5304b17 qobject: move dump_qobject() from block/ to qobject/
04e93f9 RFC: qdict: add uint
b1f8183 tests/qdict: check more get_try_int() cases
32dc113 console: use get_uint() for "head" property
ccdbdd6 i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
eabad51 numa: use get_uint() for "size" property
23ad49e pnv-core: use get_uint() for "core-pir" property
c327b58 pvpanic: use get_uint() for "ioport" property
2af440d auxbus: use get_uint() for "addr" property
63db11b arm: use get_uint() for "mp-affinity" property
ede6718 xen: use get_uint() for "max-ram-below-4g" property
d00a748 pc: use get_uint() for "hpet-intcap" property
2be46be pc: use get_uint() for "apic-id" property
0bbec76 pc: use get_uint() for "iobase" property
54613bf acpi: use get_uint() for "pci-hole*" properties
a9029ef acpi: use get_uint() for various acpi properties
4c2ac9c acpi: use get_uint() for "acpi-pcihp-io*" properties
5890942 platform-bus: use get_uint() for "addr" property
16b2431 bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base"
52a5c50 aspeed: use {set, get}_uint() for "ram-size" property
8ee5ed0 pcihp: use get_uint() for "bsel" property
ec9a2db pc-dimm: make "size" property uint64
5b65717 pc-dimm: use get_uint() for dimm properties
e05a02f isa: use get_uint() for "io-base"
74e0f4b qdev: use appropriate getter/setters type
ea4b431 apic-common: make "id" property a uint32
917ff10 qdev: avoid type casts between signed and unsigned
c803fcd qdev: wrap default property value in an union
0153836 qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
00b6346 object: use more specific property type names
6ebdb40 q35: fix get_mmcfg_size to use uint64 visitor
b66da0f object: add uint property setter/getter
3123cbf qapi: update the qobject visitor to use QNUM_U64
f65fbd4 json: learn to parse uint64 numbers
cbe9a26 qnum: add uint type
47d9e93 tests: remove /{qnum, qlist, dict}/destroy test
19e22e7 qapi: Remove visit_start_alternate() parameter promote_int
8564a30 qapi: merge QInt and QFloat in QNum
3a28906 qapi: minor refactoring
5c73880 tests: add more int/number ranges checks
98c8358 tests: Remove test cases for alternates of 'number' and 'int'
d2fce78 object: fix potential leak in getters
0c9c6c3 qdev: remove PropertyInfo.qtype field
=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-gg351w48/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
BUILD centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-gg351w48/src'
ARCHIVE qemu.tgz
ARCHIVE dtc.tgz
COPY RUNNER
RUN test-quick in qemu:centos6
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64
Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ zlib-devel glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=07e2c7a877f4
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env
Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix /var/tmp/qemu-build/install
BIOS directory /var/tmp/qemu-build/install/share/qemu
binary directory /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory /var/tmp/qemu-build/install/etc
local state directory /var/tmp/qemu-build/install/var
Manual directory /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path /tmp/qemu-test/src
C compiler cc
Host C compiler cc
C++ compiler
Objective-C compiler cc
ARFLAGS rv
CFLAGS -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g
QEMU_CFLAGS -I/usr/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all
LDFLAGS -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g
make make
install install
python python -B
smbd /usr/sbin/smbd
module support no
host CPU x86_64
host big endian no
target list x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled no
sparse enabled no
strip binaries yes
profiler no
static build no
pixman system
SDL support yes (1.2.14)
GTK support no
GTK GL support no
VTE support no
TLS priority NORMAL
GNUTLS support no
GNUTLS rnd no
libgcrypt no
libgcrypt kdf no
nettle no
nettle kdf no
libtasn1 no
curses support no
virgl support no
curl support no
mingw32 support no
Audio drivers oss
Block whitelist (rw)
Block whitelist (ro)
VirtFS support no
VNC support yes
VNC SASL support no
VNC JPEG support no
VNC PNG support no
xen support no
brlapi support no
bluez support no
Documentation no
PIE yes
vde support no
netmap support no
Linux AIO support no
ATTR/XATTR support yes
Install blobs yes
KVM support yes
HAX support no
RDMA support no
TCG interpreter no
fdt support yes
preadv support yes
fdatasync yes
madvise yes
posix_madvise yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
Trace backends log
spice support no
rbd support no
xfsctl support no
smartcard support no
libusb no
usb net redir no
OpenGL support no
OpenGL dmabufs no
libiscsi support no
libnfs support no
build guest agent yes
QGA VSS support no
QGA w32 disk info no
QGA MSI support no
seccomp support no
coroutine backend ucontext
coroutine pool yes
debug stack usage no
GlusterFS support no
gcov gcov
gcov enabled no
TPM support yes
libssh2 support no
TPM passthrough yes
QOM debugging yes
Live block migration yes
lzo support no
snappy support no
bzip2 support no
NUMA host support no
tcmalloc support no
jemalloc support no
avx2 optimization no
replication support yes
VxHS block device no
mkdir -p dtc/libfdt
GEN x86_64-softmmu/config-devices.mak.tmp
mkdir -p dtc/tests
GEN aarch64-softmmu/config-devices.mak.tmp
GEN config-host.h
GEN qemu-options.def
GEN qapi-visit.h
GEN qmp-commands.h
GEN qapi-types.h
GEN qapi-event.h
GEN x86_64-softmmu/config-devices.mak
GEN aarch64-softmmu/config-devices.mak
GEN qmp-marshal.c
GEN qapi-types.c
GEN qapi-visit.c
GEN qapi-event.c
GEN qmp-introspect.h
GEN qmp-introspect.c
GEN trace/generated-tcg-tracers.h
GEN trace/generated-helpers-wrappers.h
GEN trace/generated-helpers.h
GEN trace/generated-helpers.c
GEN module_block.h
GEN tests/test-qapi-types.h
GEN tests/test-qmp-commands.h
GEN tests/test-qapi-visit.h
GEN tests/test-qapi-event.h
GEN tests/test-qmp-introspect.h
GEN trace-root.h
GEN util/trace.h
GEN crypto/trace.h
GEN io/trace.h
GEN migration/trace.h
GEN block/trace.h
GEN backends/trace.h
GEN chardev/trace.h
GEN hw/block/trace.h
GEN hw/block/dataplane/trace.h
GEN hw/char/trace.h
GEN hw/intc/trace.h
GEN hw/net/trace.h
GEN hw/virtio/trace.h
GEN hw/audio/trace.h
GEN hw/misc/trace.h
GEN hw/usb/trace.h
GEN hw/scsi/trace.h
GEN hw/nvram/trace.h
GEN hw/display/trace.h
GEN hw/input/trace.h
GEN hw/timer/trace.h
GEN hw/dma/trace.h
GEN hw/sparc/trace.h
GEN hw/sd/trace.h
GEN hw/isa/trace.h
GEN hw/mem/trace.h
GEN hw/i386/trace.h
GEN hw/i386/xen/trace.h
GEN hw/9pfs/trace.h
GEN hw/ppc/trace.h
GEN hw/pci/trace.h
GEN hw/s390x/trace.h
GEN hw/vfio/trace.h
GEN hw/acpi/trace.h
GEN hw/arm/trace.h
GEN hw/alpha/trace.h
GEN hw/xen/trace.h
GEN ui/trace.h
GEN audio/trace.h
GEN net/trace.h
GEN target/arm/trace.h
GEN target/i386/trace.h
GEN target/mips/trace.h
GEN target/sparc/trace.h
GEN target/s390x/trace.h
GEN target/ppc/trace.h
GEN qom/trace.h
GEN linux-user/trace.h
GEN qapi/trace.h
GEN trace-root.c
GEN util/trace.c
GEN crypto/trace.c
GEN io/trace.c
GEN migration/trace.c
GEN block/trace.c
GEN backends/trace.c
GEN chardev/trace.c
GEN hw/block/trace.c
GEN hw/block/dataplane/trace.c
GEN hw/char/trace.c
GEN hw/intc/trace.c
GEN hw/net/trace.c
GEN hw/virtio/trace.c
GEN hw/audio/trace.c
GEN hw/misc/trace.c
GEN hw/usb/trace.c
GEN hw/scsi/trace.c
GEN hw/nvram/trace.c
GEN hw/display/trace.c
GEN hw/input/trace.c
GEN hw/timer/trace.c
GEN hw/dma/trace.c
GEN hw/sparc/trace.c
GEN hw/sd/trace.c
GEN hw/isa/trace.c
GEN hw/mem/trace.c
GEN hw/i386/trace.c
GEN hw/i386/xen/trace.c
GEN hw/9pfs/trace.c
GEN hw/ppc/trace.c
GEN hw/pci/trace.c
GEN hw/s390x/trace.c
GEN hw/vfio/trace.c
GEN hw/acpi/trace.c
GEN hw/arm/trace.c
GEN hw/alpha/trace.c
GEN hw/xen/trace.c
GEN ui/trace.c
GEN audio/trace.c
GEN net/trace.c
GEN target/arm/trace.c
GEN target/i386/trace.c
GEN target/mips/trace.c
GEN target/sparc/trace.c
GEN target/s390x/trace.c
GEN target/ppc/trace.c
GEN qom/trace.c
GEN linux-user/trace.c
GEN qapi/trace.c
GEN config-all-devices.mak
DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
DEP /tmp/qemu-test/src/dtc/tests/trees.S
DEP /tmp/qemu-test/src/dtc/tests/testutils.c
DEP /tmp/qemu-test/src/dtc/tests/value-labels.c
DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.c
DEP /tmp/qemu-test/src/dtc/tests/truncated_property.c
DEP /tmp/qemu-test/src/dtc/tests/check_path.c
DEP /tmp/qemu-test/src/dtc/tests/overlay_bad_fixup.c
DEP /tmp/qemu-test/src/dtc/tests/overlay.c
DEP /tmp/qemu-test/src/dtc/tests/subnode_iterate.c
DEP /tmp/qemu-test/src/dtc/tests/property_iterate.c
DEP /tmp/qemu-test/src/dtc/tests/integer-expressions.c
DEP /tmp/qemu-test/src/dtc/tests/utilfdt_test.c
DEP /tmp/qemu-test/src/dtc/tests/path_offset_aliases.c
DEP /tmp/qemu-test/src/dtc/tests/add_subnode_with_nops.c
DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_unordered.c
DEP /tmp/qemu-test/src/dtc/tests/dtb_reverse.c
DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_ordered.c
DEP /tmp/qemu-test/src/dtc/tests/extra-terminating-null.c
DEP /tmp/qemu-test/src/dtc/tests/boot-cpuid.c
DEP /tmp/qemu-test/src/dtc/tests/phandle_format.c
DEP /tmp/qemu-test/src/dtc/tests/incbin.c
DEP /tmp/qemu-test/src/dtc/tests/path-references.c
DEP /tmp/qemu-test/src/dtc/tests/references.c
DEP /tmp/qemu-test/src/dtc/tests/string_escapes.c
DEP /tmp/qemu-test/src/dtc/tests/propname_escapes.c
DEP /tmp/qemu-test/src/dtc/tests/appendprop2.c
DEP /tmp/qemu-test/src/dtc/tests/appendprop1.c
DEP /tmp/qemu-test/src/dtc/tests/del_node.c
DEP /tmp/qemu-test/src/dtc/tests/del_property.c
DEP /tmp/qemu-test/src/dtc/tests/setprop.c
DEP /tmp/qemu-test/src/dtc/tests/set_name.c
DEP /tmp/qemu-test/src/dtc/tests/rw_tree1.c
DEP /tmp/qemu-test/src/dtc/tests/open_pack.c
DEP /tmp/qemu-test/src/dtc/tests/nopulate.c
DEP /tmp/qemu-test/src/dtc/tests/mangle-layout.c
DEP /tmp/qemu-test/src/dtc/tests/move_and_save.c
DEP /tmp/qemu-test/src/dtc/tests/sw_tree1.c
DEP /tmp/qemu-test/src/dtc/tests/nop_node.c
DEP /tmp/qemu-test/src/dtc/tests/nop_property.c
DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.c
DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
DEP /tmp/qemu-test/src/dtc/tests/addr_size_cells.c
DEP /tmp/qemu-test/src/dtc/tests/notfound.c
DEP /tmp/qemu-test/src/dtc/tests/char_literal.c
DEP /tmp/qemu-test/src/dtc/tests/sized_cells.c
DEP /tmp/qemu-test/src/dtc/tests/get_alias.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_compatible.c
DEP /tmp/qemu-test/src/dtc/tests/node_check_compatible.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_phandle.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_prop_value.c
DEP /tmp/qemu-test/src/dtc/tests/parent_offset.c
DEP /tmp/qemu-test/src/dtc/tests/supernode_atdepth_offset.c
DEP /tmp/qemu-test/src/dtc/tests/get_path.c
DEP /tmp/qemu-test/src/dtc/tests/get_phandle.c
DEP /tmp/qemu-test/src/dtc/tests/getprop.c
DEP /tmp/qemu-test/src/dtc/tests/get_name.c
DEP /tmp/qemu-test/src/dtc/tests/path_offset.c
DEP /tmp/qemu-test/src/dtc/tests/subnode_offset.c
DEP /tmp/qemu-test/src/dtc/tests/find_property.c
DEP /tmp/qemu-test/src/dtc/tests/root_node.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.c
DEP /tmp/qemu-test/src/dtc/tests/get_mem_rsv.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_addresses.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_empty_tree.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_strerror.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_rw.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_wip.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_sw.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_ro.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt.c
DEP /tmp/qemu-test/src/dtc/util.c
DEP /tmp/qemu-test/src/dtc/fdtput.c
DEP /tmp/qemu-test/src/dtc/fdtget.c
DEP /tmp/qemu-test/src/dtc/fdtdump.c
LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
BISON dtc-parser.tab.c
DEP /tmp/qemu-test/src/dtc/srcpos.c
make[1]: bison: Command not found
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
DEP /tmp/qemu-test/src/dtc/treesource.c
DEP /tmp/qemu-test/src/dtc/fstree.c
DEP /tmp/qemu-test/src/dtc/livetree.c
DEP /tmp/qemu-test/src/dtc/flattree.c
DEP /tmp/qemu-test/src/dtc/dtc.c
DEP /tmp/qemu-test/src/dtc/data.c
DEP /tmp/qemu-test/src/dtc/checks.c
LEX convert-dtsv0-lexer.lex.c
BISON dtc-parser.tab.c
make[1]: flex: Command not found
make[1]: bison: Command not found
LEX dtc-lexer.lex.c
CHK version_gen.h
make[1]: flex: Command not found
UPD version_gen.h
DEP /tmp/qemu-test/src/dtc/util.c
LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
BISON dtc-parser.tab.c
make[1]: bison: Command not found
CC libfdt/fdt_ro.o
CC libfdt/fdt_sw.o
CC libfdt/fdt.o
CC libfdt/fdt_wip.o
CC libfdt/fdt_rw.o
CC libfdt/fdt_strerror.o
CC libfdt/fdt_empty_tree.o
CC libfdt/fdt_addresses.o
CC libfdt/fdt_overlay.o
AR libfdt/libfdt.a
ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
LEX convert-dtsv0-lexer.lex.c
BISON dtc-parser.tab.c
make[1]: flex: Command not found
make[1]: bison: Command not found
CC tests/qemu-iotests/socket_scm_helper.o
GEN qga/qapi-generated/qga-qapi-types.h
GEN qga/qapi-generated/qga-qmp-commands.h
CC qmp-introspect.o
GEN qga/qapi-generated/qga-qapi-types.c
GEN qga/qapi-generated/qga-qapi-visit.h
GEN qga/qapi-generated/qga-qapi-visit.c
GEN qga/qapi-generated/qga-qmp-marshal.c
CC qapi-types.o
CC qapi-visit.o
CC qapi-event.o
CC qapi/qapi-visit-core.o
CC qapi/qapi-dealloc-visitor.o
CC qapi/qobject-input-visitor.o
CC qapi/qobject-output-visitor.o
CC qapi/qmp-registry.o
CC qapi/qmp-dispatch.o
CC qapi/string-input-visitor.o
CC qapi/string-output-visitor.o
CC qapi/opts-visitor.o
CC qapi/qapi-clone-visitor.o
CC qapi/qmp-event.o
CC qapi/qapi-util.o
CC qobject/qnull.o
CC qobject/qnum.o
CC qobject/qstring.o
CC qobject/qdict.o
CC qobject/qlist.o
CC qobject/qbool.o
CC qobject/qjson.o
CC qobject/qobject.o
CC qobject/json-lexer.o
CC qobject/json-streamer.o
CC qobject/json-parser.o
CC trace/qmp.o
CC trace/control.o
CC util/osdep.o
CC util/cutils.o
CC util/unicode.o
CC util/qemu-timer-common.o
CC util/bufferiszero.o
CC util/lockcnt.o
CC util/aiocb.o
CC util/async.o
CC util/thread-pool.o
CC util/qemu-timer.o
CC util/main-loop.o
CC util/iohandler.o
CC util/aio-posix.o
CC util/compatfd.o
CC util/event_notifier-posix.o
CC util/mmap-alloc.o
CC util/oslib-posix.o
CC util/qemu-openpty.o
CC util/qemu-thread-posix.o
CC util/memfd.o
CC util/path.o
CC util/envlist.o
CC util/module.o
CC util/host-utils.o
CC util/bitmap.o
CC util/bitops.o
CC util/hbitmap.o
CC util/fifo8.o
CC util/acl.o
CC util/error.o
CC util/qemu-error.o
CC util/id.o
CC util/iov.o
CC util/qemu-config.o
CC util/qemu-sockets.o
CC util/uri.o
CC util/notify.o
CC util/qemu-option.o
CC util/qemu-progress.o
CC util/keyval.o
CC util/hexdump.o
CC util/uuid.o
CC util/crc32c.o
CC util/throttle.o
CC util/getauxval.o
CC util/readline.o
CC util/rcu.o
CC util/qemu-coroutine.o
CC util/qemu-coroutine-lock.o
CC util/qemu-coroutine-io.o
CC util/qemu-coroutine-sleep.o
CC util/coroutine-ucontext.o
CC util/buffer.o
CC util/timed-average.o
CC util/base64.o
CC util/log.o
CC util/qdist.o
CC util/qht.o
CC util/range.o
CC util/systemd.o
CC trace-root.o
CC util/trace.o
CC crypto/trace.o
CC io/trace.o
CC migration/trace.o
CC block/trace.o
CC backends/trace.o
CC chardev/trace.o
CC hw/block/trace.o
CC hw/block/dataplane/trace.o
CC hw/char/trace.o
CC hw/intc/trace.o
CC hw/net/trace.o
CC hw/virtio/trace.o
CC hw/audio/trace.o
CC hw/misc/trace.o
CC hw/usb/trace.o
CC hw/scsi/trace.o
CC hw/nvram/trace.o
CC hw/display/trace.o
CC hw/input/trace.o
CC hw/timer/trace.o
CC hw/dma/trace.o
CC hw/sparc/trace.o
CC hw/sd/trace.o
CC hw/isa/trace.o
CC hw/mem/trace.o
CC hw/i386/trace.o
CC hw/i386/xen/trace.o
CC hw/9pfs/trace.o
CC hw/ppc/trace.o
CC hw/pci/trace.o
CC hw/s390x/trace.o
CC hw/vfio/trace.o
CC hw/acpi/trace.o
CC hw/arm/trace.o
CC hw/alpha/trace.o
CC hw/xen/trace.o
CC ui/trace.o
CC audio/trace.o
CC net/trace.o
CC target/arm/trace.o
CC target/i386/trace.o
CC target/mips/trace.o
CC target/sparc/trace.o
CC target/s390x/trace.o
CC target/ppc/trace.o
CC qom/trace.o
CC linux-user/trace.o
CC qapi/trace.o
CC crypto/pbkdf-stub.o
CC stubs/arch-query-cpu-def.o
CC stubs/arch-query-cpu-model-expansion.o
CC stubs/arch-query-cpu-model-comparison.o
CC stubs/arch-query-cpu-model-baseline.o
CC stubs/bdrv-next-monitor-owned.o
CC stubs/blockdev-close-all-bdrv-states.o
CC stubs/blk-commit-all.o
CC stubs/clock-warp.o
CC stubs/cpu-get-clock.o
CC stubs/cpu-get-icount.o
CC stubs/dump.o
CC stubs/error-printf.o
CC stubs/fdset.o
CC stubs/gdbstub.o
CC stubs/get-vm-name.o
CC stubs/iothread.o
CC stubs/iothread-lock.o
CC stubs/is-daemonized.o
CC stubs/migr-blocker.o
CC stubs/machine-init-done.o
CC stubs/monitor.o
CC stubs/notify-event.o
CC stubs/qtest.o
CC stubs/replay.o
CC stubs/runstate-check.o
CC stubs/set-fd-handler.o
CC stubs/slirp.o
CC stubs/sysbus.o
CC stubs/trace-control.o
CC stubs/uuid.o
CC stubs/vmstate.o
CC stubs/vm-stop.o
CC stubs/qmp_pc_dimm_device_list.o
CC stubs/target-monitor-defs.o
CC stubs/target-get-monitor-def.o
CC stubs/pc_madt_cpu_entry.o
CC stubs/vmgenid.o
CC stubs/xen-common.o
CC stubs/xen-hvm.o
CC contrib/ivshmem-client/ivshmem-client.o
CC contrib/ivshmem-client/main.o
CC contrib/ivshmem-server/ivshmem-server.o
CC contrib/ivshmem-server/main.o
CC qemu-nbd.o
CC block.o
CC blockjob.o
CC qemu-io-cmds.o
CC replication.o
CC block/raw-format.o
CC block/qcow.o
CC block/vdi.o
CC block/vmdk.o
CC block/cloop.o
CC block/bochs.o
CC block/vpc.o
CC block/vvfat.o
CC block/dmg.o
CC block/qcow2.o
CC block/qcow2-refcount.o
CC block/qcow2-cluster.o
CC block/qcow2-snapshot.o
CC block/qcow2-cache.o
CC block/qed.o
CC block/qed-gencb.o
CC block/qed-l2-cache.o
CC block/qed-table.o
CC block/qed-cluster.o
CC block/qed-check.o
CC block/vhdx.o
CC block/vhdx-endian.o
CC block/vhdx-log.o
CC block/quorum.o
CC block/parallels.o
CC block/blkdebug.o
CC block/blkverify.o
CC block/blkreplay.o
CC block/block-backend.o
CC block/snapshot.o
CC block/qapi.o
CC block/file-posix.o
CC block/null.o
CC block/mirror.o
CC block/commit.o
CC block/io.o
CC block/throttle-groups.o
CC block/nbd.o
CC block/nbd-client.o
CC block/sheepdog.o
CC block/accounting.o
CC block/dirty-bitmap.o
CC block/write-threshold.o
CC block/backup.o
CC block/replication.o
CC block/crypto.o
CC nbd/server.o
CC nbd/client.o
CC nbd/common.o
CC crypto/init.o
CC crypto/hash.o
CC crypto/hash-glib.o
CC crypto/hmac.o
CC crypto/hmac-glib.o
CC crypto/aes.o
CC crypto/desrfb.o
CC crypto/cipher.o
CC crypto/tlscreds.o
CC crypto/tlscredsanon.o
CC crypto/tlscredsx509.o
CC crypto/tlssession.o
CC crypto/secret.o
CC crypto/random-platform.o
CC crypto/pbkdf.o
CC crypto/ivgen.o
CC crypto/ivgen-essiv.o
CC crypto/ivgen-plain.o
CC crypto/ivgen-plain64.o
CC crypto/afsplit.o
CC crypto/xts.o
CC crypto/block.o
CC crypto/block-qcow.o
CC crypto/block-luks.o
CC io/channel.o
CC io/channel-buffer.o
CC io/channel-command.o
CC io/channel-file.o
CC io/channel-socket.o
CC io/channel-tls.o
CC io/channel-watch.o
CC io/channel-websock.o
CC io/channel-util.o
CC io/dns-resolver.o
CC io/task.o
CC qom/object.o
CC qom/container.o
CC qom/qom-qobject.o
CC qom/object_interfaces.o
GEN qemu-img-cmds.h
CC qemu-io.o
CC qemu-bridge-helper.o
CC blockdev.o
CC blockdev-nbd.o
CC iothread.o
CC qdev-monitor.o
CC device-hotplug.o
CC os-posix.o
CC accel.o
CC bt-host.o
CC bt-vhci.o
CC dma-helpers.o
CC vl.o
CC tpm.o
CC device_tree.o
CC qmp-marshal.o
CC qmp.o
CC hmp.o
CC cpus-common.o
CC audio/audio.o
CC audio/noaudio.o
CC audio/wavaudio.o
CC audio/mixeng.o
CC audio/sdlaudio.o
CC audio/ossaudio.o
CC audio/wavcapture.o
CC backends/rng.o
CC backends/rng-egd.o
CC backends/rng-random.o
CC backends/tpm.o
CC backends/hostmem.o
CC backends/hostmem-ram.o
CC backends/hostmem-file.o
CC backends/cryptodev.o
CC backends/cryptodev-builtin.o
CC block/stream.o
CC chardev/msmouse.o
CC chardev/wctablet.o
CC chardev/testdev.o
CC disas/arm.o
CC disas/i386.o
CC fsdev/qemu-fsdev-dummy.o
CC fsdev/qemu-fsdev-opts.o
CC fsdev/qemu-fsdev-throttle.o
CC hw/acpi/core.o
CC hw/acpi/piix4.o
CC hw/acpi/pcihp.o
CC hw/acpi/ich9.o
CC hw/acpi/tco.o
CC hw/acpi/cpu_hotplug.o
CC hw/acpi/memory_hotplug.o
CC hw/acpi/cpu.o
CC hw/acpi/nvdimm.o
CC hw/acpi/vmgenid.o
CC hw/acpi/acpi_interface.o
CC hw/acpi/bios-linker-loader.o
CC hw/acpi/aml-build.o
CC hw/acpi/ipmi.o
CC hw/acpi/acpi-stub.o
CC hw/acpi/ipmi-stub.o
CC hw/audio/sb16.o
CC hw/audio/es1370.o
CC hw/audio/ac97.o
CC hw/audio/fmopl.o
CC hw/audio/adlib.o
CC hw/audio/gus.o
CC hw/audio/gusemu_hal.o
CC hw/audio/gusemu_mixer.o
CC hw/audio/cs4231a.o
CC hw/audio/intel-hda.o
CC hw/audio/hda-codec.o
CC hw/audio/pcspk.o
CC hw/audio/wm8750.o
CC hw/audio/pl041.o
CC hw/audio/lm4549.o
CC hw/audio/marvell_88w8618.o
CC hw/audio/soundhw.o
CC hw/block/block.o
CC hw/block/cdrom.o
CC hw/block/hd-geometry.o
CC hw/block/fdc.o
CC hw/block/m25p80.o
CC hw/block/nand.o
CC hw/block/pflash_cfi01.o
CC hw/block/pflash_cfi02.o
CC hw/block/ecc.o
CC hw/block/onenand.o
CC hw/block/nvme.o
CC hw/bt/core.o
CC hw/bt/l2cap.o
CC hw/bt/sdp.o
CC hw/bt/hci.o
CC hw/bt/hid.o
CC hw/bt/hci-csr.o
CC hw/char/ipoctal232.o
CC hw/char/parallel.o
CC hw/char/pl011.o
CC hw/char/serial.o
CC hw/char/serial-isa.o
CC hw/char/serial-pci.o
CC hw/char/virtio-console.o
CC hw/char/cadence_uart.o
CC hw/char/debugcon.o
CC hw/char/imx_serial.o
CC hw/core/qdev.o
CC hw/core/qdev-properties.o
CC hw/core/bus.o
CC hw/core/reset.o
CC hw/core/fw-path-provider.o
CC hw/core/irq.o
CC hw/core/hotplug.o
CC hw/core/nmi.o
CC hw/core/ptimer.o
CC hw/core/sysbus.o
CC hw/core/machine.o
CC hw/core/loader.o
CC hw/core/qdev-properties-system.o
CC hw/core/register.o
CC hw/core/or-irq.o
CC hw/core/platform-bus.o
CC hw/display/ads7846.o
CC hw/display/cirrus_vga.o
CC hw/display/pl110.o
CC hw/display/ssd0303.o
CC hw/display/ssd0323.o
CC hw/display/vga-pci.o
CC hw/display/vga-isa.o
CC hw/display/vmware_vga.o
CC hw/display/blizzard.o
CC hw/display/exynos4210_fimd.o
CC hw/display/framebuffer.o
CC hw/display/tc6393xb.o
CC hw/dma/pl080.o
CC hw/dma/pl330.o
CC hw/dma/i8257.o
CC hw/dma/xlnx-zynq-devcfg.o
CC hw/gpio/max7310.o
CC hw/gpio/pl061.o
CC hw/gpio/zaurus.o
CC hw/gpio/gpio_key.o
CC hw/i2c/core.o
CC hw/i2c/smbus.o
CC hw/i2c/smbus_eeprom.o
CC hw/i2c/i2c-ddc.o
CC hw/i2c/versatile_i2c.o
CC hw/i2c/smbus_ich9.o
CC hw/i2c/pm_smbus.o
CC hw/i2c/bitbang_i2c.o
CC hw/i2c/exynos4210_i2c.o
CC hw/i2c/imx_i2c.o
CC hw/i2c/aspeed_i2c.o
CC hw/ide/core.o
CC hw/ide/atapi.o
CC hw/ide/qdev.o
CC hw/ide/pci.o
CC hw/ide/isa.o
CC hw/ide/piix.o
CC hw/ide/microdrive.o
CC hw/ide/ahci.o
CC hw/ide/ich.o
CC hw/input/hid.o
CC hw/input/lm832x.o
CC hw/input/pckbd.o
CC hw/input/pl050.o
CC hw/input/ps2.o
CC hw/input/stellaris_input.o
CC hw/input/tsc2005.o
CC hw/input/vmmouse.o
CC hw/input/virtio-input.o
CC hw/input/virtio-input-hid.o
CC hw/input/virtio-input-host.o
CC hw/intc/i8259_common.o
CC hw/intc/i8259.o
CC hw/intc/pl190.o
CC hw/intc/imx_avic.o
CC hw/intc/realview_gic.o
CC hw/intc/ioapic_common.o
CC hw/intc/arm_gic_common.o
CC hw/intc/arm_gic.o
CC hw/intc/arm_gicv2m.o
CC hw/intc/arm_gicv3_common.o
CC hw/intc/arm_gicv3.o
CC hw/intc/arm_gicv3_dist.o
CC hw/intc/arm_gicv3_redist.o
CC hw/intc/arm_gicv3_its_common.o
CC hw/intc/intc.o
CC hw/ipack/ipack.o
CC hw/ipack/tpci200.o
CC hw/ipmi/ipmi.o
CC hw/ipmi/ipmi_bmc_sim.o
CC hw/ipmi/ipmi_bmc_extern.o
CC hw/ipmi/isa_ipmi_kcs.o
CC hw/ipmi/isa_ipmi_bt.o
CC hw/isa/isa-bus.o
CC hw/isa/apm.o
CC hw/mem/pc-dimm.o
CC hw/mem/nvdimm.o
CC hw/misc/applesmc.o
CC hw/misc/max111x.o
CC hw/misc/tmp105.o
CC hw/misc/debugexit.o
CC hw/misc/sga.o
CC hw/misc/pc-testdev.o
CC hw/misc/pci-testdev.o
CC hw/misc/unimp.o
CC hw/misc/arm_l2x0.o
CC hw/misc/arm_integrator_debug.o
CC hw/misc/a9scu.o
CC hw/misc/arm11scu.o
CC hw/net/ne2000.o
CC hw/net/eepro100.o
CC hw/net/pcnet-pci.o
CC hw/net/pcnet.o
CC hw/net/e1000.o
CC hw/net/e1000x_common.o
CC hw/net/net_tx_pkt.o
CC hw/net/net_rx_pkt.o
CC hw/net/e1000e.o
CC hw/net/e1000e_core.o
CC hw/net/vmxnet3.o
CC hw/net/rtl8139.o
CC hw/net/smc91c111.o
CC hw/net/lan9118.o
CC hw/net/ne2000-isa.o
CC hw/net/xgmac.o
CC hw/net/allwinner_emac.o
CC hw/net/imx_fec.o
CC hw/net/cadence_gem.o
CC hw/net/stellaris_enet.o
CC hw/net/ftgmac100.o
CC hw/net/rocker/rocker.o
CC hw/net/rocker/rocker_fp.o
CC hw/net/rocker/rocker_desc.o
CC hw/net/rocker/rocker_world.o
CC hw/net/rocker/rocker_of_dpa.o
CC hw/nvram/eeprom93xx.o
CC hw/nvram/fw_cfg.o
CC hw/nvram/chrp_nvram.o
CC hw/pci-bridge/pci_bridge_dev.o
CC hw/pci-bridge/pcie_root_port.o
CC hw/pci-bridge/gen_pcie_root_port.o
CC hw/pci-bridge/pci_expander_bridge.o
CC hw/pci-bridge/xio3130_upstream.o
CC hw/pci-bridge/xio3130_downstream.o
CC hw/pci-bridge/ioh3420.o
CC hw/pci-bridge/i82801b11.o
CC hw/pci-host/pam.o
CC hw/pci-host/versatile.o
CC hw/pci-host/piix.o
CC hw/pci-host/q35.o
CC hw/pci-host/gpex.o
CC hw/pci/pci.o
CC hw/pci/pci_bridge.o
CC hw/pci/msix.o
CC hw/pci/msi.o
CC hw/pci/shpc.o
CC hw/pci/slotid_cap.o
CC hw/pci/pci_host.o
CC hw/pci/pcie_host.o
CC hw/pci/pcie.o
CC hw/pci/pcie_aer.o
CC hw/pci/pcie_port.o
CC hw/pci/pci-stub.o
CC hw/pcmcia/pcmcia.o
CC hw/scsi/scsi-disk.o
CC hw/scsi/scsi-generic.o
CC hw/scsi/scsi-bus.o
CC hw/scsi/lsi53c895a.o
CC hw/scsi/mptsas.o
CC hw/scsi/mptconfig.o
CC hw/scsi/mptendian.o
CC hw/scsi/megasas.o
CC hw/scsi/vmw_pvscsi.o
CC hw/scsi/esp.o
CC hw/scsi/esp-pci.o
CC hw/sd/pl181.o
CC hw/sd/ssi-sd.o
CC hw/sd/sd.o
CC hw/sd/core.o
CC hw/sd/sdhci.o
CC hw/smbios/smbios.o
CC hw/smbios/smbios_type_38.o
CC hw/smbios/smbios-stub.o
CC hw/smbios/smbios_type_38-stub.o
CC hw/ssi/pl022.o
CC hw/ssi/ssi.o
CC hw/ssi/xilinx_spips.o
CC hw/ssi/aspeed_smc.o
CC hw/ssi/stm32f2xx_spi.o
CC hw/timer/arm_timer.o
CC hw/timer/arm_mptimer.o
CC hw/timer/armv7m_systick.o
CC hw/timer/a9gtimer.o
CC hw/timer/cadence_ttc.o
CC hw/timer/ds1338.o
CC hw/timer/hpet.o
CC hw/timer/i8254_common.o
CC hw/timer/i8254.o
CC hw/timer/pl031.o
CC hw/timer/twl92230.o
CC hw/timer/imx_epit.o
CC hw/timer/imx_gpt.o
CC hw/timer/stm32f2xx_timer.o
CC hw/timer/aspeed_timer.o
CC hw/tpm/tpm_tis.o
CC hw/tpm/tpm_passthrough.o
CC hw/tpm/tpm_util.o
CC hw/usb/core.o
CC hw/usb/combined-packet.o
CC hw/usb/bus.o
CC hw/usb/libhw.o
CC hw/usb/desc.o
CC hw/usb/desc-msos.o
CC hw/usb/hcd-uhci.o
CC hw/usb/hcd-ohci.o
CC hw/usb/hcd-ehci.o
CC hw/usb/hcd-ehci-pci.o
CC hw/usb/hcd-ehci-sysbus.o
CC hw/usb/hcd-xhci.o
CC hw/usb/hcd-xhci-nec.o
CC hw/usb/hcd-musb.o
CC hw/usb/dev-hub.o
CC hw/usb/dev-hid.o
CC hw/usb/dev-wacom.o
CC hw/usb/dev-storage.o
CC hw/usb/dev-uas.o
CC hw/usb/dev-audio.o
CC hw/usb/dev-serial.o
CC hw/usb/dev-network.o
CC hw/usb/dev-bluetooth.o
CC hw/usb/dev-smartcard-reader.o
CC hw/usb/dev-mtp.o
CC hw/usb/host-stub.o
CC hw/virtio/virtio-rng.o
CC hw/virtio/virtio-pci.o
CC hw/virtio/virtio-bus.o
CC hw/virtio/virtio-mmio.o
CC hw/virtio/vhost-stub.o
CC hw/watchdog/watchdog.o
CC hw/watchdog/wdt_i6300esb.o
CC hw/watchdog/wdt_ib700.o
CC hw/watchdog/wdt_aspeed.o
CC migration/migration.o
CC migration/socket.o
CC migration/fd.o
CC migration/exec.o
CC migration/tls.o
CC migration/channel.o
CC migration/savevm.o
CC migration/colo-comm.o
CC migration/colo.o
CC migration/colo-failover.o
CC migration/vmstate.o
CC migration/vmstate-types.o
CC migration/page_cache.o
CC migration/qemu-file.o
CC migration/qemu-file-channel.o
CC migration/xbzrle.o
CC migration/postcopy-ram.o
CC migration/qjson.o
CC migration/block.o
CC net/net.o
CC net/queue.o
CC net/checksum.o
CC net/util.o
CC net/hub.o
CC net/socket.o
CC net/dump.o
CC net/eth.o
CC net/l2tpv3.o
CC net/vhost-user.o
CC net/slirp.o
CC net/filter.o
CC net/filter-buffer.o
CC net/filter-mirror.o
CC net/colo-compare.o
CC net/colo.o
CC net/filter-rewriter.o
CC net/filter-replay.o
CC net/tap.o
CC net/tap-linux.o
CC qom/cpu.o
CC replay/replay.o
CC replay/replay-internal.o
CC replay/replay-events.o
CC replay/replay-time.o
CC replay/replay-input.o
CC replay/replay-char.o
/tmp/qemu-test/src/replay/replay-internal.c: In function ‘replay_put_array’:
/tmp/qemu-test/src/replay/replay-internal.c:65: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
CC replay/replay-snapshot.o
CC replay/replay-net.o
CC replay/replay-audio.o
CC slirp/cksum.o
CC slirp/if.o
CC slirp/ip_icmp.o
CC slirp/ip6_input.o
CC slirp/ip6_icmp.o
CC slirp/ip6_output.o
CC slirp/ip_input.o
CC slirp/ip_output.o
CC slirp/dnssearch.o
CC slirp/dhcpv6.o
CC slirp/slirp.o
CC slirp/mbuf.o
CC slirp/misc.o
CC slirp/socket.o
CC slirp/sbuf.o
CC slirp/tcp_input.o
CC slirp/tcp_output.o
CC slirp/tcp_subr.o
CC slirp/tcp_timer.o
CC slirp/udp.o
CC slirp/udp6.o
CC slirp/bootp.o
CC slirp/tftp.o
CC slirp/arp_table.o
CC slirp/ndp_table.o
CC slirp/ncsi.o
CC ui/keymaps.o
CC ui/console.o
CC ui/cursor.o
CC ui/qemu-pixman.o
/tmp/qemu-test/src/slirp/tcp_input.c: In function ‘tcp_input’:
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_p’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_len’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_tos’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_id’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_off’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_ttl’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_sum’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_src.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_dst.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:220: warning: ‘save_ip6.ip_nh’ may be used uninitialized in this function
CC ui/input.o
CC ui/input-legacy.o
CC ui/input-keymap.o
CC ui/input-linux.o
CC ui/sdl.o
CC ui/sdl_zoom.o
CC ui/x_keymap.o
CC ui/vnc.o
CC ui/vnc-enc-zlib.o
CC ui/vnc-enc-hextile.o
CC ui/vnc-enc-tight.o
CC ui/vnc-palette.o
CC ui/vnc-enc-zrle.o
CC ui/vnc-auth-vencrypt.o
CC ui/vnc-ws.o
CC ui/vnc-jobs.o
CC chardev/char.o
CC chardev/char-fd.o
CC chardev/char-fe.o
CC chardev/char-file.o
CC chardev/char-io.o
CC chardev/char-mux.o
CC chardev/char-null.o
CC chardev/char-parallel.o
CC chardev/char-pipe.o
CC chardev/char-pty.o
CC chardev/char-ringbuf.o
CC chardev/char-serial.o
CC chardev/char-socket.o
CC chardev/char-stdio.o
CC chardev/char-udp.o
AS optionrom/multiboot.o
AS optionrom/linuxboot.o
CC optionrom/linuxboot_dma.o
cc: unrecognized option '-no-integrated-as'
cc: unrecognized option '-no-integrated-as'
AS optionrom/kvmvapic.o
LINK tests/qemu-iotests/socket_scm_helper
BUILD optionrom/multiboot.img
BUILD optionrom/linuxboot.img
CC qga/commands.o
BUILD optionrom/linuxboot_dma.img
CC qga/guest-agent-command-state.o
BUILD optionrom/kvmvapic.img
CC qga/main.o
BUILD optionrom/multiboot.raw
CC qga/commands-posix.o
BUILD optionrom/linuxboot.raw
CC qga/channel-posix.o
CC qga/qapi-generated/qga-qapi-types.o
CC qga/qapi-generated/qga-qapi-visit.o
CC qga/qapi-generated/qga-qmp-marshal.o
AR libqemuutil.a
AR libqemustub.a
CC qemu-img.o
BUILD optionrom/linuxboot_dma.raw
BUILD optionrom/kvmvapic.raw
SIGN optionrom/multiboot.bin
SIGN optionrom/linuxboot.bin
LINK qemu-io
LINK qemu-bridge-helper
SIGN optionrom/linuxboot_dma.bin
SIGN optionrom/kvmvapic.bin
LINK ivshmem-client
LINK ivshmem-server
LINK qemu-nbd
LINK qemu-img
GEN x86_64-softmmu/hmp-commands.h
GEN x86_64-softmmu/hmp-commands-info.h
GEN aarch64-softmmu/hmp-commands.h
GEN x86_64-softmmu/config-target.h
GEN aarch64-softmmu/hmp-commands-info.h
CC x86_64-softmmu/exec.o
GEN aarch64-softmmu/config-target.h
CC x86_64-softmmu/translate-all.o
CC x86_64-softmmu/cpu-exec.o
CC x86_64-softmmu/translate-common.o
CC x86_64-softmmu/cpu-exec-common.o
CC aarch64-softmmu/exec.o
CC x86_64-softmmu/tcg/tcg.o
CC aarch64-softmmu/translate-all.o
CC x86_64-softmmu/tcg/tcg-op.o
CC x86_64-softmmu/tcg/optimize.o
CC aarch64-softmmu/cpu-exec.o
CC x86_64-softmmu/tcg/tcg-common.o
CC aarch64-softmmu/translate-common.o
CC x86_64-softmmu/fpu/softfloat.o
CC x86_64-softmmu/disas.o
CC aarch64-softmmu/cpu-exec-common.o
CC aarch64-softmmu/tcg/tcg.o
CC x86_64-softmmu/tcg-runtime.o
CC x86_64-softmmu/hax-stub.o
GEN x86_64-softmmu/gdbstub-xml.c
CC x86_64-softmmu/arch_init.o
CC aarch64-softmmu/tcg/tcg-op.o
CC aarch64-softmmu/tcg/optimize.o
CC x86_64-softmmu/cpus.o
CC x86_64-softmmu/monitor.o
CC x86_64-softmmu/gdbstub.o
CC aarch64-softmmu/tcg/tcg-common.o
CC x86_64-softmmu/balloon.o
CC aarch64-softmmu/fpu/softfloat.o
CC aarch64-softmmu/disas.o
CC aarch64-softmmu/tcg-runtime.o
GEN aarch64-softmmu/gdbstub-xml.c
CC aarch64-softmmu/hax-stub.o
CC aarch64-softmmu/kvm-stub.o
CC aarch64-softmmu/arch_init.o
CC aarch64-softmmu/cpus.o
CC aarch64-softmmu/monitor.o
CC aarch64-softmmu/gdbstub.o
CC aarch64-softmmu/balloon.o
CC aarch64-softmmu/ioport.o
CC x86_64-softmmu/ioport.o
CC aarch64-softmmu/numa.o
CC x86_64-softmmu/numa.o
CC aarch64-softmmu/qtest.o
CC x86_64-softmmu/qtest.o
CC x86_64-softmmu/bootdevice.o
CC aarch64-softmmu/bootdevice.o
CC x86_64-softmmu/kvm-all.o
CC x86_64-softmmu/memory.o
CC x86_64-softmmu/cputlb.o
CC aarch64-softmmu/memory.o
LINK qemu-ga
CC x86_64-softmmu/memory_mapping.o
CC aarch64-softmmu/cputlb.o
CC aarch64-softmmu/memory_mapping.o
CC x86_64-softmmu/dump.o
CC x86_64-softmmu/migration/ram.o
CC x86_64-softmmu/hw/block/virtio-blk.o
CC x86_64-softmmu/hw/block/dataplane/virtio-blk.o
CC x86_64-softmmu/hw/char/virtio-serial-bus.o
CC aarch64-softmmu/dump.o
CC x86_64-softmmu/hw/core/generic-loader.o
CC aarch64-softmmu/migration/ram.o
CC aarch64-softmmu/hw/adc/stm32f2xx_adc.o
CC x86_64-softmmu/hw/core/null-machine.o
CC aarch64-softmmu/hw/block/virtio-blk.o
CC aarch64-softmmu/hw/block/dataplane/virtio-blk.o
CC x86_64-softmmu/hw/cpu/core.o
CC aarch64-softmmu/hw/char/exynos4210_uart.o
CC aarch64-softmmu/hw/char/omap_uart.o
CC x86_64-softmmu/hw/display/vga.o
CC x86_64-softmmu/hw/display/virtio-gpu.o
CC aarch64-softmmu/hw/char/digic-uart.o
CC x86_64-softmmu/hw/display/virtio-gpu-3d.o
CC aarch64-softmmu/hw/char/stm32f2xx_usart.o
CC aarch64-softmmu/hw/char/bcm2835_aux.o
CC x86_64-softmmu/hw/display/virtio-gpu-pci.o
CC x86_64-softmmu/hw/display/virtio-vga.o
CC aarch64-softmmu/hw/char/virtio-serial-bus.o
CC x86_64-softmmu/hw/intc/apic.o
CC aarch64-softmmu/hw/core/generic-loader.o
CC x86_64-softmmu/hw/intc/apic_common.o
CC x86_64-softmmu/hw/intc/ioapic.o
CC aarch64-softmmu/hw/core/null-machine.o
CC x86_64-softmmu/hw/isa/lpc_ich9.o
CC aarch64-softmmu/hw/cpu/arm11mpcore.o
CC aarch64-softmmu/hw/cpu/realview_mpcore.o
CC x86_64-softmmu/hw/misc/vmport.o
CC aarch64-softmmu/hw/cpu/a9mpcore.o
CC aarch64-softmmu/hw/cpu/a15mpcore.o
CC x86_64-softmmu/hw/misc/ivshmem.o
CC x86_64-softmmu/hw/misc/pvpanic.o
CC aarch64-softmmu/hw/cpu/core.o
CC aarch64-softmmu/hw/display/omap_dss.o
CC x86_64-softmmu/hw/misc/edu.o
CC x86_64-softmmu/hw/misc/hyperv_testdev.o
CC aarch64-softmmu/hw/display/omap_lcdc.o
CC aarch64-softmmu/hw/display/pxa2xx_lcd.o
CC aarch64-softmmu/hw/display/bcm2835_fb.o
CC aarch64-softmmu/hw/display/vga.o
CC x86_64-softmmu/hw/net/virtio-net.o
CC aarch64-softmmu/hw/display/virtio-gpu.o
CC x86_64-softmmu/hw/net/vhost_net.o
CC x86_64-softmmu/hw/scsi/virtio-scsi.o
CC aarch64-softmmu/hw/display/virtio-gpu-3d.o
CC x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
CC x86_64-softmmu/hw/scsi/vhost-scsi-common.o
CC x86_64-softmmu/hw/scsi/vhost-scsi.o
CC x86_64-softmmu/hw/timer/mc146818rtc.o
CC aarch64-softmmu/hw/display/virtio-gpu-pci.o
CC x86_64-softmmu/hw/vfio/common.o
CC aarch64-softmmu/hw/display/dpcd.o
CC x86_64-softmmu/hw/vfio/pci.o
CC x86_64-softmmu/hw/vfio/pci-quirks.o
CC x86_64-softmmu/hw/vfio/platform.o
CC x86_64-softmmu/hw/vfio/spapr.o
CC aarch64-softmmu/hw/display/xlnx_dp.o
CC aarch64-softmmu/hw/dma/xlnx_dpdma.o
CC aarch64-softmmu/hw/dma/omap_dma.o
CC x86_64-softmmu/hw/virtio/virtio.o
CC x86_64-softmmu/hw/virtio/virtio-balloon.o
CC aarch64-softmmu/hw/dma/soc_dma.o
CC x86_64-softmmu/hw/virtio/vhost.o
CC x86_64-softmmu/hw/virtio/vhost-backend.o
CC aarch64-softmmu/hw/dma/pxa2xx_dma.o
CC x86_64-softmmu/hw/virtio/vhost-user.o
CC aarch64-softmmu/hw/dma/bcm2835_dma.o
CC x86_64-softmmu/hw/virtio/vhost-vsock.o
CC aarch64-softmmu/hw/gpio/omap_gpio.o
CC x86_64-softmmu/hw/virtio/virtio-crypto.o
CC aarch64-softmmu/hw/gpio/imx_gpio.o
CC aarch64-softmmu/hw/gpio/bcm2835_gpio.o
CC aarch64-softmmu/hw/i2c/omap_i2c.o
CC aarch64-softmmu/hw/input/pxa2xx_keypad.o
CC x86_64-softmmu/hw/virtio/virtio-crypto-pci.o
CC aarch64-softmmu/hw/input/tsc210x.o
CC aarch64-softmmu/hw/intc/armv7m_nvic.o
CC x86_64-softmmu/hw/i386/multiboot.o
CC x86_64-softmmu/hw/i386/pc.o
CC x86_64-softmmu/hw/i386/pc_piix.o
CC x86_64-softmmu/hw/i386/pc_q35.o
CC aarch64-softmmu/hw/intc/exynos4210_gic.o
CC aarch64-softmmu/hw/intc/exynos4210_combiner.o
CC x86_64-softmmu/hw/i386/pc_sysfw.o
CC aarch64-softmmu/hw/intc/omap_intc.o
CC aarch64-softmmu/hw/intc/bcm2835_ic.o
CC x86_64-softmmu/hw/i386/x86-iommu.o
CC aarch64-softmmu/hw/intc/bcm2836_control.o
CC aarch64-softmmu/hw/intc/allwinner-a10-pic.o
CC aarch64-softmmu/hw/intc/aspeed_vic.o
CC x86_64-softmmu/hw/i386/intel_iommu.o
CC x86_64-softmmu/hw/i386/amd_iommu.o
CC aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
CC aarch64-softmmu/hw/misc/ivshmem.o
CC aarch64-softmmu/hw/misc/arm_sysctl.o
CC aarch64-softmmu/hw/misc/cbus.o
CC aarch64-softmmu/hw/misc/exynos4210_pmu.o
CC x86_64-softmmu/hw/i386/kvmvapic.o
CC x86_64-softmmu/hw/i386/acpi-build.o
CC x86_64-softmmu/hw/i386/pci-assign-load-rom.o
CC x86_64-softmmu/hw/i386/kvm/clock.o
CC aarch64-softmmu/hw/misc/exynos4210_clk.o
/tmp/qemu-test/src/hw/i386/pc_piix.c: In function ‘igd_passthrough_isa_bridge_create’:
/tmp/qemu-test/src/hw/i386/pc_piix.c:1067: warning: ‘pch_rev_id’ may be used uninitialized in this function
CC x86_64-softmmu/hw/i386/kvm/apic.o
CC x86_64-softmmu/hw/i386/kvm/i8259.o
CC x86_64-softmmu/hw/i386/kvm/ioapic.o
CC aarch64-softmmu/hw/misc/imx_ccm.o
CC x86_64-softmmu/hw/i386/kvm/i8254.o
CC aarch64-softmmu/hw/misc/imx31_ccm.o
CC aarch64-softmmu/hw/misc/imx25_ccm.o
CC aarch64-softmmu/hw/misc/imx6_ccm.o
CC x86_64-softmmu/hw/i386/kvm/pci-assign.o
CC aarch64-softmmu/hw/misc/imx6_src.o
CC aarch64-softmmu/hw/misc/mst_fpga.o
/tmp/qemu-test/src/hw/i386/acpi-build.c: In function ‘build_append_pci_bus_devices’:
/tmp/qemu-test/src/hw/i386/acpi-build.c:525: warning: ‘notify_method’ may be used uninitialized in this function
CC aarch64-softmmu/hw/misc/omap_clk.o
CC aarch64-softmmu/hw/misc/omap_gpmc.o
CC aarch64-softmmu/hw/misc/omap_l4.o
CC aarch64-softmmu/hw/misc/omap_sdrc.o
CC aarch64-softmmu/hw/misc/omap_tap.o
CC x86_64-softmmu/target/i386/translate.o
CC aarch64-softmmu/hw/misc/bcm2835_mbox.o
CC aarch64-softmmu/hw/misc/bcm2835_property.o
CC aarch64-softmmu/hw/misc/bcm2835_rng.o
CC aarch64-softmmu/hw/misc/zynq_slcr.o
CC aarch64-softmmu/hw/misc/zynq-xadc.o
CC x86_64-softmmu/target/i386/helper.o
CC aarch64-softmmu/hw/misc/stm32f2xx_syscfg.o
CC x86_64-softmmu/target/i386/cpu.o
CC x86_64-softmmu/target/i386/bpt_helper.o
CC x86_64-softmmu/target/i386/excp_helper.o
CC aarch64-softmmu/hw/misc/edu.o
CC x86_64-softmmu/target/i386/fpu_helper.o
CC aarch64-softmmu/hw/misc/auxbus.o
CC aarch64-softmmu/hw/misc/aspeed_scu.o
CC aarch64-softmmu/hw/misc/aspeed_sdmc.o
CC x86_64-softmmu/target/i386/cc_helper.o
CC aarch64-softmmu/hw/net/virtio-net.o
CC aarch64-softmmu/hw/net/vhost_net.o
CC x86_64-softmmu/target/i386/int_helper.o
CC x86_64-softmmu/target/i386/svm_helper.o
CC aarch64-softmmu/hw/pcmcia/pxa2xx.o
CC aarch64-softmmu/hw/scsi/virtio-scsi.o
CC aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
CC aarch64-softmmu/hw/scsi/vhost-scsi-common.o
CC aarch64-softmmu/hw/sd/omap_mmc.o
CC aarch64-softmmu/hw/scsi/vhost-scsi.o
CC x86_64-softmmu/target/i386/misc_helper.o
CC x86_64-softmmu/target/i386/smm_helper.o
CC aarch64-softmmu/hw/sd/pxa2xx_mmci.o
CC x86_64-softmmu/target/i386/mem_helper.o
CC aarch64-softmmu/hw/sd/bcm2835_sdhost.o
CC aarch64-softmmu/hw/ssi/omap_spi.o
CC aarch64-softmmu/hw/ssi/imx_spi.o
CC x86_64-softmmu/target/i386/seg_helper.o
CC aarch64-softmmu/hw/timer/exynos4210_mct.o
CC aarch64-softmmu/hw/timer/exynos4210_pwm.o
CC aarch64-softmmu/hw/timer/exynos4210_rtc.o
CC x86_64-softmmu/target/i386/mpx_helper.o
CC x86_64-softmmu/target/i386/gdbstub.o
CC aarch64-softmmu/hw/timer/omap_gptimer.o
CC x86_64-softmmu/target/i386/machine.o
CC x86_64-softmmu/target/i386/arch_memory_mapping.o
CC aarch64-softmmu/hw/timer/omap_synctimer.o
CC x86_64-softmmu/target/i386/arch_dump.o
CC aarch64-softmmu/hw/timer/pxa2xx_timer.o
CC x86_64-softmmu/target/i386/monitor.o
CC aarch64-softmmu/hw/timer/digic-timer.o
CC aarch64-softmmu/hw/timer/allwinner-a10-pit.o
CC x86_64-softmmu/target/i386/kvm.o
CC x86_64-softmmu/target/i386/hyperv.o
CC aarch64-softmmu/hw/usb/tusb6010.o
CC aarch64-softmmu/hw/vfio/common.o
GEN trace/generated-helpers.c
CC x86_64-softmmu/trace/control-target.o
CC aarch64-softmmu/hw/vfio/pci.o
CC aarch64-softmmu/hw/vfio/pci-quirks.o
CC aarch64-softmmu/hw/vfio/platform.o
CC x86_64-softmmu/gdbstub-xml.o
CC aarch64-softmmu/hw/vfio/calxeda-xgmac.o
CC x86_64-softmmu/trace/generated-helpers.o
CC aarch64-softmmu/hw/vfio/amd-xgbe.o
CC aarch64-softmmu/hw/virtio/virtio.o
CC aarch64-softmmu/hw/vfio/spapr.o
CC aarch64-softmmu/hw/virtio/vhost-backend.o
CC aarch64-softmmu/hw/virtio/virtio-balloon.o
CC aarch64-softmmu/hw/virtio/vhost.o
CC aarch64-softmmu/hw/virtio/vhost-user.o
LINK x86_64-softmmu/qemu-system-x86_64
CC aarch64-softmmu/hw/virtio/vhost-vsock.o
CC aarch64-softmmu/hw/virtio/virtio-crypto.o
CC aarch64-softmmu/hw/virtio/virtio-crypto-pci.o
CC aarch64-softmmu/hw/arm/boot.o
CC aarch64-softmmu/hw/arm/collie.o
CC aarch64-softmmu/hw/arm/exynos4_boards.o
CC aarch64-softmmu/hw/arm/gumstix.o
CC aarch64-softmmu/hw/arm/highbank.o
CC aarch64-softmmu/hw/arm/digic_boards.o
CC aarch64-softmmu/hw/arm/integratorcp.o
CC aarch64-softmmu/hw/arm/musicpal.o
CC aarch64-softmmu/hw/arm/mainstone.o
CC aarch64-softmmu/hw/arm/nseries.o
CC aarch64-softmmu/hw/arm/omap_sx1.o
CC aarch64-softmmu/hw/arm/palm.o
CC aarch64-softmmu/hw/arm/realview.o
CC aarch64-softmmu/hw/arm/spitz.o
CC aarch64-softmmu/hw/arm/stellaris.o
CC aarch64-softmmu/hw/arm/tosa.o
CC aarch64-softmmu/hw/arm/versatilepb.o
CC aarch64-softmmu/hw/arm/vexpress.o
CC aarch64-softmmu/hw/arm/virt.o
CC aarch64-softmmu/hw/arm/xilinx_zynq.o
CC aarch64-softmmu/hw/arm/z2.o
CC aarch64-softmmu/hw/arm/virt-acpi-build.o
CC aarch64-softmmu/hw/arm/netduino2.o
CC aarch64-softmmu/hw/arm/sysbus-fdt.o
CC aarch64-softmmu/hw/arm/armv7m.o
CC aarch64-softmmu/hw/arm/exynos4210.o
CC aarch64-softmmu/hw/arm/pxa2xx.o
CC aarch64-softmmu/hw/arm/pxa2xx_gpio.o
CC aarch64-softmmu/hw/arm/pxa2xx_pic.o
CC aarch64-softmmu/hw/arm/digic.o
CC aarch64-softmmu/hw/arm/omap1.o
CC aarch64-softmmu/hw/arm/omap2.o
CC aarch64-softmmu/hw/arm/strongarm.o
CC aarch64-softmmu/hw/arm/allwinner-a10.o
CC aarch64-softmmu/hw/arm/cubieboard.o
CC aarch64-softmmu/hw/arm/bcm2835_peripherals.o
CC aarch64-softmmu/hw/arm/raspi.o
CC aarch64-softmmu/hw/arm/bcm2836.o
CC aarch64-softmmu/hw/arm/stm32f205_soc.o
CC aarch64-softmmu/hw/arm/xlnx-zynqmp.o
CC aarch64-softmmu/hw/arm/xlnx-ep108.o
CC aarch64-softmmu/hw/arm/fsl-imx25.o
CC aarch64-softmmu/hw/arm/imx25_pdk.o
CC aarch64-softmmu/hw/arm/fsl-imx31.o
CC aarch64-softmmu/hw/arm/kzm.o
CC aarch64-softmmu/hw/arm/fsl-imx6.o
CC aarch64-softmmu/hw/arm/sabrelite.o
CC aarch64-softmmu/hw/arm/aspeed_soc.o
CC aarch64-softmmu/hw/arm/aspeed.o
CC aarch64-softmmu/target/arm/arm-semi.o
CC aarch64-softmmu/target/arm/machine.o
CC aarch64-softmmu/target/arm/psci.o
CC aarch64-softmmu/target/arm/monitor.o
CC aarch64-softmmu/target/arm/arch_dump.o
CC aarch64-softmmu/target/arm/op_helper.o
CC aarch64-softmmu/target/arm/kvm-stub.o
CC aarch64-softmmu/target/arm/helper.o
CC aarch64-softmmu/target/arm/translate.o
CC aarch64-softmmu/target/arm/cpu.o
CC aarch64-softmmu/target/arm/neon_helper.o
CC aarch64-softmmu/target/arm/iwmmxt_helper.o
CC aarch64-softmmu/target/arm/gdbstub.o
CC aarch64-softmmu/target/arm/translate-a64.o
CC aarch64-softmmu/target/arm/gdbstub64.o
CC aarch64-softmmu/target/arm/crypto_helper.o
CC aarch64-softmmu/target/arm/helper-a64.o
CC aarch64-softmmu/target/arm/cpu64.o
CC aarch64-softmmu/target/arm/arm-powerctl.o
CC aarch64-softmmu/trace/control-target.o
CC aarch64-softmmu/gdbstub-xml.o
GEN trace/generated-helpers.c
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘handle_shri_with_rndacc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:6365: warning: ‘tcg_src_hi’ may be used uninitialized in this function
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘disas_simd_scalar_two_reg_misc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:8092: warning: ‘rmode’ may be used uninitialized in this function
CC aarch64-softmmu/trace/generated-helpers.o
LINK aarch64-softmmu/qemu-system-aarch64
BISON dtc-parser.tab.c
make[1]: bison: Command not found
LEX convert-dtsv0-lexer.lex.c
LEX dtc-lexer.lex.c
make[1]: flex: Command not found
make[1]: flex: Command not found
TEST tests/qapi-schema/alternate-any.out
TEST tests/qapi-schema/alternate-array.out
TEST tests/qapi-schema/alternate-base.out
TEST tests/qapi-schema/alternate-conflict-dict.out
TEST tests/qapi-schema/alternate-clash.out
TEST tests/qapi-schema/alternate-conflict-enum-int.out
TEST tests/qapi-schema/alternate-conflict-enum-bool.out
TEST tests/qapi-schema/alternate-conflict-string.out
TEST tests/qapi-schema/alternate-empty.out
TEST tests/qapi-schema/alternate-unknown.out
TEST tests/qapi-schema/args-alternate.out
TEST tests/qapi-schema/args-any.out
TEST tests/qapi-schema/alternate-nested.out
TEST tests/qapi-schema/args-array-empty.out
TEST tests/qapi-schema/args-array-unknown.out
TEST tests/qapi-schema/args-bad-boxed.out
TEST tests/qapi-schema/args-boxed-anon.out
TEST tests/qapi-schema/args-boxed-empty.out
TEST tests/qapi-schema/args-boxed-string.out
TEST tests/qapi-schema/args-int.out
TEST tests/qapi-schema/args-invalid.out
TEST tests/qapi-schema/args-member-array-bad.out
TEST tests/qapi-schema/args-member-case.out
TEST tests/qapi-schema/args-member-unknown.out
TEST tests/qapi-schema/args-name-clash.out
TEST tests/qapi-schema/args-unknown.out
TEST tests/qapi-schema/bad-base.out
TEST tests/qapi-schema/bad-data.out
TEST tests/qapi-schema/args-union.out
TEST tests/qapi-schema/bad-ident.out
TEST tests/qapi-schema/bad-type-bool.out
TEST tests/qapi-schema/bad-type-dict.out
TEST tests/qapi-schema/bad-type-int.out
TEST tests/qapi-schema/base-cycle-direct.out
TEST tests/qapi-schema/base-cycle-indirect.out
TEST tests/qapi-schema/command-int.out
TEST tests/qapi-schema/doc-bad-alternate-member.out
TEST tests/qapi-schema/comments.out
TEST tests/qapi-schema/doc-bad-command-arg.out
TEST tests/qapi-schema/doc-bad-symbol.out
TEST tests/qapi-schema/doc-bad-union-member.out
TEST tests/qapi-schema/doc-before-include.out
TEST tests/qapi-schema/doc-before-pragma.out
TEST tests/qapi-schema/doc-duplicated-arg.out
TEST tests/qapi-schema/doc-duplicated-return.out
TEST tests/qapi-schema/doc-duplicated-since.out
TEST tests/qapi-schema/doc-empty-arg.out
TEST tests/qapi-schema/doc-empty-section.out
TEST tests/qapi-schema/doc-empty-symbol.out
TEST tests/qapi-schema/doc-good.out
TEST tests/qapi-schema/doc-interleaved-section.out
TEST tests/qapi-schema/doc-invalid-end.out
TEST tests/qapi-schema/doc-invalid-end2.out
TEST tests/qapi-schema/doc-invalid-return.out
TEST tests/qapi-schema/doc-invalid-section.out
TEST tests/qapi-schema/doc-invalid-start.out
TEST tests/qapi-schema/doc-missing.out
TEST tests/qapi-schema/doc-missing-colon.out
TEST tests/qapi-schema/doc-missing-expr.out
TEST tests/qapi-schema/doc-missing-space.out
TEST tests/qapi-schema/double-data.out
TEST tests/qapi-schema/doc-no-symbol.out
TEST tests/qapi-schema/double-type.out
TEST tests/qapi-schema/duplicate-key.out
TEST tests/qapi-schema/empty.out
TEST tests/qapi-schema/enum-bad-name.out
TEST tests/qapi-schema/enum-bad-prefix.out
TEST tests/qapi-schema/enum-clash-member.out
TEST tests/qapi-schema/enum-dict-member.out
TEST tests/qapi-schema/enum-int-member.out
TEST tests/qapi-schema/enum-member-case.out
TEST tests/qapi-schema/enum-missing-data.out
TEST tests/qapi-schema/enum-wrong-data.out
TEST tests/qapi-schema/escape-outside-string.out
TEST tests/qapi-schema/escape-too-big.out
TEST tests/qapi-schema/escape-too-short.out
TEST tests/qapi-schema/event-boxed-empty.out
TEST tests/qapi-schema/event-case.out
TEST tests/qapi-schema/event-nest-struct.out
TEST tests/qapi-schema/flat-union-array-branch.out
TEST tests/qapi-schema/flat-union-bad-base.out
TEST tests/qapi-schema/flat-union-bad-discriminator.out
TEST tests/qapi-schema/flat-union-base-any.out
TEST tests/qapi-schema/flat-union-base-union.out
TEST tests/qapi-schema/flat-union-clash-member.out
TEST tests/qapi-schema/flat-union-incomplete-branch.out
TEST tests/qapi-schema/flat-union-empty.out
TEST tests/qapi-schema/flat-union-inline.out
TEST tests/qapi-schema/flat-union-int-branch.out
TEST tests/qapi-schema/flat-union-invalid-branch-key.out
TEST tests/qapi-schema/flat-union-invalid-discriminator.out
TEST tests/qapi-schema/flat-union-no-base.out
TEST tests/qapi-schema/flat-union-optional-discriminator.out
TEST tests/qapi-schema/flat-union-string-discriminator.out
TEST tests/qapi-schema/funny-char.out
TEST tests/qapi-schema/ident-with-escape.out
TEST tests/qapi-schema/include-before-err.out
TEST tests/qapi-schema/include-cycle.out
TEST tests/qapi-schema/include-extra-junk.out
TEST tests/qapi-schema/include-format-err.out
TEST tests/qapi-schema/include-nested-err.out
TEST tests/qapi-schema/include-no-file.out
TEST tests/qapi-schema/include-non-file.out
TEST tests/qapi-schema/include-relpath.out
TEST tests/qapi-schema/include-repetition.out
TEST tests/qapi-schema/include-self-cycle.out
TEST tests/qapi-schema/include-simple.out
TEST tests/qapi-schema/indented-expr.out
TEST tests/qapi-schema/leading-comma-list.out
TEST tests/qapi-schema/leading-comma-object.out
TEST tests/qapi-schema/missing-colon.out
TEST tests/qapi-schema/missing-comma-list.out
TEST tests/qapi-schema/missing-type.out
TEST tests/qapi-schema/missing-comma-object.out
TEST tests/qapi-schema/nested-struct-data.out
TEST tests/qapi-schema/non-objects.out
TEST tests/qapi-schema/pragma-doc-required-crap.out
TEST tests/qapi-schema/pragma-extra-junk.out
TEST tests/qapi-schema/pragma-name-case-whitelist-crap.out
TEST tests/qapi-schema/pragma-non-dict.out
TEST tests/qapi-schema/pragma-returns-whitelist-crap.out
TEST tests/qapi-schema/qapi-schema-test.out
TEST tests/qapi-schema/quoted-structural-chars.out
TEST tests/qapi-schema/redefined-builtin.out
TEST tests/qapi-schema/redefined-command.out
TEST tests/qapi-schema/redefined-event.out
TEST tests/qapi-schema/redefined-type.out
TEST tests/qapi-schema/reserved-command-q.out
TEST tests/qapi-schema/reserved-enum-q.out
TEST tests/qapi-schema/reserved-member-has.out
TEST tests/qapi-schema/reserved-member-q.out
TEST tests/qapi-schema/reserved-member-u.out
TEST tests/qapi-schema/reserved-member-underscore.out
TEST tests/qapi-schema/reserved-type-kind.out
TEST tests/qapi-schema/reserved-type-list.out
TEST tests/qapi-schema/returns-alternate.out
TEST tests/qapi-schema/returns-array-bad.out
TEST tests/qapi-schema/returns-dict.out
TEST tests/qapi-schema/returns-unknown.out
TEST tests/qapi-schema/returns-whitelist.out
TEST tests/qapi-schema/struct-base-clash-deep.out
TEST tests/qapi-schema/struct-base-clash.out
TEST tests/qapi-schema/struct-data-invalid.out
TEST tests/qapi-schema/struct-member-invalid.out
TEST tests/qapi-schema/trailing-comma-list.out
TEST tests/qapi-schema/trailing-comma-object.out
TEST tests/qapi-schema/type-bypass-bad-gen.out
TEST tests/qapi-schema/unclosed-list.out
TEST tests/qapi-schema/unclosed-object.out
TEST tests/qapi-schema/unclosed-string.out
TEST tests/qapi-schema/unicode-str.out
TEST tests/qapi-schema/union-base-empty.out
TEST tests/qapi-schema/union-base-no-discriminator.out
TEST tests/qapi-schema/union-branch-case.out
TEST tests/qapi-schema/union-clash-branches.out
TEST tests/qapi-schema/union-empty.out
TEST tests/qapi-schema/union-invalid-base.out
TEST tests/qapi-schema/union-optional-branch.out
TEST tests/qapi-schema/union-unknown.out
TEST tests/qapi-schema/unknown-escape.out
TEST tests/qapi-schema/unknown-expr-key.out
GEN tests/qapi-schema/doc-good.test.texi
CC tests/check-qdict.o
CC tests/test-char.o
CC tests/check-qnum.o
CC tests/check-qlist.o
CC tests/check-qstring.o
CC tests/check-qnull.o
CC tests/check-qjson.o
CC tests/test-qobject-output-visitor.o
GEN tests/test-qapi-visit.c
GEN tests/test-qapi-types.c
GEN tests/test-qapi-event.c
GEN tests/test-qmp-introspect.c
CC tests/test-clone-visitor.o
CC tests/test-qobject-input-visitor.o
CC tests/test-qmp-commands.o
GEN tests/test-qmp-marshal.c
CC tests/test-string-input-visitor.o
CC tests/test-string-output-visitor.o
CC tests/test-qmp-event.o
CC tests/test-opts-visitor.o
CC tests/test-coroutine.o
CC tests/iothread.o
CC tests/test-visitor-serialization.o
CC tests/test-iov.o
CC tests/test-aio.o
CC tests/test-aio-multithread.o
CC tests/test-throttle.o
CC tests/test-thread-pool.o
CC tests/test-hbitmap.o
CC tests/test-blockjob.o
CC tests/test-blockjob-txn.o
CC tests/test-x86-cpuid.o
CC tests/test-xbzrle.o
CC tests/test-vmstate.o
CC tests/test-cutils.o
CC tests/test-shift128.o
CC tests/test-mul64.o
CC tests/test-int128.o
/tmp/qemu-test/src/tests/test-int128.c:180: warning: ‘__noclone__’ attribute directive ignored
CC tests/rcutorture.o
CC tests/test-rcu-list.o
CC tests/test-qdist.o
CC tests/test-qht.o
CC tests/test-qht-par.o
CC tests/qht-bench.o
CC tests/test-bitops.o
CC tests/test-bitcnt.o
CC tests/check-qom-proplist.o
CC tests/check-qom-interface.o
CC tests/test-qemu-opts.o
CC tests/test-keyval.o
CC tests/test-write-threshold.o
CC tests/test-crypto-hash.o
CC tests/test-crypto-hmac.o
CC tests/test-crypto-cipher.o
CC tests/test-crypto-secret.o
CC tests/test-qga.o
CC tests/libqtest.o
CC tests/test-timed-average.o
CC tests/test-io-task.o
CC tests/test-io-channel-socket.o
CC tests/io-channel-helpers.o
CC tests/test-io-channel-file.o
CC tests/test-io-channel-command.o
CC tests/test-io-channel-buffer.o
CC tests/test-base64.o
CC tests/test-crypto-ivgen.o
CC tests/test-crypto-afsplit.o
CC tests/test-crypto-xts.o
CC tests/test-crypto-block.o
CC tests/test-logging.o
CC tests/test-replication.o
CC tests/test-bufferiszero.o
CC tests/ptimer-test.o
CC tests/test-uuid.o
CC tests/ptimer-test-stubs.o
CC tests/test-qapi-util.o
CC tests/vhost-user-test.o
CC tests/libqos/pci.o
CC tests/libqos/fw_cfg.o
CC tests/libqos/malloc.o
CC tests/libqos/i2c.o
CC tests/libqos/libqos.o
CC tests/libqos/malloc-spapr.o
CC tests/libqos/libqos-spapr.o
CC tests/libqos/rtas.o
CC tests/libqos/pci-spapr.o
CC tests/libqos/pci-pc.o
CC tests/libqos/malloc-pc.o
CC tests/libqos/libqos-pc.o
CC tests/libqos/ahci.o
CC tests/libqos/virtio.o
CC tests/libqos/virtio-pci.o
CC tests/libqos/virtio-mmio.o
CC tests/libqos/malloc-generic.o
CC tests/endianness-test.o
CC tests/fdc-test.o
CC tests/ide-test.o
CC tests/ahci-test.o
CC tests/hd-geo-test.o
CC tests/boot-order-test.o
CC tests/bios-tables-test.o
CC tests/boot-sector.o
CC tests/acpi-utils.o
CC tests/boot-serial-test.o
CC tests/pxe-test.o
CC tests/rtc-test.o
CC tests/ipmi-kcs-test.o
CC tests/ipmi-bt-test.o
CC tests/i440fx-test.o
CC tests/fw_cfg-test.o
CC tests/drive_del-test.o
CC tests/wdt_ib700-test.o
CC tests/tco-test.o
CC tests/e1000-test.o
CC tests/e1000e-test.o
CC tests/rtl8139-test.o
CC tests/pcnet-test.o
CC tests/eepro100-test.o
CC tests/ne2000-test.o
CC tests/nvme-test.o
CC tests/ac97-test.o
CC tests/es1370-test.o
CC tests/virtio-net-test.o
CC tests/virtio-balloon-test.o
CC tests/virtio-blk-test.o
CC tests/virtio-rng-test.o
CC tests/virtio-scsi-test.o
CC tests/virtio-serial-test.o
CC tests/virtio-console-test.o
CC tests/tpci200-test.o
CC tests/ipoctal232-test.o
CC tests/display-vga-test.o
CC tests/intel-hda-test.o
CC tests/ivshmem-test.o
CC tests/vmxnet3-test.o
CC tests/pvpanic-test.o
CC tests/i82801b11-test.o
CC tests/ioh3420-test.o
CC tests/usb-hcd-ohci-test.o
CC tests/libqos/usb.o
CC tests/usb-hcd-uhci-test.o
CC tests/usb-hcd-ehci-test.o
CC tests/usb-hcd-xhci-test.o
CC tests/pc-cpu-test.o
CC tests/q35-test.o
CC tests/test-netfilter.o
CC tests/test-filter-mirror.o
CC tests/test-filter-redirector.o
CC tests/postcopy-test.o
CC tests/test-x86-cpuid-compat.o
CC tests/numa-test.o
CC tests/qmp-test.o
CC tests/device-introspect-test.o
CC tests/qom-test.o
CC tests/test-hmp.o
LINK tests/check-qdict
LINK tests/test-char
LINK tests/check-qnum
LINK tests/check-qstring
LINK tests/check-qlist
LINK tests/check-qnull
CC tests/test-qapi-types.o
CC tests/test-qapi-visit.o
CC tests/test-qmp-introspect.o
CC tests/test-qapi-event.o
LINK tests/check-qjson
CC tests/test-qmp-marshal.o
LINK tests/test-coroutine
LINK tests/test-iov
LINK tests/test-aio
LINK tests/test-aio-multithread
LINK tests/test-throttle
LINK tests/test-thread-pool
LINK tests/test-hbitmap
LINK tests/test-blockjob
LINK tests/test-blockjob-txn
LINK tests/test-x86-cpuid
LINK tests/test-xbzrle
LINK tests/test-vmstate
LINK tests/test-cutils
LINK tests/test-shift128
LINK tests/test-int128
LINK tests/test-mul64
LINK tests/rcutorture
LINK tests/test-rcu-list
LINK tests/test-qdist
LINK tests/test-qht
LINK tests/qht-bench
LINK tests/test-bitops
LINK tests/test-bitcnt
LINK tests/check-qom-interface
LINK tests/check-qom-proplist
LINK tests/test-qemu-opts
LINK tests/test-keyval
LINK tests/test-write-threshold
LINK tests/test-crypto-hash
LINK tests/test-crypto-hmac
LINK tests/test-crypto-cipher
LINK tests/test-crypto-secret
LINK tests/test-qga
LINK tests/test-timed-average
LINK tests/test-io-task
LINK tests/test-io-channel-socket
LINK tests/test-io-channel-file
LINK tests/test-io-channel-command
LINK tests/test-io-channel-buffer
LINK tests/test-base64
LINK tests/test-crypto-ivgen
LINK tests/test-crypto-afsplit
LINK tests/test-crypto-xts
LINK tests/test-crypto-block
LINK tests/test-logging
LINK tests/test-replication
LINK tests/test-bufferiszero
LINK tests/test-uuid
LINK tests/ptimer-test
LINK tests/test-qapi-util
LINK tests/vhost-user-test
LINK tests/endianness-test
LINK tests/fdc-test
LINK tests/ide-test
LINK tests/ahci-test
LINK tests/hd-geo-test
LINK tests/boot-order-test
LINK tests/bios-tables-test
LINK tests/boot-serial-test
LINK tests/pxe-test
LINK tests/rtc-test
LINK tests/ipmi-kcs-test
LINK tests/ipmi-bt-test
LINK tests/i440fx-test
LINK tests/fw_cfg-test
LINK tests/drive_del-test
LINK tests/wdt_ib700-test
LINK tests/tco-test
LINK tests/e1000-test
LINK tests/e1000e-test
LINK tests/rtl8139-test
LINK tests/pcnet-test
LINK tests/eepro100-test
LINK tests/ne2000-test
LINK tests/nvme-test
LINK tests/ac97-test
LINK tests/es1370-test
LINK tests/virtio-net-test
LINK tests/virtio-balloon-test
LINK tests/virtio-blk-test
LINK tests/virtio-rng-test
LINK tests/virtio-scsi-test
LINK tests/virtio-serial-test
LINK tests/virtio-console-test
LINK tests/tpci200-test
LINK tests/ipoctal232-test
LINK tests/display-vga-test
LINK tests/intel-hda-test
LINK tests/ivshmem-test
LINK tests/vmxnet3-test
LINK tests/pvpanic-test
LINK tests/i82801b11-test
LINK tests/ioh3420-test
LINK tests/usb-hcd-ohci-test
LINK tests/usb-hcd-uhci-test
LINK tests/usb-hcd-ehci-test
LINK tests/usb-hcd-xhci-test
LINK tests/pc-cpu-test
LINK tests/q35-test
LINK tests/test-netfilter
LINK tests/test-filter-mirror
LINK tests/test-filter-redirector
LINK tests/postcopy-test
LINK tests/test-x86-cpuid-compat
LINK tests/numa-test
LINK tests/qmp-test
LINK tests/device-introspect-test
LINK tests/qom-test
LINK tests/test-hmp
GTESTER tests/check-qdict
GTESTER tests/test-char
GTESTER tests/check-qlist
GTESTER tests/check-qstring
GTESTER tests/check-qnull
GTESTER tests/check-qnum
GTESTER tests/check-qjson
LINK tests/test-qobject-output-visitor
LINK tests/test-clone-visitor
LINK tests/test-qobject-input-visitor
LINK tests/test-qmp-commands
LINK tests/test-string-input-visitor
LINK tests/test-string-output-visitor
LINK tests/test-qmp-event
LINK tests/test-opts-visitor
GTESTER tests/test-coroutine
GTESTER tests/test-iov
LINK tests/test-visitor-serialization
GTESTER tests/test-aio
GTESTER tests/test-aio-multithread
GTESTER tests/test-throttle
GTESTER tests/test-thread-pool
GTESTER tests/test-hbitmap
GTESTER tests/test-blockjob
GTESTER tests/test-blockjob-txn
GTESTER tests/test-x86-cpuid
GTESTER tests/test-xbzrle
GTESTER tests/test-vmstate
Failed to load simple/primitive:b_1
Failed to load simple/primitive:i64_2
Failed to load simple/primitive:i32_1
Failed to load simple/primitive:i32_1
Failed to load test/with_tmp:a
Failed to load test/tmp_child_parent:f
Failed to load test/tmp_child:parent
Failed to load test/with_tmp:tmp
Failed to load test/tmp_child:diff
Failed to load test/with_tmp:tmp
Failed to load test/tmp_child:diff
Failed to load test/with_tmp:tmp
GTESTER tests/test-cutils
GTESTER tests/test-shift128
GTESTER tests/test-mul64
GTESTER tests/test-int128
GTESTER tests/rcutorture
GTESTER tests/test-rcu-list
GTESTER tests/test-qdist
GTESTER tests/test-qht
LINK tests/test-qht-par
GTESTER tests/test-bitops
GTESTER tests/test-bitcnt
GTESTER tests/check-qom-interface
GTESTER tests/check-qom-proplist
GTESTER tests/test-qemu-opts
GTESTER tests/test-keyval
GTESTER tests/test-write-threshold
GTESTER tests/test-crypto-hash
GTESTER tests/test-crypto-hmac
GTESTER tests/test-crypto-cipher
GTESTER tests/test-crypto-secret
GTESTER tests/test-qga
GTESTER tests/test-timed-average
GTESTER tests/test-io-task
GTESTER tests/test-io-channel-socket
GTESTER tests/test-io-channel-file
GTESTER tests/test-io-channel-command
GTESTER tests/test-io-channel-buffer
GTESTER tests/test-base64
GTESTER tests/test-crypto-ivgen
GTESTER tests/test-crypto-afsplit
GTESTER tests/test-crypto-xts
GTESTER tests/test-crypto-block
GTESTER tests/test-logging
GTESTER tests/test-replication
GTESTER tests/test-bufferiszero
GTESTER tests/test-uuid
GTESTER tests/ptimer-test
GTESTER tests/test-qapi-util
GTESTER check-qtest-x86_64
GTESTER check-qtest-aarch64
GTESTER tests/test-qobject-output-visitor
GTESTER tests/test-clone-visitor
GTESTER tests/test-qobject-input-visitor
GTESTER tests/test-qmp-commands
GTESTER tests/test-string-input-visitor
GTESTER tests/test-string-output-visitor
GTESTER tests/test-qmp-event
GTESTER tests/test-opts-visitor
GTESTER tests/test-visitor-serialization
GTESTER tests/test-qht-par
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-gg351w48/src'
real 15m5.488s
user 0m4.821s
sys 0m1.444s
BUILD fedora
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-gg351w48/src'
ARCHIVE qemu.tgz
ARCHIVE dtc.tgz
COPY RUNNER
RUN test-mingw in qemu:fedora
Packages installed:
PyYAML-3.11-13.fc25.x86_64
SDL-devel-1.2.15-21.fc24.x86_64
bc-1.06.95-16.fc24.x86_64
bison-3.0.4-4.fc24.x86_64
ccache-3.3.4-1.fc25.x86_64
clang-3.9.1-2.fc25.x86_64
findutils-4.6.0-8.fc25.x86_64
flex-2.6.0-3.fc25.x86_64
gcc-6.3.1-1.fc25.x86_64
gcc-c++-6.3.1-1.fc25.x86_64
git-2.9.3-2.fc25.x86_64
glib2-devel-2.50.3-1.fc25.x86_64
libfdt-devel-1.4.2-1.fc25.x86_64
make-4.1-5.fc24.x86_64
mingw32-SDL-1.2.15-7.fc24.noarch
mingw32-bzip2-1.0.6-7.fc24.noarch
mingw32-curl-7.47.0-1.fc24.noarch
mingw32-glib2-2.50.1-1.fc25.noarch
mingw32-gmp-6.1.1-1.fc25.noarch
mingw32-gnutls-3.5.5-2.fc25.noarch
mingw32-gtk2-2.24.31-2.fc25.noarch
mingw32-gtk3-3.22.2-1.fc25.noarch
mingw32-libjpeg-turbo-1.5.1-1.fc25.noarch
mingw32-libpng-1.6.27-1.fc25.noarch
mingw32-libssh2-1.4.3-5.fc24.noarch
mingw32-libtasn1-4.9-1.fc25.noarch
mingw32-nettle-3.3-1.fc25.noarch
mingw32-pixman-0.34.0-1.fc25.noarch
mingw32-pkg-config-0.28-6.fc24.x86_64
mingw64-SDL-1.2.15-7.fc24.noarch
mingw64-bzip2-1.0.6-7.fc24.noarch
mingw64-curl-7.47.0-1.fc24.noarch
mingw64-glib2-2.50.1-1.fc25.noarch
mingw64-gmp-6.1.1-1.fc25.noarch
mingw64-gnutls-3.5.5-2.fc25.noarch
mingw64-gtk2-2.24.31-2.fc25.noarch
mingw64-gtk3-3.22.2-1.fc25.noarch
mingw64-libjpeg-turbo-1.5.1-1.fc25.noarch
mingw64-libpng-1.6.27-1.fc25.noarch
mingw64-libssh2-1.4.3-5.fc24.noarch
mingw64-libtasn1-4.9-1.fc25.noarch
mingw64-nettle-3.3-1.fc25.noarch
mingw64-pixman-0.34.0-1.fc25.noarch
mingw64-pkg-config-0.28-6.fc24.x86_64
package python2 is not installed
perl-5.24.1-385.fc25.x86_64
pixman-devel-0.34.0-2.fc24.x86_64
sparse-0.5.0-10.fc25.x86_64
tar-1.29-3.fc25.x86_64
which-2.21-1.fc25.x86_64
zlib-devel-1.2.8-10.fc24.x86_64
Environment variables:
FBR=f25
PACKAGES=ccache git tar PyYAML sparse flex bison python2 glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel gcc gcc-c++ clang make perl which bc findutils mingw32-pixman mingw32-glib2 mingw32-gmp mingw32-SDL mingw32-pkg-config mingw32-gtk2 mingw32-gtk3 mingw32-gnutls mingw32-nettle mingw32-libtasn1 mingw32-libjpeg-turbo mingw32-libpng mingw32-curl mingw32-libssh2 mingw32-bzip2 mingw64-pixman mingw64-glib2 mingw64-gmp mingw64-SDL mingw64-pkg-config mingw64-gtk2 mingw64-gtk3 mingw64-gnutls mingw64-nettle mingw64-libtasn1 mingw64-libjpeg-turbo mingw64-libpng mingw64-curl mingw64-libssh2 mingw64-bzip2
HOSTNAME=
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.m4a=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.oga=01;36:*.opus=01;36:*.spx=01;36:*.xspf=01;36:
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
TARGET_LIST=
HISTCONTROL=ignoredups
FGC=f25
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
DISTTAG=f25docker
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES=mingw clang pyyaml dtc
DEBUG=
_=/usr/bin/env
Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install --cross-prefix=x86_64-w64-mingw32- --enable-trace-backends=simple --enable-debug --enable-gnutls --enable-nettle --enable-curl --enable-vnc --enable-bzip2 --enable-guest-agent --with-sdlabi=1.2 --with-gtkabi=2.0
Install prefix /var/tmp/qemu-build/install
BIOS directory /var/tmp/qemu-build/install
binary directory /var/tmp/qemu-build/install
library directory /var/tmp/qemu-build/install/lib
module directory /var/tmp/qemu-build/install/lib
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory /var/tmp/qemu-build/install
local state directory queried at runtime
Windows SDK no
Source path /tmp/qemu-test/src
C compiler x86_64-w64-mingw32-gcc
Host C compiler cc
C++ compiler x86_64-w64-mingw32-g++
Objective-C compiler clang
ARFLAGS rv
CFLAGS -g
QEMU_CFLAGS -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/pixman-1 -I$(SRC_PATH)/dtc/libfdt -Werror -mms-bitfields -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/glib-2.0 -I/usr/x86_64-w64-mingw32/sys-root/mingw/lib/glib-2.0/include -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -m64 -mcx16 -mthreads -D__USE_MINGW_ANSI_STDIO=1 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/p11-kit-1 -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/libpng16
LDFLAGS -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -Wl,--warn-common -m64 -g
make make
install install
python python -B
smbd /usr/sbin/smbd
module support no
host CPU x86_64
host big endian no
target list x86_64-softmmu aarch64-softmmu
tcg debug enabled yes
gprof enabled no
sparse enabled no
strip binaries no
profiler no
static build no
pixman system
SDL support yes (1.2.15)
GTK support yes (2.24.31)
GTK GL support no
VTE support no
TLS priority NORMAL
GNUTLS support yes
GNUTLS rnd yes
libgcrypt no
libgcrypt kdf no
nettle yes (3.3)
nettle kdf yes
libtasn1 yes
curses support no
virgl support no
curl support yes
mingw32 support yes
Audio drivers dsound
Block whitelist (rw)
Block whitelist (ro)
VirtFS support no
VNC support yes
VNC SASL support no
VNC JPEG support yes
VNC PNG support yes
xen support no
brlapi support no
bluez support no
Documentation no
PIE no
vde support no
netmap support no
Linux AIO support no
ATTR/XATTR support no
Install blobs yes
KVM support no
HAX support yes
RDMA support no
TCG interpreter no
fdt support yes
preadv support no
fdatasync no
madvise no
posix_madvise no
libcap-ng support no
vhost-net support no
vhost-scsi support no
vhost-vsock support no
Trace backends simple
Trace output file trace-<pid>
spice support no
rbd support no
xfsctl support no
smartcard support no
libusb no
usb net redir no
OpenGL support no
OpenGL dmabufs no
libiscsi support no
libnfs support no
build guest agent yes
QGA VSS support no
QGA w32 disk info yes
QGA MSI support no
seccomp support no
coroutine backend win32
coroutine pool yes
debug stack usage no
GlusterFS support no
gcov gcov
gcov enabled no
TPM support yes
libssh2 support yes
TPM passthrough no
QOM debugging yes
Live block migration yes
lzo support no
snappy support no
bzip2 support yes
NUMA host support no
tcmalloc support no
jemalloc support no
avx2 optimization yes
replication support yes
VxHS block device no
mkdir -p dtc/libfdt
mkdir -p dtc/tests
GEN aarch64-softmmu/config-devices.mak.tmp
GEN x86_64-softmmu/config-devices.mak.tmp
GEN config-host.h
GEN qemu-options.def
GEN qmp-commands.h
GEN qapi-types.h
GEN qapi-visit.h
GEN qapi-event.h
GEN x86_64-softmmu/config-devices.mak
GEN qmp-marshal.c
GEN qapi-types.c
GEN aarch64-softmmu/config-devices.mak
GEN qapi-visit.c
GEN qapi-event.c
GEN qmp-introspect.h
GEN qmp-introspect.c
GEN trace/generated-tcg-tracers.h
GEN trace/generated-helpers-wrappers.h
GEN trace/generated-helpers.c
GEN trace/generated-helpers.h
GEN module_block.h
GEN tests/test-qapi-types.h
GEN tests/test-qapi-visit.h
GEN tests/test-qmp-commands.h
GEN tests/test-qapi-event.h
GEN tests/test-qmp-introspect.h
GEN trace-root.h
GEN util/trace.h
GEN crypto/trace.h
GEN io/trace.h
GEN migration/trace.h
GEN block/trace.h
GEN backends/trace.h
GEN chardev/trace.h
GEN hw/block/trace.h
GEN hw/block/dataplane/trace.h
GEN hw/char/trace.h
GEN hw/intc/trace.h
GEN hw/net/trace.h
GEN hw/virtio/trace.h
GEN hw/audio/trace.h
GEN hw/misc/trace.h
GEN hw/usb/trace.h
GEN hw/scsi/trace.h
GEN hw/nvram/trace.h
GEN hw/display/trace.h
GEN hw/input/trace.h
GEN hw/timer/trace.h
GEN hw/dma/trace.h
GEN hw/sparc/trace.h
GEN hw/sd/trace.h
GEN hw/isa/trace.h
GEN hw/mem/trace.h
GEN hw/i386/trace.h
GEN hw/i386/xen/trace.h
GEN hw/9pfs/trace.h
GEN hw/ppc/trace.h
GEN hw/pci/trace.h
GEN hw/s390x/trace.h
GEN hw/vfio/trace.h
GEN hw/acpi/trace.h
GEN hw/arm/trace.h
GEN hw/alpha/trace.h
GEN hw/xen/trace.h
GEN audio/trace.h
GEN ui/trace.h
GEN net/trace.h
GEN target/arm/trace.h
GEN target/i386/trace.h
GEN target/mips/trace.h
GEN target/sparc/trace.h
GEN target/s390x/trace.h
GEN target/ppc/trace.h
GEN qom/trace.h
GEN linux-user/trace.h
GEN trace-root.c
GEN qapi/trace.h
GEN util/trace.c
GEN crypto/trace.c
GEN io/trace.c
GEN migration/trace.c
GEN block/trace.c
GEN backends/trace.c
GEN chardev/trace.c
GEN hw/block/trace.c
GEN hw/block/dataplane/trace.c
GEN hw/char/trace.c
GEN hw/intc/trace.c
GEN hw/net/trace.c
GEN hw/virtio/trace.c
GEN hw/audio/trace.c
GEN hw/misc/trace.c
GEN hw/usb/trace.c
GEN hw/scsi/trace.c
GEN hw/nvram/trace.c
GEN hw/display/trace.c
GEN hw/input/trace.c
GEN hw/timer/trace.c
GEN hw/dma/trace.c
GEN hw/sparc/trace.c
GEN hw/sd/trace.c
GEN hw/isa/trace.c
GEN hw/mem/trace.c
GEN hw/i386/trace.c
GEN hw/i386/xen/trace.c
GEN hw/9pfs/trace.c
GEN hw/ppc/trace.c
GEN hw/pci/trace.c
GEN hw/s390x/trace.c
GEN hw/vfio/trace.c
GEN hw/acpi/trace.c
GEN hw/arm/trace.c
GEN hw/alpha/trace.c
GEN hw/xen/trace.c
GEN ui/trace.c
GEN audio/trace.c
GEN net/trace.c
GEN target/arm/trace.c
GEN target/i386/trace.c
GEN target/mips/trace.c
GEN target/sparc/trace.c
GEN target/s390x/trace.c
GEN target/ppc/trace.c
GEN qom/trace.c
GEN linux-user/trace.c
GEN qapi/trace.c
GEN config-all-devices.mak
DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
DEP /tmp/qemu-test/src/dtc/tests/trees.S
DEP /tmp/qemu-test/src/dtc/tests/testutils.c
DEP /tmp/qemu-test/src/dtc/tests/value-labels.c
DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.c
DEP /tmp/qemu-test/src/dtc/tests/truncated_property.c
DEP /tmp/qemu-test/src/dtc/tests/check_path.c
DEP /tmp/qemu-test/src/dtc/tests/overlay_bad_fixup.c
DEP /tmp/qemu-test/src/dtc/tests/overlay.c
DEP /tmp/qemu-test/src/dtc/tests/subnode_iterate.c
DEP /tmp/qemu-test/src/dtc/tests/property_iterate.c
DEP /tmp/qemu-test/src/dtc/tests/integer-expressions.c
DEP /tmp/qemu-test/src/dtc/tests/utilfdt_test.c
DEP /tmp/qemu-test/src/dtc/tests/path_offset_aliases.c
DEP /tmp/qemu-test/src/dtc/tests/add_subnode_with_nops.c
DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_unordered.c
DEP /tmp/qemu-test/src/dtc/tests/dtb_reverse.c
DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_ordered.c
DEP /tmp/qemu-test/src/dtc/tests/extra-terminating-null.c
DEP /tmp/qemu-test/src/dtc/tests/incbin.c
DEP /tmp/qemu-test/src/dtc/tests/boot-cpuid.c
DEP /tmp/qemu-test/src/dtc/tests/phandle_format.c
DEP /tmp/qemu-test/src/dtc/tests/path-references.c
DEP /tmp/qemu-test/src/dtc/tests/references.c
DEP /tmp/qemu-test/src/dtc/tests/propname_escapes.c
DEP /tmp/qemu-test/src/dtc/tests/string_escapes.c
DEP /tmp/qemu-test/src/dtc/tests/appendprop2.c
DEP /tmp/qemu-test/src/dtc/tests/appendprop1.c
DEP /tmp/qemu-test/src/dtc/tests/del_node.c
DEP /tmp/qemu-test/src/dtc/tests/del_property.c
DEP /tmp/qemu-test/src/dtc/tests/setprop.c
DEP /tmp/qemu-test/src/dtc/tests/set_name.c
DEP /tmp/qemu-test/src/dtc/tests/rw_tree1.c
DEP /tmp/qemu-test/src/dtc/tests/nopulate.c
DEP /tmp/qemu-test/src/dtc/tests/open_pack.c
DEP /tmp/qemu-test/src/dtc/tests/mangle-layout.c
DEP /tmp/qemu-test/src/dtc/tests/move_and_save.c
DEP /tmp/qemu-test/src/dtc/tests/sw_tree1.c
DEP /tmp/qemu-test/src/dtc/tests/nop_property.c
DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.c
DEP /tmp/qemu-test/src/dtc/tests/nop_node.c
DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
DEP /tmp/qemu-test/src/dtc/tests/addr_size_cells.c
DEP /tmp/qemu-test/src/dtc/tests/notfound.c
DEP /tmp/qemu-test/src/dtc/tests/sized_cells.c
DEP /tmp/qemu-test/src/dtc/tests/char_literal.c
DEP /tmp/qemu-test/src/dtc/tests/get_alias.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_compatible.c
DEP /tmp/qemu-test/src/dtc/tests/node_check_compatible.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_phandle.c
DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_prop_value.c
DEP /tmp/qemu-test/src/dtc/tests/parent_offset.c
DEP /tmp/qemu-test/src/dtc/tests/supernode_atdepth_offset.c
DEP /tmp/qemu-test/src/dtc/tests/get_phandle.c
DEP /tmp/qemu-test/src/dtc/tests/get_path.c
DEP /tmp/qemu-test/src/dtc/tests/getprop.c
DEP /tmp/qemu-test/src/dtc/tests/get_name.c
DEP /tmp/qemu-test/src/dtc/tests/path_offset.c
DEP /tmp/qemu-test/src/dtc/tests/subnode_offset.c
DEP /tmp/qemu-test/src/dtc/tests/find_property.c
DEP /tmp/qemu-test/src/dtc/tests/root_node.c
DEP /tmp/qemu-test/src/dtc/tests/get_mem_rsv.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_empty_tree.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_addresses.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_strerror.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_rw.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_sw.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_wip.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt_ro.c
DEP /tmp/qemu-test/src/dtc/libfdt/fdt.c
DEP /tmp/qemu-test/src/dtc/util.c
DEP /tmp/qemu-test/src/dtc/fdtput.c
DEP /tmp/qemu-test/src/dtc/fdtget.c
DEP /tmp/qemu-test/src/dtc/fdtdump.c
DEP /tmp/qemu-test/src/dtc/srcpos.c
LEX convert-dtsv0-lexer.lex.c
BISON dtc-parser.tab.c
LEX dtc-lexer.lex.c
DEP /tmp/qemu-test/src/dtc/treesource.c
DEP /tmp/qemu-test/src/dtc/livetree.c
DEP /tmp/qemu-test/src/dtc/fstree.c
DEP /tmp/qemu-test/src/dtc/flattree.c
DEP /tmp/qemu-test/src/dtc/dtc.c
DEP /tmp/qemu-test/src/dtc/checks.c
DEP /tmp/qemu-test/src/dtc/data.c
DEP convert-dtsv0-lexer.lex.c
DEP dtc-parser.tab.c
DEP dtc-lexer.lex.c
CHK version_gen.h
UPD version_gen.h
DEP /tmp/qemu-test/src/dtc/util.c
CC libfdt/fdt.o
CC libfdt/fdt_sw.o
CC libfdt/fdt_wip.o
CC libfdt/fdt_ro.o
CC libfdt/fdt_strerror.o
CC libfdt/fdt_rw.o
CC libfdt/fdt_addresses.o
CC libfdt/fdt_empty_tree.o
CC libfdt/fdt_overlay.o
AR libfdt/libfdt.a
x86_64-w64-mingw32-ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
RC version.o
GEN qga/qapi-generated/qga-qapi-types.h
GEN qga/qapi-generated/qga-qmp-commands.h
GEN qga/qapi-generated/qga-qapi-visit.c
GEN qga/qapi-generated/qga-qapi-visit.h
GEN qga/qapi-generated/qga-qmp-marshal.c
GEN qga/qapi-generated/qga-qapi-types.c
CC qmp-introspect.o
CC qapi-types.o
CC qapi-visit.o
CC qapi-event.o
CC qapi/qapi-visit-core.o
CC qapi/qobject-input-visitor.o
CC qapi/qobject-output-visitor.o
CC qapi/qapi-dealloc-visitor.o
CC qapi/qmp-registry.o
CC qapi/qmp-dispatch.o
CC qapi/string-input-visitor.o
CC qapi/string-output-visitor.o
CC qapi/opts-visitor.o
CC qapi/qapi-clone-visitor.o
CC qapi/qmp-event.o
CC qapi/qapi-util.o
CC qobject/qnull.o
CC qobject/qnum.o
CC qobject/qstring.o
CC qobject/qdict.o
CC qobject/qlist.o
CC qobject/qbool.o
CC qobject/qjson.o
/tmp/qemu-test/src/qobject/qnum.c: In function 'qnum_get_double':
/tmp/qemu-test/src/qobject/qnum.c:162:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
/tmp/qemu-test/src/qobject/qnum.c: In function 'qnum_to_string':
/tmp/qemu-test/src/qobject/qnum.c:200:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
cc1: all warnings being treated as errors
/tmp/qemu-test/src/rules.mak:69: recipe for target 'qobject/qnum.o' failed
make: *** [qobject/qnum.o] Error 1
make: *** Waiting for unfinished jobs....
tests/docker/Makefile.include:118: recipe for target 'docker-run' failed
make[1]: *** [docker-run] Error 2
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-gg351w48/src'
tests/docker/Makefile.include:149: recipe for target 'docker-run-test-mingw@fedora' failed
make: *** [docker-run-test-mingw@fedora] Error 2
=== OUTPUT END ===
Test command exited with code: 2
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (43 preceding siblings ...)
2017-06-07 20:41 ` [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type no-reply
@ 2017-06-08 1:47 ` no-reply
2017-06-09 12:32 ` Markus Armbruster
45 siblings, 0 replies; 70+ messages in thread
From: no-reply @ 2017-06-08 1:47 UTC (permalink / raw)
To: marcandre.lureau; +Cc: famz, qemu-devel, armbru
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20170607163635.17635-1-marcandre.lureau@redhat.com
Subject: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
5304b17 qobject: move dump_qobject() from block/ to qobject/
04e93f9 RFC: qdict: add uint
b1f8183 tests/qdict: check more get_try_int() cases
32dc113 console: use get_uint() for "head" property
ccdbdd6 i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
eabad51 numa: use get_uint() for "size" property
23ad49e pnv-core: use get_uint() for "core-pir" property
c327b58 pvpanic: use get_uint() for "ioport" property
2af440d auxbus: use get_uint() for "addr" property
63db11b arm: use get_uint() for "mp-affinity" property
ede6718 xen: use get_uint() for "max-ram-below-4g" property
d00a748 pc: use get_uint() for "hpet-intcap" property
2be46be pc: use get_uint() for "apic-id" property
0bbec76 pc: use get_uint() for "iobase" property
54613bf acpi: use get_uint() for "pci-hole*" properties
a9029ef acpi: use get_uint() for various acpi properties
4c2ac9c acpi: use get_uint() for "acpi-pcihp-io*" properties
5890942 platform-bus: use get_uint() for "addr" property
16b2431 bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base"
52a5c50 aspeed: use {set, get}_uint() for "ram-size" property
8ee5ed0 pcihp: use get_uint() for "bsel" property
ec9a2db pc-dimm: make "size" property uint64
5b65717 pc-dimm: use get_uint() for dimm properties
e05a02f isa: use get_uint() for "io-base"
74e0f4b qdev: use appropriate getter/setters type
ea4b431 apic-common: make "id" property a uint32
917ff10 qdev: avoid type casts between signed and unsigned
c803fcd qdev: wrap default property value in an union
0153836 qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
00b6346 object: use more specific property type names
6ebdb40 q35: fix get_mmcfg_size to use uint64 visitor
b66da0f object: add uint property setter/getter
3123cbf qapi: update the qobject visitor to use QNUM_U64
f65fbd4 json: learn to parse uint64 numbers
cbe9a26 qnum: add uint type
47d9e93 tests: remove /{qnum, qlist, dict}/destroy test
19e22e7 qapi: Remove visit_start_alternate() parameter promote_int
8564a30 qapi: merge QInt and QFloat in QNum
3a28906 qapi: minor refactoring
5c73880 tests: add more int/number ranges checks
98c8358 tests: Remove test cases for alternates of 'number' and 'int'
d2fce78 object: fix potential leak in getters
0c9c6c3 qdev: remove PropertyInfo.qtype field
=== OUTPUT BEGIN ===
Checking PATCH 1/43: qdev: remove PropertyInfo.qtype field...
Checking PATCH 2/43: object: fix potential leak in getters...
Checking PATCH 3/43: tests: Remove test cases for alternates of 'number' and 'int'...
Checking PATCH 4/43: tests: add more int/number ranges checks...
Checking PATCH 5/43: qapi: minor refactoring...
Checking PATCH 6/43: qapi: merge QInt and QFloat in QNum...
ERROR: do not use C99 // comments
#1971: FILE: tests/check-qnum.c:39:
+ // destroy doesn't exit yet
ERROR: do not use C99 // comments
#1987: FILE: tests/check-qnum.c:55:
+ // destroy doesn't exit yet
total: 2 errors, 0 warnings, 1894 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 7/43: qapi: Remove visit_start_alternate() parameter promote_int...
Checking PATCH 8/43: tests: remove /{qnum, qlist, dict}/destroy test...
Checking PATCH 9/43: qnum: add uint type...
Checking PATCH 10/43: json: learn to parse uint64 numbers...
Checking PATCH 11/43: qapi: update the qobject visitor to use QNUM_U64...
Checking PATCH 12/43: object: add uint property setter/getter...
Checking PATCH 13/43: q35: fix get_mmcfg_size to use uint64 visitor...
Checking PATCH 14/43: object: use more specific property type names...
Checking PATCH 15/43: qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()...
Checking PATCH 16/43: qdev: wrap default property value in an union...
Checking PATCH 17/43: qdev: avoid type casts between signed and unsigned...
Checking PATCH 18/43: apic-common: make "id" property a uint32...
Checking PATCH 19/43: qdev: use appropriate getter/setters type...
Checking PATCH 20/43: isa: use get_uint() for "io-base"...
Checking PATCH 21/43: pc-dimm: use get_uint() for dimm properties...
Checking PATCH 22/43: pc-dimm: make "size" property uint64...
Checking PATCH 23/43: pcihp: use get_uint() for "bsel" property...
Checking PATCH 24/43: aspeed: use {set, get}_uint() for "ram-size" property...
Checking PATCH 25/43: bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base"...
Checking PATCH 26/43: platform-bus: use get_uint() for "addr" property...
Checking PATCH 27/43: acpi: use get_uint() for "acpi-pcihp-io*" properties...
Checking PATCH 28/43: acpi: use get_uint() for various acpi properties...
Checking PATCH 29/43: acpi: use get_uint() for "pci-hole*" properties...
Checking PATCH 30/43: pc: use get_uint() for "iobase" property...
Checking PATCH 31/43: pc: use get_uint() for "apic-id" property...
Checking PATCH 32/43: pc: use get_uint() for "hpet-intcap" property...
Checking PATCH 33/43: xen: use get_uint() for "max-ram-below-4g" property...
Checking PATCH 34/43: arm: use get_uint() for "mp-affinity" property...
Checking PATCH 35/43: auxbus: use get_uint() for "addr" property...
Checking PATCH 36/43: pvpanic: use get_uint() for "ioport" property...
Checking PATCH 37/43: pnv-core: use get_uint() for "core-pir" property...
Checking PATCH 38/43: numa: use get_uint() for "size" property...
Checking PATCH 39/43: i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties...
Checking PATCH 40/43: console: use get_uint() for "head" property...
Checking PATCH 41/43: tests/qdict: check more get_try_int() cases...
Checking PATCH 42/43: RFC: qdict: add uint...
Checking PATCH 43/43: qobject: move dump_qobject() from block/ to qobject/...
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks Marc-André Lureau
@ 2017-06-08 14:55 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 14:55 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/test-qobject-input-visitor.c | 38 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
> index 83d663d11d..3a6ce2226c 100644
> --- a/tests/test-qobject-input-visitor.c
> +++ b/tests/test-qobject-input-visitor.c
> @@ -107,6 +107,7 @@ static void test_visitor_in_int(TestInputVisitorData *data,
> const void *unused)
> {
> int64_t res = 0;
> + double dbl;
> int value = -42;
> Visitor *v;
>
> @@ -114,6 +115,9 @@ static void test_visitor_in_int(TestInputVisitorData *data,
>
> visit_type_int(v, NULL, &res, &error_abort);
> g_assert_cmpint(res, ==, value);
> +
> + visit_type_number(v, NULL, &dbl, &error_abort);
> + g_assert_cmpfloat(dbl, ==, -42.0);
> }
>
> static void test_visitor_in_uint(TestInputVisitorData *data,
> @@ -121,6 +125,8 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
> {
> Error *err = NULL;
> uint64_t res = 0;
> + int64_t i64;
> + double dbl;
> int value = 42;
> Visitor *v;
>
> @@ -129,8 +135,13 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
> visit_type_uint64(v, NULL, &res, &error_abort);
> g_assert_cmpuint(res, ==, (uint64_t)value);
>
> - /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */
> + visit_type_int(v, NULL, &i64, &error_abort);
> + g_assert_cmpint(i64, ==, value);
> +
> + visit_type_number(v, NULL, &dbl, &error_abort);
> + g_assert_cmpfloat(dbl, ==, value);
>
> + /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */
> v = visitor_input_test_init(data, "%d", -value);
>
> visit_type_uint64(v, NULL, &res, &error_abort);
> @@ -142,6 +153,8 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
>
> visit_type_uint64(v, NULL, &res, &err);
> error_free_or_abort(&err);
> +
> + visit_type_number(v, NULL, &dbl, &error_abort);
Please test the expected value, like you do for the other
visit_type_number() you add.
> }
>
> static void test_visitor_in_int_overflow(TestInputVisitorData *data,
> @@ -260,6 +273,27 @@ static void test_visitor_in_number(TestInputVisitorData *data,
> g_assert_cmpfloat(res, ==, value);
> }
>
> +static void test_visitor_in_large_number(TestInputVisitorData *data,
> + const void *unused)
> +{
> + Error *err = NULL;
> + double res = 0;
> + int64_t i64;
> + uint64_t u64;
> + Visitor *v;
> +
> + v = visitor_input_test_init(data, "-18446744073709551616"); /* -2^64 */
> +
> + visit_type_number(v, NULL, &res, &error_abort);
> + g_assert_cmpfloat(res, ==, -18446744073709552e3);
> +
> + visit_type_int(v, NULL, &i64, &err);
> + error_free_or_abort(&err);
> +
> + visit_type_uint64(v, NULL, &u64, &err);
> + error_free_or_abort(&err);
> +}
> +
> static void test_visitor_in_number_keyval(TestInputVisitorData *data,
> const void *unused)
> {
> @@ -1253,6 +1287,8 @@ int main(int argc, char **argv)
> NULL, test_visitor_in_bool_str_fail);
> input_visitor_test_add("/visitor/input/number",
> NULL, test_visitor_in_number);
> + input_visitor_test_add("/visitor/input/large_number",
> + NULL, test_visitor_in_large_number);
> input_visitor_test_add("/visitor/input/number_keyval",
> NULL, test_visitor_in_number_keyval);
> input_visitor_test_add("/visitor/input/number_str_keyval",
With test_visitor_in_uint() tightened:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring Marc-André Lureau
@ 2017-06-08 14:57 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 14:57 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Lets title this
qapi: Clean up qobject_input_type_number() control flow
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Use the more common pattern to error out.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> qapi/qobject-input-visitor.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
> index eac40f618a..26ef49a60b 100644
> --- a/qapi/qobject-input-visitor.c
> +++ b/qapi/qobject-input-visitor.c
> @@ -547,13 +547,13 @@ static void qobject_input_type_number(Visitor *v, const char *name, double *obj,
> }
>
> qfloat = qobject_to_qfloat(qobj);
> - if (qfloat) {
> - *obj = qfloat_get_double(qobject_to_qfloat(qobj));
> + if (!qfloat) {
> + error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
> + full_name(qiv, name), "number");
> return;
> }
>
> - error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
> - full_name(qiv, name), "number");
> + *obj = qfloat_get_double(qobject_to_qfloat(qobj));
> }
>
> static void qobject_input_type_number_keyval(Visitor *v, const char *name,
Preferably with the more descriptive commit message
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test Marc-André Lureau
@ 2017-06-08 15:00 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 15:00 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> The tests aren't really useful, or already covered by other simple tests.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum Marc-André Lureau
@ 2017-06-08 15:54 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 15:54 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> We would like to use a same QObject type to represent numbers, whether
> they are int, uint, or floats. Getters will allow some compatibility
> between the various types if the number fits other representations.
>
> Add a few more tests while at it.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[...]
> diff --git a/blockdev.c b/blockdev.c
> index 892d768574..154c95d402 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -334,9 +334,11 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,
> break;
> }
>
> - case QTYPE_QINT: {
> - int64_t length = qint_get_int(qobject_to_qint(entry->value));
> - if (length > 0 && length <= UINT_MAX) {
> + case QTYPE_QNUM: {
> + int64_t length;
> +
> + if (qnum_get_try_int(qobject_to_qnum(entry->value), &length) &&
> + length > 0 && length <= UINT_MAX) {
> block_acct_add_interval(stats, (unsigned) length);
> } else {
> error_setg(errp, "Invalid interval length: %" PRId64, length);
Less churn and a bit more legible:
+ case QTYPE_QNUM: {
+ int64_t length = qnum_get_int(qobject_to_qint(entry->value));
+
+ if (length > 0 && length <= UINT_MAX) {
Aborts when entry->value doesn't fit into int64_t, but that's no worse
than before.
[...]
> diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
> index 3a6ce2226c..9e3d4aa7e5 100644
> --- a/tests/test-qobject-input-visitor.c
> +++ b/tests/test-qobject-input-visitor.c
> @@ -164,9 +164,9 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data,
> Error *err = NULL;
> Visitor *v;
>
> - /* this will overflow a Qint/int64, so should be deserialized into
> - * a QFloat/double field instead, leading to an error if we pass it
> - * to visit_type_int. confirm this.
> + /* this will overflow a QNUM_I64, so should be deserialized into a
Wing both ends and start with a capital letter, please:
+ /*
+ * This will overflow a QNUM_I64, so should be deserialized into a
> + * QNUM_DOUBLE field instead, leading to an error if we pass it to
> + * visit_type_int. confirm this.
Humor me:
* visit_type_int(). Confirm this.
> */
> v = visitor_input_test_init(data, "%f", DBL_MAX);
>
[...]
With these minor touch-ups:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers Marc-André Lureau
@ 2017-06-08 16:27 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 16:27 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Switch strtoll() usage to qemu_strtoi64() helper while at it.
>
> Add a few tests for large numbers.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64 Marc-André Lureau
@ 2017-06-08 16:36 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 16:36 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Switch to use QNum/uint where appropriate to remove i64 limitation.
>
> The input visitor will cast i64 input to u64 for compatibility
> reasons (existing json QMP client already use negative i64 for large
> u64, and expect an implicit cast in qemu).
>
> Note: before the patch, uint64_t values above INT64_MAX are sent over
> json QMP as negative values, e.g. UINT64_MAX is sent as -1. After the
> patch, they are sent unmodified. Clearly a bug fix, but we have to
> consider compatibility issues anyway. libvirt should cope fine,
> because its parsing of unsigned integers accepts negative values
> modulo 2^64. There's hope that other clients will, too.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
> hw/i386/acpi-build.c | 2 +-
> qapi/qobject-input-visitor.c | 21 ++++++++++++++++-----
> qapi/qobject-output-visitor.c | 3 +--
> tests/test-qobject-input-visitor.c | 7 ++-----
> tests/test-qobject-output-visitor.c | 20 ++++++++++++++++----
> 5 files changed, 36 insertions(+), 17 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index d7d2b65fe4..3eb43677f0 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -2614,7 +2614,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> if (!o) {
> return false;
> }
> - mcfg->mcfg_base = qnum_get_int(qobject_to_qnum(o));
> + mcfg->mcfg_base = qnum_get_uint(qobject_to_qnum(o));
> qobject_decref(o);
>
> o = object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL);
> diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
> index 539b3b825d..35aff78f2b 100644
> --- a/qapi/qobject-input-visitor.c
> +++ b/qapi/qobject-input-visitor.c
> @@ -417,7 +417,6 @@ static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
> static void qobject_input_type_uint64(Visitor *v, const char *name,
> uint64_t *obj, Error **errp)
> {
> - /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */
> QObjectInputVisitor *qiv = to_qiv(v);
> QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
> QNum *qnum;
> @@ -427,11 +426,23 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
> return;
> }
> qnum = qobject_to_qnum(qobj);
> - if (!qnum || !qnum_get_try_int(qnum, &val)) {
> - error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
> - full_name(qiv, name), "integer");
> + if (!qnum) {
> + goto err;
> + }
> +
> + if (qnum_get_try_uint(qnum, obj)) {
> + return;
> }
> - *obj = val;
> +
> + /* Need to accept negative values for backward compatibility */
> + if (qnum_get_try_int(qnum, &val)) {
> + *obj = val;
> + return;
> + }
> +
> +err:
> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> + full_name(qiv, name), "uint64");
> }
>
> static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,
> diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c
> index 2ca5093b22..70be84ccb5 100644
> --- a/qapi/qobject-output-visitor.c
> +++ b/qapi/qobject-output-visitor.c
> @@ -150,9 +150,8 @@ static void qobject_output_type_int64(Visitor *v, const char *name,
> static void qobject_output_type_uint64(Visitor *v, const char *name,
> uint64_t *obj, Error **errp)
> {
> - /* FIXME values larger than INT64_MAX become negative */
> QObjectOutputVisitor *qov = to_qov(v);
> - qobject_output_add(qov, name, qnum_from_int(*obj));
> + qobject_output_add(qov, name, qnum_from_uint(*obj));
> }
>
> static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
> diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
> index 40a135db89..3bcdb9a045 100644
> --- a/tests/test-qobject-input-visitor.c
> +++ b/tests/test-qobject-input-visitor.c
> @@ -123,7 +123,6 @@ static void test_visitor_in_int(TestInputVisitorData *data,
> static void test_visitor_in_uint(TestInputVisitorData *data,
> const void *unused)
> {
> - Error *err = NULL;
> uint64_t res = 0;
> int64_t i64;
> double dbl;
> @@ -147,12 +146,10 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
> visit_type_uint64(v, NULL, &res, &error_abort);
> g_assert_cmpuint(res, ==, (uint64_t)-value);
>
> - /* BUG: value between INT64_MAX+1 and UINT64_MAX rejected */
> -
> v = visitor_input_test_init(data, "18446744073709551574");
>
> - visit_type_uint64(v, NULL, &res, &err);
> - error_free_or_abort(&err);
> + visit_type_uint64(v, NULL, &res, &error_abort);
> + g_assert_cmpuint(res, ==, 18446744073709551574U);
>
> visit_type_number(v, NULL, &dbl, &error_abort);
> }
> diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
> index a16c8f663f..d23c8eb352 100644
> --- a/tests/test-qobject-output-visitor.c
> +++ b/tests/test-qobject-output-visitor.c
> @@ -602,14 +602,26 @@ static void check_native_list(QObject *qobj,
> qlist = qlist_copy(qobject_to_qlist(qdict_get(qdict, "data")));
>
> switch (kind) {
> - case USER_DEF_NATIVE_LIST_UNION_KIND_S8:
> - case USER_DEF_NATIVE_LIST_UNION_KIND_S16:
> - case USER_DEF_NATIVE_LIST_UNION_KIND_S32:
> - case USER_DEF_NATIVE_LIST_UNION_KIND_S64:
> case USER_DEF_NATIVE_LIST_UNION_KIND_U8:
> case USER_DEF_NATIVE_LIST_UNION_KIND_U16:
> case USER_DEF_NATIVE_LIST_UNION_KIND_U32:
> case USER_DEF_NATIVE_LIST_UNION_KIND_U64:
> + for (i = 0; i < 32; i++) {
> + QObject *tmp;
> + QNum *qvalue;
> +
> + tmp = qlist_peek(qlist);
> + g_assert(tmp);
> + qvalue = qobject_to_qnum(tmp);
> + g_assert_cmpuint(qnum_get_uint(qvalue), ==, i);
You use qnum_get_uint() here, but...
> + qobject_decref(qlist_pop(qlist));
> + }
> + break;
> +
> + case USER_DEF_NATIVE_LIST_UNION_KIND_S8:
> + case USER_DEF_NATIVE_LIST_UNION_KIND_S16:
> + case USER_DEF_NATIVE_LIST_UNION_KIND_S32:
> + case USER_DEF_NATIVE_LIST_UNION_KIND_S64:
> /*
> * All integer elements in JSON arrays get stored into QNums
> * when we convert to QObjects, so we can check them all in
* the same fashion, so simply fall through here.
*/
case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER:
for (i = 0; i < 32; i++) {
QObject *tmp;
QNum *qvalue;
int64_t val;
tmp = qlist_peek(qlist);
g_assert(tmp);
qvalue = qobject_to_qnum(tmp);
g_assert(qnum_get_try_int(qvalue, &val));
qnum_get_try_int() here. Either is fine with me, but let's to it the
same way.
You seem to prefer qnum_get_try_int() elsewhere in tests, probably
because it fails more nicely, at the cost of one extra line. I don't
mind.
g_assert_cmpint(val, ==, i);
qobject_decref(qlist_pop(qlist));
}
break;
With that tidied up, my R-by stands.
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32 Marc-André Lureau
@ 2017-06-08 16:39 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 16:39 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> The getter and setter of TYPE_APIC_COMMON property "id" are
> apic_common_get_id() and apic_common_set_id().
>
> apic_common_get_id() reads either APICCommonState member uint32_t
> initial_apic_id or uint8_t id into an int64_t local variable. It then
> passes this variable to visit_type_int().
>
> apic_common_set_id() uses visit_type_int() to read the value into a
> local variable, which it then assigns both to initial_apic_id and id.
>
> While the state backing the property is two unsigned members, 8 and 32
> bits wide, the actual visitor is 64 bits signed.
>
> Change getter and setter to use visit_type_uint32(). Then everything's
> uint32_t, except for @id.
>
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED() Marc-André Lureau
@ 2017-06-08 16:42 ` Markus Armbruster
2017-06-08 17:01 ` Markus Armbruster
0 siblings, 1 reply; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 16:42 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Prepare for the next patch's DEFINE_PROP_UNSIGNED().
Suggest "To prepare for the", or "In preparation of the", or "The rename
prepares for the".
While there, tidy up case in the title to "qdev: Rename ..."
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
2017-06-08 16:42 ` Markus Armbruster
@ 2017-06-08 17:01 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:01 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Markus Armbruster <armbru@redhat.com> writes:
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
>> Prepare for the next patch's DEFINE_PROP_UNSIGNED().
>
> Suggest "To prepare for the", or "In preparation of the", or "The rename
> prepares for the".
Also "the patch after next's".
> While there, tidy up case in the title to "qdev: Rename ..."
>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union Marc-André Lureau
@ 2017-06-08 17:01 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:01 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Wrap the Property default value (an int64_t) in a union, to prepare
> for the next patch adding a uint64_t.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Split like this, review is easy :)
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned Marc-André Lureau
@ 2017-06-08 17:08 ` Markus Armbruster
2017-06-09 10:04 ` Marc-André Lureau
0 siblings, 1 reply; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:08 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Modify the unsigned type for various properties to use QNUM_U64, to
> avoid type casts.
>
> There are a few empty lines added to improve code reading/style.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/hw/qdev-core.h | 1 +
> include/hw/qdev-properties.h | 29 ++++++++++++++++++++---------
> hw/core/qdev-properties.c | 23 ++++++++++++++---------
> 3 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 784971b8d8..9d7c1c0e9b 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -228,6 +228,7 @@ struct Property {
> uint8_t bitnr;
> union {
> int64_t i;
> + uint64_t u;
> } defval;
> int arrayoffset;
> PropertyInfo *arrayinfo;
> diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> index 34524d0bfe..1e5c928f32 100644
> --- a/include/hw/qdev-properties.h
> +++ b/include/hw/qdev-properties.h
> @@ -37,6 +37,7 @@ extern PropertyInfo qdev_prop_arraylen;
> .offset = offsetof(_state, _field) \
> + type_check(_type, typeof_field(_state, _field)), \
> }
> +
> #define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) { \
> .name = (_name), \
> .info = &(_prop), \
> @@ -44,21 +45,31 @@ extern PropertyInfo qdev_prop_arraylen;
> + type_check(_type,typeof_field(_state, _field)), \
> .defval.i = (_type)_defval, \
> }
> +
> #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
> .name = (_name), \
> .info = &(qdev_prop_bit), \
> .bitnr = (_bit), \
> .offset = offsetof(_state, _field) \
> + type_check(uint32_t,typeof_field(_state, _field)), \
> - .defval.i = (bool)_defval, \
> + .defval.u = (bool)_defval, \
> + }
> +
> +#define DEFINE_PROP_UNSIGNED(_name, _state, _field, _defval, _prop, _type) { \
> + .name = (_name), \
> + .info = &(_prop), \
> + .offset = offsetof(_state, _field) \
> + + type_check(_type, typeof_field(_state, _field)), \
> + .defval.u = (_type)_defval, \
> }
> +
> #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
> .name = (_name), \
> .info = &(qdev_prop_bit64), \
> .bitnr = (_bit), \
> .offset = offsetof(_state, _field) \
> + type_check(uint64_t, typeof_field(_state, _field)), \
> - .defval.i = (bool)_defval, \
> + .defval.u = (bool)_defval, \
> }
>
> #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \
> @@ -66,7 +77,7 @@ extern PropertyInfo qdev_prop_arraylen;
> .info = &(qdev_prop_bool), \
> .offset = offsetof(_state, _field) \
> + type_check(bool, typeof_field(_state, _field)), \
> - .defval.i = (bool)_defval, \
> + .defval.u = (bool)_defval, \
Whitespace is off.
> }
>
> #define PROP_ARRAY_LEN_PREFIX "len-"
> @@ -107,17 +118,17 @@ extern PropertyInfo qdev_prop_arraylen;
> }
>
> #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> #define DEFINE_PROP_INT32(_n, _s, _f, _d) \
> DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
> #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
> #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
> DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
>
> @@ -163,7 +174,7 @@ extern PropertyInfo qdev_prop_arraylen;
> #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
> DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
> #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \
> - DEFINE_PROP_SIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
> + DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
> #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
> DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index f3f682c611..a8f09c13e2 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque,
>
> static void set_default_value_enum(Object *obj, const Property *prop)
> {
> - object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
> + object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
> prop->name, &error_abort);
> }
You use DEFINE_PROP_SIGNED() for enums. Shouldn't we stick to defval.i?
>
> @@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const char *name,
>
> static void set_default_value_bool(Object *obj, const Property *prop)
> {
> - object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort);
> + object_property_set_bool(obj, prop->defval.u, prop->name, &error_abort);
> }
>
> PropertyInfo qdev_prop_bit = {
> @@ -264,11 +264,16 @@ 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_int,
> + .set_default_value = set_default_value_uint,
> };
>
> /* --- 16bit integer --- */
> @@ -302,7 +307,7 @@ PropertyInfo qdev_prop_uint16 = {
> .name = "uint16",
> .get = get_uint16,
> .set = set_uint16,
> - .set_default_value = set_default_value_int,
> + .set_default_value = set_default_value_uint,
> };
>
> /* --- 32bit integer --- */
> @@ -361,7 +366,7 @@ PropertyInfo qdev_prop_uint32 = {
> .name = "uint32",
> .get = get_uint32,
> .set = set_uint32,
> - .set_default_value = set_default_value_int,
> + .set_default_value = set_default_value_uint,
> };
>
> PropertyInfo qdev_prop_int32 = {
> @@ -402,7 +407,7 @@ PropertyInfo qdev_prop_uint64 = {
> .name = "uint64",
> .get = get_uint64,
> .set = set_uint64,
> - .set_default_value = set_default_value_int,
> + .set_default_value = set_default_value_uint,
> };
>
> /* --- string --- */
> @@ -725,7 +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_int,
> + .set_default_value = set_default_value_uint,
> };
>
> /* --- pci host address --- */
> @@ -948,7 +953,7 @@ PropertyInfo qdev_prop_arraylen = {
> .name = "uint32",
> .get = get_uint32,
> .set = set_prop_arraylen,
> - .set_default_value = set_default_value_int,
> + .set_default_value = set_default_value_uint,
> };
>
> /* --- public helpers --- */
> @@ -1185,5 +1190,5 @@ PropertyInfo qdev_prop_size = {
> .name = "size",
> .get = get_size,
> .set = set_size,
> - .set_default_value = set_default_value_int,
> + .set_default_value = set_default_value_uint,
> };
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type Marc-André Lureau
@ 2017-06-08 17:23 ` Markus Armbruster
0 siblings, 0 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:23 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Based on the underlying type of the data accessed, use the appropriate
> getters/setters.
Enumerating data here would be nice.
* AcpiPmInfo members s3_disabled, s4_disabled are bool, member s4_val is
an uint8_t.
* Property ACPI_PCIHP_IO_PROP is defined with
object_property_add_uint32_ptr().
* Property PCIE_HOST_MCFG_SIZE is implemented with visit_type_uint64()
* PCIDevice property "addr" is backed by PCIDevice member devfn, which
is an int32_t.
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Preferably with a more detailed commit message:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint Marc-André Lureau
@ 2017-06-08 17:25 ` Markus Armbruster
2017-06-09 10:05 ` Marc-André Lureau
0 siblings, 1 reply; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:25 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Similar to int support, add uint support.
>
> Note this is RFC because this is currently unused in qemu, I haven't
> found a good user for it yet (kaslr qemu-ga code did use it though).
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
We need to make up our mind whether to store this in the tree or on the
mailing list.
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/ Marc-André Lureau
@ 2017-06-08 17:43 ` Markus Armbruster
2017-06-09 10:11 ` Marc-André Lureau
2017-06-09 14:34 ` Max Reitz
0 siblings, 2 replies; 70+ messages in thread
From: Markus Armbruster @ 2017-06-08 17:43 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel, Kevin Wolf, Max Reitz
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> The dump functions could be generally useful for any qobject user or for
> debugging etc.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> include/qapi/qmp/qdict.h | 2 ++
> include/qapi/qmp/qlist.h | 2 ++
> include/qapi/qmp/qobject.h | 7 ++++
> block/qapi.c | 90 +++-------------------------------------------
> qobject/qdict.c | 30 ++++++++++++++++
> qobject/qlist.c | 23 ++++++++++++
> qobject/qobject.c | 19 ++++++++++
> tests/check-qjson.c | 19 ++++++++++
> 8 files changed, 106 insertions(+), 86 deletions(-)
>
> diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
> index 8c7c2b762b..1ef3bc8cda 100644
> --- a/include/qapi/qmp/qdict.h
> +++ b/include/qapi/qmp/qdict.h
> @@ -91,4 +91,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp);
>
> void qdict_join(QDict *dest, QDict *src, bool overwrite);
>
> +char *qdict_to_string(QDict *dict, int indent);
> +
> #endif /* QDICT_H */
> diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
> index c4b5fdad9b..c93ac3e15b 100644
> --- a/include/qapi/qmp/qlist.h
> +++ b/include/qapi/qmp/qlist.h
> @@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist);
> QList *qobject_to_qlist(const QObject *obj);
> void qlist_destroy_obj(QObject *obj);
>
> +char *qlist_to_string(QList *list, int indent);
> +
> static inline const QListEntry *qlist_first(const QList *qlist)
> {
> return QTAILQ_FIRST(&qlist->head);
> diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
> index b8ddbca405..0d6ae5048a 100644
> --- a/include/qapi/qmp/qobject.h
> +++ b/include/qapi/qmp/qobject.h
> @@ -101,4 +101,11 @@ static inline QObject *qnull(void)
> return &qnull_;
> }
>
> +char *qobject_to_string_indent(QObject *obj, int indent);
> +
> +static inline char *qobject_to_string(QObject *obj)
> +{
> + return qobject_to_string_indent(obj, 0);
> +}
> +
> #endif /* QOBJECT_H */
> diff --git a/block/qapi.c b/block/qapi.c
> index 2050df29e4..9b7d42e50a 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -586,101 +586,19 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,
> }
> }
>
> -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
> - QDict *dict);
> -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
> - QList *list);
> -
> -static void dump_qobject(fprintf_function func_fprintf, void *f,
> - int comp_indent, QObject *obj)
> -{
> - switch (qobject_type(obj)) {
> - case QTYPE_QNUM: {
> - QNum *value = qobject_to_qnum(obj);
> - char *tmp = qnum_to_string(value);
> - func_fprintf(f, "%s", tmp);
> - g_free(tmp);
> - break;
> - }
> - case QTYPE_QSTRING: {
> - QString *value = qobject_to_qstring(obj);
> - func_fprintf(f, "%s", qstring_get_str(value));
> - break;
> - }
> - case QTYPE_QDICT: {
> - QDict *value = qobject_to_qdict(obj);
> - dump_qdict(func_fprintf, f, comp_indent, value);
> - break;
> - }
> - case QTYPE_QLIST: {
> - QList *value = qobject_to_qlist(obj);
> - dump_qlist(func_fprintf, f, comp_indent, value);
> - break;
> - }
> - case QTYPE_QBOOL: {
> - QBool *value = qobject_to_qbool(obj);
> - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
> - break;
> - }
> - default:
> - abort();
> - }
> -}
> -
> -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
> - QList *list)
> -{
> - const QListEntry *entry;
> - int i = 0;
> -
> - for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
> - QType type = qobject_type(entry->value);
> - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i,
> - composite ? '\n' : ' ');
> - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
> - if (!composite) {
> - func_fprintf(f, "\n");
> - }
> - }
> -}
> -
> -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
> - QDict *dict)
> -{
> - const QDictEntry *entry;
> -
> - for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
> - QType type = qobject_type(entry->value);
> - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> - char *key = g_malloc(strlen(entry->key) + 1);
> - int i;
> -
> - /* replace dashes with spaces in key (variable) names */
> - for (i = 0; entry->key[i]; i++) {
> - key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
> - }
> - key[i] = 0;
> - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key,
> - composite ? '\n' : ' ');
> - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
> - if (!composite) {
> - func_fprintf(f, "\n");
> - }
> - g_free(key);
> - }
> -}
> -
> void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
> ImageInfoSpecific *info_spec)
> {
> QObject *obj, *data;
> Visitor *v = qobject_output_visitor_new(&obj);
> + char *tmp;
>
> visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
> visit_complete(v, &obj);
> data = qdict_get(qobject_to_qdict(obj), "data");
> - dump_qobject(func_fprintf, f, 1, data);
> + tmp = qobject_to_string_indent(data, 1);
> + func_fprintf(f, "%s", tmp);
> + g_free(tmp);
> qobject_decref(obj);
> visit_free(v);
> }
The title claims "move dump_qobject() from block/ to qobject/", but
that's not what the patch does. It *replaces* dump_qobject() by
qobject_to_string(). The former dumps to a callback, the latter to a
dynamic string buffer.
Providing dump functionality in one way doesn't preclude the other way:
given callback, one could define a callback that builds up a string
buffer, and given buffer, one could (and you actually do) pass the
buffer to a callback. That's less efficient, though.
Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
Max and Kevin to double-check.
Two ways forward:
1. Get Max / Kevin's blessing, change the commit message to match the
code.
2. Change the code to match the commit message.
> diff --git a/qobject/qdict.c b/qobject/qdict.c
> index 65069baa1b..7e5a945c5e 100644
> --- a/qobject/qdict.c
> +++ b/qobject/qdict.c
> @@ -1055,3 +1055,33 @@ void qdict_join(QDict *dest, QDict *src, bool overwrite)
> entry = next;
> }
> }
> +
> +char *qdict_to_string(QDict *dict, int indent)
> +{
> + const QDictEntry *entry;
> + GString *str = g_string_new(NULL);
> +
> + for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
> + QType type = qobject_type(entry->value);
> + bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> + char *key = g_malloc(strlen(entry->key) + 1);
> + char *val = qobject_to_string_indent(entry->value, indent + 1);
> + int i;
> +
> + /* replace dashes with spaces in key (variable) names */
> + for (i = 0; entry->key[i]; i++) {
> + key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
> + }
> + key[i] = 0;
> + g_string_append_printf(str, "%*s%s:", indent * 4, "", key);
> + g_string_append_c(str, composite ? '\n' : ' ');
> + g_string_append(str, val);
> + if (!composite) {
> + g_string_append_c(str, '\n');
> + }
> + g_free(val);
> + g_free(key);
> + }
> +
> + return g_string_free(str, false);
> +}
> diff --git a/qobject/qlist.c b/qobject/qlist.c
> index 86b60cb88c..b769248290 100644
> --- a/qobject/qlist.c
> +++ b/qobject/qlist.c
> @@ -158,3 +158,26 @@ void qlist_destroy_obj(QObject *obj)
>
> g_free(qlist);
> }
> +
> +char *qlist_to_string(QList *list, int indent)
> +{
> + GString *str = g_string_new(NULL);
> + const QListEntry *entry;
> + int i = 0;
> +
> + for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
> + QType type = qobject_type(entry->value);
> + bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> + char *val = qobject_to_string_indent(entry->value, indent + 1);
> +
> + g_string_append_printf(str, "%*s[%i]:", indent * 4, "", i);
> + g_string_append_c(str, composite ? '\n' : ' ');
> + g_string_append(str, val);
> + if (!composite) {
> + g_string_append_c(str, '\n');
> + }
> + g_free(val);
> + }
> +
> + return g_string_free(str, false);
> +}
> diff --git a/qobject/qobject.c b/qobject/qobject.c
> index b0cafb66f1..64e959c54f 100644
> --- a/qobject/qobject.c
> +++ b/qobject/qobject.c
> @@ -27,3 +27,22 @@ void qobject_destroy(QObject *obj)
> assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
> qdestroy[obj->type](obj);
> }
> +
> +char *qobject_to_string_indent(QObject *obj, int indent)
> +{
> + switch (qobject_type(obj)) {
> + case QTYPE_QNUM:
> + return qnum_to_string(qobject_to_qnum(obj));
> + case QTYPE_QSTRING:
> + return g_strdup(qstring_get_str(qobject_to_qstring(obj)));
> + case QTYPE_QDICT:
> + return qdict_to_string(qobject_to_qdict(obj), indent);
> + case QTYPE_QLIST:
> + return qlist_to_string(qobject_to_qlist(obj), indent);
> + case QTYPE_QBOOL:
> + return g_strdup(qbool_get_bool(qobject_to_qbool(obj)) ?
> + "true" : "false");
> + default:
> + abort();
> + }
> +}
> diff --git a/tests/check-qjson.c b/tests/check-qjson.c
> index 53f2275b9b..dd3c102bc0 100644
> --- a/tests/check-qjson.c
> +++ b/tests/check-qjson.c
> @@ -1372,6 +1372,23 @@ static void simple_whitespace(void)
> }
> }
>
> +static void qobject_to_string_test(void)
> +{
> + QObject *obj;
> + char *tmp;
> +
> + obj = qobject_from_json("[ 43, { 'c': { 'd' : 12 } }, [ 1, 2 ], 42 ]",
> + &error_abort);
> + tmp = qobject_to_string(obj);
> + g_assert_cmpstr(tmp, ==,
> + "[0]: 43\n"
> + "[1]:\n c:\n d: 12\n"
> + "[2]:\n [0]: 1\n [1]: 2\n"
> + "[3]: 42\n");
> + g_free(tmp);
> + qobject_decref(obj);
> +}
> +
> static void simple_varargs(void)
> {
> QObject *embedded_obj;
> @@ -1545,5 +1562,7 @@ int main(int argc, char **argv)
> g_test_add_func("/errors/unterminated/literal", unterminated_literal);
> g_test_add_func("/errors/limits/nesting", limits_nesting);
>
> + g_test_add_func("/qobject/to_string", qobject_to_string_test);
> +
> return g_test_run();
> }
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned
2017-06-08 17:08 ` Markus Armbruster
@ 2017-06-09 10:04 ` Marc-André Lureau
0 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-09 10:04 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
Hi
----- Original Message -----
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > Modify the unsigned type for various properties to use QNUM_U64, to
> > avoid type casts.
> >
> > There are a few empty lines added to improve code reading/style.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > include/hw/qdev-core.h | 1 +
> > include/hw/qdev-properties.h | 29 ++++++++++++++++++++---------
> > hw/core/qdev-properties.c | 23 ++++++++++++++---------
> > 3 files changed, 35 insertions(+), 18 deletions(-)
> >
> > diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> > index 784971b8d8..9d7c1c0e9b 100644
> > --- a/include/hw/qdev-core.h
> > +++ b/include/hw/qdev-core.h
> > @@ -228,6 +228,7 @@ struct Property {
> > uint8_t bitnr;
> > union {
> > int64_t i;
> > + uint64_t u;
> > } defval;
> > int arrayoffset;
> > PropertyInfo *arrayinfo;
> > diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> > index 34524d0bfe..1e5c928f32 100644
> > --- a/include/hw/qdev-properties.h
> > +++ b/include/hw/qdev-properties.h
> > @@ -37,6 +37,7 @@ extern PropertyInfo qdev_prop_arraylen;
> > .offset = offsetof(_state, _field) \
> > + type_check(_type, typeof_field(_state, _field)), \
> > }
> > +
> > #define DEFINE_PROP_SIGNED(_name, _state, _field, _defval, _prop, _type) {
> > \
> > .name = (_name), \
> > .info = &(_prop), \
> > @@ -44,21 +45,31 @@ extern PropertyInfo qdev_prop_arraylen;
> > + type_check(_type,typeof_field(_state, _field)), \
> > .defval.i = (_type)_defval, \
> > }
> > +
> > #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
> > .name = (_name), \
> > .info = &(qdev_prop_bit), \
> > .bitnr = (_bit), \
> > .offset = offsetof(_state, _field) \
> > + type_check(uint32_t,typeof_field(_state, _field)), \
> > - .defval.i = (bool)_defval, \
> > + .defval.u = (bool)_defval, \
> > + }
> > +
> > +#define DEFINE_PROP_UNSIGNED(_name, _state, _field, _defval, _prop, _type)
> > { \
> > + .name = (_name), \
> > + .info = &(_prop), \
> > + .offset = offsetof(_state, _field) \
> > + + type_check(_type, typeof_field(_state, _field)), \
> > + .defval.u = (_type)_defval, \
> > }
> > +
> > #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
> > .name = (_name), \
> > .info = &(qdev_prop_bit64), \
> > .bitnr = (_bit), \
> > .offset = offsetof(_state, _field) \
> > + type_check(uint64_t, typeof_field(_state, _field)), \
> > - .defval.i = (bool)_defval, \
> > + .defval.u = (bool)_defval, \
> > }
> >
> > #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \
> > @@ -66,7 +77,7 @@ extern PropertyInfo qdev_prop_arraylen;
> > .info = &(qdev_prop_bool), \
> > .offset = offsetof(_state, _field) \
> > + type_check(bool, typeof_field(_state, _field)), \
> > - .defval.i = (bool)_defval, \
> > + .defval.u = (bool)_defval, \
>
> Whitespace is off.
>
> > }
> >
> > #define PROP_ARRAY_LEN_PREFIX "len-"
> > @@ -107,17 +118,17 @@ extern PropertyInfo qdev_prop_arraylen;
> > }
> >
> > #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> > #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> > #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> > #define DEFINE_PROP_INT32(_n, _s, _f, _d) \
> > DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
> > #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> > #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
> > #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
> > DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
> >
> > @@ -163,7 +174,7 @@ extern PropertyInfo qdev_prop_arraylen;
> > #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
> > DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
> > #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \
> > - DEFINE_PROP_SIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
> > + DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
> > #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
> > DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr,
> > PCIHostDeviceAddress)
> >
> > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > index f3f682c611..a8f09c13e2 100644
> > --- a/hw/core/qdev-properties.c
> > +++ b/hw/core/qdev-properties.c
> > @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char
> > *name, void *opaque,
> >
> > static void set_default_value_enum(Object *obj, const Property *prop)
> > {
> > - object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
> > + object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
> > prop->name, &error_abort);
> > }
>
> You use DEFINE_PROP_SIGNED() for enums. Shouldn't we stick to defval.i?
Yes, enum should be signed, please fix on commit (unless I have to resend).
>
> >
> > @@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const
> > char *name,
> >
> > static void set_default_value_bool(Object *obj, const Property *prop)
> > {
> > - object_property_set_bool(obj, prop->defval.i, prop->name,
> > &error_abort);
> > + object_property_set_bool(obj, prop->defval.u, prop->name,
> > &error_abort);
> > }
> >
> > PropertyInfo qdev_prop_bit = {
> > @@ -264,11 +264,16 @@ 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_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > /* --- 16bit integer --- */
> > @@ -302,7 +307,7 @@ PropertyInfo qdev_prop_uint16 = {
> > .name = "uint16",
> > .get = get_uint16,
> > .set = set_uint16,
> > - .set_default_value = set_default_value_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > /* --- 32bit integer --- */
> > @@ -361,7 +366,7 @@ PropertyInfo qdev_prop_uint32 = {
> > .name = "uint32",
> > .get = get_uint32,
> > .set = set_uint32,
> > - .set_default_value = set_default_value_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > PropertyInfo qdev_prop_int32 = {
> > @@ -402,7 +407,7 @@ PropertyInfo qdev_prop_uint64 = {
> > .name = "uint64",
> > .get = get_uint64,
> > .set = set_uint64,
> > - .set_default_value = set_default_value_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > /* --- string --- */
> > @@ -725,7 +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_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > /* --- pci host address --- */
> > @@ -948,7 +953,7 @@ PropertyInfo qdev_prop_arraylen = {
> > .name = "uint32",
> > .get = get_uint32,
> > .set = set_prop_arraylen,
> > - .set_default_value = set_default_value_int,
> > + .set_default_value = set_default_value_uint,
> > };
> >
> > /* --- public helpers --- */
> > @@ -1185,5 +1190,5 @@ PropertyInfo qdev_prop_size = {
> > .name = "size",
> > .get = get_size,
> > .set = set_size,
> > - .set_default_value = set_default_value_int,
> > + .set_default_value = set_default_value_uint,
> > };
>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint
2017-06-08 17:25 ` Markus Armbruster
@ 2017-06-09 10:05 ` Marc-André Lureau
0 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-09 10:05 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
Hi
----- Original Message -----
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > Similar to int support, add uint support.
> >
> > Note this is RFC because this is currently unused in qemu, I haven't
> > found a good user for it yet (kaslr qemu-ga code did use it though).
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
>
> We need to make up our mind whether to store this in the tree or on the
> mailing list.
>
Let's keep it on the ML for now.
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-08 17:43 ` Markus Armbruster
@ 2017-06-09 10:11 ` Marc-André Lureau
2017-06-09 10:15 ` Marc-André Lureau
2017-06-09 14:34 ` Max Reitz
1 sibling, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-09 10:11 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, Kevin Wolf, Max Reitz
----- Original Message -----
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > The dump functions could be generally useful for any qobject user or for
> > debugging etc.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > include/qapi/qmp/qdict.h | 2 ++
> > include/qapi/qmp/qlist.h | 2 ++
> > include/qapi/qmp/qobject.h | 7 ++++
> > block/qapi.c | 90
> > +++-------------------------------------------
> > qobject/qdict.c | 30 ++++++++++++++++
> > qobject/qlist.c | 23 ++++++++++++
> > qobject/qobject.c | 19 ++++++++++
> > tests/check-qjson.c | 19 ++++++++++
> > 8 files changed, 106 insertions(+), 86 deletions(-)
> >
> > diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
> > index 8c7c2b762b..1ef3bc8cda 100644
> > --- a/include/qapi/qmp/qdict.h
> > +++ b/include/qapi/qmp/qdict.h
> > @@ -91,4 +91,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp);
> >
> > void qdict_join(QDict *dest, QDict *src, bool overwrite);
> >
> > +char *qdict_to_string(QDict *dict, int indent);
> > +
> > #endif /* QDICT_H */
> > diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
> > index c4b5fdad9b..c93ac3e15b 100644
> > --- a/include/qapi/qmp/qlist.h
> > +++ b/include/qapi/qmp/qlist.h
> > @@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist);
> > QList *qobject_to_qlist(const QObject *obj);
> > void qlist_destroy_obj(QObject *obj);
> >
> > +char *qlist_to_string(QList *list, int indent);
> > +
> > static inline const QListEntry *qlist_first(const QList *qlist)
> > {
> > return QTAILQ_FIRST(&qlist->head);
> > diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
> > index b8ddbca405..0d6ae5048a 100644
> > --- a/include/qapi/qmp/qobject.h
> > +++ b/include/qapi/qmp/qobject.h
> > @@ -101,4 +101,11 @@ static inline QObject *qnull(void)
> > return &qnull_;
> > }
> >
> > +char *qobject_to_string_indent(QObject *obj, int indent);
> > +
> > +static inline char *qobject_to_string(QObject *obj)
> > +{
> > + return qobject_to_string_indent(obj, 0);
> > +}
> > +
> > #endif /* QOBJECT_H */
> > diff --git a/block/qapi.c b/block/qapi.c
> > index 2050df29e4..9b7d42e50a 100644
> > --- a/block/qapi.c
> > +++ b/block/qapi.c
> > @@ -586,101 +586,19 @@ void bdrv_snapshot_dump(fprintf_function
> > func_fprintf, void *f,
> > }
> > }
> >
> > -static void dump_qdict(fprintf_function func_fprintf, void *f, int
> > indentation,
> > - QDict *dict);
> > -static void dump_qlist(fprintf_function func_fprintf, void *f, int
> > indentation,
> > - QList *list);
> > -
> > -static void dump_qobject(fprintf_function func_fprintf, void *f,
> > - int comp_indent, QObject *obj)
> > -{
> > - switch (qobject_type(obj)) {
> > - case QTYPE_QNUM: {
> > - QNum *value = qobject_to_qnum(obj);
> > - char *tmp = qnum_to_string(value);
> > - func_fprintf(f, "%s", tmp);
> > - g_free(tmp);
> > - break;
> > - }
> > - case QTYPE_QSTRING: {
> > - QString *value = qobject_to_qstring(obj);
> > - func_fprintf(f, "%s", qstring_get_str(value));
> > - break;
> > - }
> > - case QTYPE_QDICT: {
> > - QDict *value = qobject_to_qdict(obj);
> > - dump_qdict(func_fprintf, f, comp_indent, value);
> > - break;
> > - }
> > - case QTYPE_QLIST: {
> > - QList *value = qobject_to_qlist(obj);
> > - dump_qlist(func_fprintf, f, comp_indent, value);
> > - break;
> > - }
> > - case QTYPE_QBOOL: {
> > - QBool *value = qobject_to_qbool(obj);
> > - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" :
> > "false");
> > - break;
> > - }
> > - default:
> > - abort();
> > - }
> > -}
> > -
> > -static void dump_qlist(fprintf_function func_fprintf, void *f, int
> > indentation,
> > - QList *list)
> > -{
> > - const QListEntry *entry;
> > - int i = 0;
> > -
> > - for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++)
> > {
> > - QType type = qobject_type(entry->value);
> > - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> > - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i,
> > - composite ? '\n' : ' ');
> > - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
> > - if (!composite) {
> > - func_fprintf(f, "\n");
> > - }
> > - }
> > -}
> > -
> > -static void dump_qdict(fprintf_function func_fprintf, void *f, int
> > indentation,
> > - QDict *dict)
> > -{
> > - const QDictEntry *entry;
> > -
> > - for (entry = qdict_first(dict); entry; entry = qdict_next(dict,
> > entry)) {
> > - QType type = qobject_type(entry->value);
> > - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> > - char *key = g_malloc(strlen(entry->key) + 1);
> > - int i;
> > -
> > - /* replace dashes with spaces in key (variable) names */
> > - for (i = 0; entry->key[i]; i++) {
> > - key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
> > - }
> > - key[i] = 0;
> > - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key,
> > - composite ? '\n' : ' ');
> > - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
> > - if (!composite) {
> > - func_fprintf(f, "\n");
> > - }
> > - g_free(key);
> > - }
> > -}
> > -
> > void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
> > ImageInfoSpecific *info_spec)
> > {
> > QObject *obj, *data;
> > Visitor *v = qobject_output_visitor_new(&obj);
> > + char *tmp;
> >
> > visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
> > visit_complete(v, &obj);
> > data = qdict_get(qobject_to_qdict(obj), "data");
> > - dump_qobject(func_fprintf, f, 1, data);
> > + tmp = qobject_to_string_indent(data, 1);
> > + func_fprintf(f, "%s", tmp);
> > + g_free(tmp);
> > qobject_decref(obj);
> > visit_free(v);
> > }
>
> The title claims "move dump_qobject() from block/ to qobject/", but
> that's not what the patch does. It *replaces* dump_qobject() by
> qobject_to_string(). The former dumps to a callback, the latter to a
> dynamic string buffer.
>
> Providing dump functionality in one way doesn't preclude the other way:
> given callback, one could define a callback that builds up a string
> buffer, and given buffer, one could (and you actually do) pass the
> buffer to a callback. That's less efficient, though.
>
> Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
> Max and Kevin to double-check.
I believe convenience is more important than efficiency here. It's easy to call qobject_to_string(foo) from gdb for example, with a callback, it's less easy.
(fprintf or monitor_fprintf will both build an internal buffer anyway, efficiency is probably similar)
>
> Two ways forward:
>
> 1. Get Max / Kevin's blessing, change the commit message to match the
> code.
>
> 2. Change the code to match the commit message.
>
> > diff --git a/qobject/qdict.c b/qobject/qdict.c
> > index 65069baa1b..7e5a945c5e 100644
> > --- a/qobject/qdict.c
> > +++ b/qobject/qdict.c
> > @@ -1055,3 +1055,33 @@ void qdict_join(QDict *dest, QDict *src, bool
> > overwrite)
> > entry = next;
> > }
> > }
> > +
> > +char *qdict_to_string(QDict *dict, int indent)
> > +{
> > + const QDictEntry *entry;
> > + GString *str = g_string_new(NULL);
> > +
> > + for (entry = qdict_first(dict); entry; entry = qdict_next(dict,
> > entry)) {
> > + QType type = qobject_type(entry->value);
> > + bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> > + char *key = g_malloc(strlen(entry->key) + 1);
> > + char *val = qobject_to_string_indent(entry->value, indent + 1);
> > + int i;
> > +
> > + /* replace dashes with spaces in key (variable) names */
> > + for (i = 0; entry->key[i]; i++) {
> > + key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
> > + }
> > + key[i] = 0;
> > + g_string_append_printf(str, "%*s%s:", indent * 4, "", key);
> > + g_string_append_c(str, composite ? '\n' : ' ');
> > + g_string_append(str, val);
> > + if (!composite) {
> > + g_string_append_c(str, '\n');
> > + }
> > + g_free(val);
> > + g_free(key);
> > + }
> > +
> > + return g_string_free(str, false);
> > +}
> > diff --git a/qobject/qlist.c b/qobject/qlist.c
> > index 86b60cb88c..b769248290 100644
> > --- a/qobject/qlist.c
> > +++ b/qobject/qlist.c
> > @@ -158,3 +158,26 @@ void qlist_destroy_obj(QObject *obj)
> >
> > g_free(qlist);
> > }
> > +
> > +char *qlist_to_string(QList *list, int indent)
> > +{
> > + GString *str = g_string_new(NULL);
> > + const QListEntry *entry;
> > + int i = 0;
> > +
> > + for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++)
> > {
> > + QType type = qobject_type(entry->value);
> > + bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> > + char *val = qobject_to_string_indent(entry->value, indent + 1);
> > +
> > + g_string_append_printf(str, "%*s[%i]:", indent * 4, "", i);
> > + g_string_append_c(str, composite ? '\n' : ' ');
> > + g_string_append(str, val);
> > + if (!composite) {
> > + g_string_append_c(str, '\n');
> > + }
> > + g_free(val);
> > + }
> > +
> > + return g_string_free(str, false);
> > +}
> > diff --git a/qobject/qobject.c b/qobject/qobject.c
> > index b0cafb66f1..64e959c54f 100644
> > --- a/qobject/qobject.c
> > +++ b/qobject/qobject.c
> > @@ -27,3 +27,22 @@ void qobject_destroy(QObject *obj)
> > assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
> > qdestroy[obj->type](obj);
> > }
> > +
> > +char *qobject_to_string_indent(QObject *obj, int indent)
> > +{
> > + switch (qobject_type(obj)) {
> > + case QTYPE_QNUM:
> > + return qnum_to_string(qobject_to_qnum(obj));
> > + case QTYPE_QSTRING:
> > + return g_strdup(qstring_get_str(qobject_to_qstring(obj)));
> > + case QTYPE_QDICT:
> > + return qdict_to_string(qobject_to_qdict(obj), indent);
> > + case QTYPE_QLIST:
> > + return qlist_to_string(qobject_to_qlist(obj), indent);
> > + case QTYPE_QBOOL:
> > + return g_strdup(qbool_get_bool(qobject_to_qbool(obj)) ?
> > + "true" : "false");
> > + default:
> > + abort();
> > + }
> > +}
> > diff --git a/tests/check-qjson.c b/tests/check-qjson.c
> > index 53f2275b9b..dd3c102bc0 100644
> > --- a/tests/check-qjson.c
> > +++ b/tests/check-qjson.c
> > @@ -1372,6 +1372,23 @@ static void simple_whitespace(void)
> > }
> > }
> >
> > +static void qobject_to_string_test(void)
> > +{
> > + QObject *obj;
> > + char *tmp;
> > +
> > + obj = qobject_from_json("[ 43, { 'c': { 'd' : 12 } }, [ 1, 2 ], 42 ]",
> > + &error_abort);
> > + tmp = qobject_to_string(obj);
> > + g_assert_cmpstr(tmp, ==,
> > + "[0]: 43\n"
> > + "[1]:\n c:\n d: 12\n"
> > + "[2]:\n [0]: 1\n [1]: 2\n"
> > + "[3]: 42\n");
> > + g_free(tmp);
> > + qobject_decref(obj);
> > +}
> > +
> > static void simple_varargs(void)
> > {
> > QObject *embedded_obj;
> > @@ -1545,5 +1562,7 @@ int main(int argc, char **argv)
> > g_test_add_func("/errors/unterminated/literal", unterminated_literal);
> > g_test_add_func("/errors/limits/nesting", limits_nesting);
> >
> > + g_test_add_func("/qobject/to_string", qobject_to_string_test);
> > +
> > return g_test_run();
> > }
>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-09 10:11 ` Marc-André Lureau
@ 2017-06-09 10:15 ` Marc-André Lureau
2017-06-09 12:40 ` Markus Armbruster
0 siblings, 1 reply; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-09 10:15 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel, Kevin Wolf, Max Reitz
Hi
----- Original Message -----
> >
> > The title claims "move dump_qobject() from block/ to qobject/", but
> > that's not what the patch does. It *replaces* dump_qobject() by
> > qobject_to_string(). The former dumps to a callback, the latter to a
> > dynamic string buffer.
> >
> > Providing dump functionality in one way doesn't preclude the other way:
> > given callback, one could define a callback that builds up a string
> > buffer, and given buffer, one could (and you actually do) pass the
> > buffer to a callback. That's less efficient, though.
> >
> > Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
> > Max and Kevin to double-check.
>
> I believe convenience is more important than efficiency here. It's easy to
> call qobject_to_string(foo) from gdb for example, with a callback, it's less
> easy.
>
> (fprintf or monitor_fprintf will both build an internal buffer anyway,
> efficiency is probably similar)
>
Hmm, there are more allocations in qobject_to_string() though
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
` (44 preceding siblings ...)
2017-06-08 1:47 ` no-reply
@ 2017-06-09 12:32 ` Markus Armbruster
2017-06-09 13:06 ` Marc-André Lureau
45 siblings, 1 reply; 70+ messages in thread
From: Markus Armbruster @ 2017-06-09 12:32 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: qemu-devel
PATCH 01-41 look ready with minor tweaks. I chatted with Marc-André,
and he asked me to apply them myself. You can find the result at
https://repo.or.cz/qemu/armbru.git in branch qapi-next. Marc-André,
please give it a quick look-over. If it's good, I'll post a pull
request later today.
PATCH 42 is RFC. I'd like to give PATCH 43 a bit more time on the list.
Incremental diff for your convenience:
diff --git a/blockdev.c b/blockdev.c
index 154c95d..4009dd9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -335,10 +335,9 @@ static bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals,
}
case QTYPE_QNUM: {
- int64_t length;
+ int64_t length = qnum_get_int(qobject_to_qnum(entry->value));
- if (qnum_get_try_int(qobject_to_qnum(entry->value), &length) &&
- length > 0 && length <= UINT_MAX) {
+ if (length > 0 && length <= UINT_MAX) {
block_acct_add_interval(stats, (unsigned) length);
} else {
error_setg(errp, "Invalid interval length: %" PRId64, length);
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a8f09c1..68cd653 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char *name, void *opaque,
static void set_default_value_enum(Object *obj, const Property *prop)
{
- object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
+ object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
prop->name, &error_abort);
}
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 3bcdb9a..34bab8a 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -152,6 +152,7 @@ static void test_visitor_in_uint(TestInputVisitorData *data,
g_assert_cmpuint(res, ==, 18446744073709551574U);
visit_type_number(v, NULL, &dbl, &error_abort);
+ g_assert_cmpfloat(dbl, ==, 18446744073709552000.0);
}
static void test_visitor_in_int_overflow(TestInputVisitorData *data,
@@ -161,9 +162,10 @@ static void test_visitor_in_int_overflow(TestInputVisitorData *data,
Error *err = NULL;
Visitor *v;
- /* this will overflow a QNUM_I64, so should be deserialized into a
+ /*
+ * This will overflow a QNUM_I64, so should be deserialized into a
* QNUM_DOUBLE field instead, leading to an error if we pass it to
- * visit_type_int. confirm this.
+ * visit_type_int(). Confirm this.
*/
v = visitor_input_test_init(data, "%f", DBL_MAX);
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index d23c8eb..749c540 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -609,11 +609,13 @@ static void check_native_list(QObject *qobj,
for (i = 0; i < 32; i++) {
QObject *tmp;
QNum *qvalue;
+ uint64_t val;
tmp = qlist_peek(qlist);
g_assert(tmp);
qvalue = qobject_to_qnum(tmp);
- g_assert_cmpuint(qnum_get_uint(qvalue), ==, i);
+ g_assert(qnum_get_try_uint(qvalue, &val));
+ g_assert_cmpint(val, ==, i);
qobject_decref(qlist_pop(qlist));
}
break;
^ permalink raw reply related [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-09 10:15 ` Marc-André Lureau
@ 2017-06-09 12:40 ` Markus Armbruster
2017-06-09 12:46 ` Eric Blake
0 siblings, 1 reply; 70+ messages in thread
From: Markus Armbruster @ 2017-06-09 12:40 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Kevin Wolf, qemu-devel, Max Reitz
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> Hi
>
> ----- Original Message -----
>> >
>> > The title claims "move dump_qobject() from block/ to qobject/", but
>> > that's not what the patch does. It *replaces* dump_qobject() by
>> > qobject_to_string(). The former dumps to a callback, the latter to a
>> > dynamic string buffer.
>> >
>> > Providing dump functionality in one way doesn't preclude the other way:
>> > given callback, one could define a callback that builds up a string
>> > buffer, and given buffer, one could (and you actually do) pass the
>> > buffer to a callback. That's less efficient, though.
>> >
>> > Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
>> > Max and Kevin to double-check.
>>
>> I believe convenience is more important than efficiency here. It's easy to
>> call qobject_to_string(foo) from gdb for example, with a callback, it's less
>> easy.
>>
>> (fprintf or monitor_fprintf will both build an internal buffer anyway,
>> efficiency is probably similar)
monitor_vprintf() formats to a dynamic buffer, which it passes to
monitor_puts(). monitor_puts() uses a line buffer.
fprintf() can be unbuffered, line-buffered, or fully buffered.
Converting everything to a string first is different: the string buffer
holds *everything* rather than just a line or some fixed size.
> Hmm, there are more allocations in qobject_to_string() though
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-09 12:40 ` Markus Armbruster
@ 2017-06-09 12:46 ` Eric Blake
0 siblings, 0 replies; 70+ messages in thread
From: Eric Blake @ 2017-06-09 12:46 UTC (permalink / raw)
To: Markus Armbruster, Marc-André Lureau
Cc: Kevin Wolf, qemu-devel, Max Reitz
[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]
On 06/09/2017 07:40 AM, Markus Armbruster wrote:
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
>> Hi
>>
>> ----- Original Message -----
>>>>
>>>> The title claims "move dump_qobject() from block/ to qobject/", but
>>>> that's not what the patch does. It *replaces* dump_qobject() by
>>>> qobject_to_string(). The former dumps to a callback, the latter to a
>>>> dynamic string buffer.
>>>>
>>>> Providing dump functionality in one way doesn't preclude the other way:
>>>> given callback, one could define a callback that builds up a string
>>>> buffer, and given buffer, one could (and you actually do) pass the
>>>> buffer to a callback. That's less efficient, though.
>>>>
>>>> Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
>>>> Max and Kevin to double-check.
>>>
>>> I believe convenience is more important than efficiency here. It's easy to
>>> call qobject_to_string(foo) from gdb for example, with a callback, it's less
>>> easy.
>>>
>>> (fprintf or monitor_fprintf will both build an internal buffer anyway,
>>> efficiency is probably similar)
>
> monitor_vprintf() formats to a dynamic buffer, which it passes to
> monitor_puts(). monitor_puts() uses a line buffer.
>
> fprintf() can be unbuffered, line-buffered, or fully buffered.
>
> Converting everything to a string first is different: the string buffer
> holds *everything* rather than just a line or some fixed size.
My patch series to create a QAPI-to-JSON output visitor, and convert the
existing qobject-to-json conversion to be a thin wrapper over the JSON
visitor, is a natural place to create a visitor constructor that can
take a callback (where the callback either appends to a QString or uses
pwrite() (no need to spend time with the slower printf()) to go straight
to stdout. I'll have to revive that series on top of your work.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
2017-06-09 12:32 ` Markus Armbruster
@ 2017-06-09 13:06 ` Marc-André Lureau
0 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-09 13:06 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-devel
Hi
----- Original Message -----
> PATCH 01-41 look ready with minor tweaks. I chatted with Marc-André,
> and he asked me to apply them myself. You can find the result at
> https://repo.or.cz/qemu/armbru.git in branch qapi-next. Marc-André,
> please give it a quick look-over. If it's good, I'll post a pull
> request later today.
Looks good to me, thanks a lot!
>
> PATCH 42 is RFC. I'd like to give PATCH 43 a bit more time on the list.
>
> Incremental diff for your convenience:
>
> diff --git a/blockdev.c b/blockdev.c
> index 154c95d..4009dd9 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -335,10 +335,9 @@ static bool parse_stats_intervals(BlockAcctStats *stats,
> QList *intervals,
> }
>
> case QTYPE_QNUM: {
> - int64_t length;
> + int64_t length = qnum_get_int(qobject_to_qnum(entry->value));
>
> - if (qnum_get_try_int(qobject_to_qnum(entry->value), &length) &&
> - length > 0 && length <= UINT_MAX) {
> + if (length > 0 && length <= UINT_MAX) {
> block_acct_add_interval(stats, (unsigned) length);
> } else {
> error_setg(errp, "Invalid interval length: %" PRId64,
> length);
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index a8f09c1..68cd653 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char
> *name, void *opaque,
>
> static void set_default_value_enum(Object *obj, const Property *prop)
> {
> - object_property_set_str(obj, prop->info->enum_table[prop->defval.u],
> + object_property_set_str(obj, prop->info->enum_table[prop->defval.i],
> prop->name, &error_abort);
> }
>
> diff --git a/tests/test-qobject-input-visitor.c
> b/tests/test-qobject-input-visitor.c
> index 3bcdb9a..34bab8a 100644
> --- a/tests/test-qobject-input-visitor.c
> +++ b/tests/test-qobject-input-visitor.c
> @@ -152,6 +152,7 @@ static void test_visitor_in_uint(TestInputVisitorData
> *data,
> g_assert_cmpuint(res, ==, 18446744073709551574U);
>
> visit_type_number(v, NULL, &dbl, &error_abort);
> + g_assert_cmpfloat(dbl, ==, 18446744073709552000.0);
> }
>
> static void test_visitor_in_int_overflow(TestInputVisitorData *data,
> @@ -161,9 +162,10 @@ static void
> test_visitor_in_int_overflow(TestInputVisitorData *data,
> Error *err = NULL;
> Visitor *v;
>
> - /* this will overflow a QNUM_I64, so should be deserialized into a
> + /*
> + * This will overflow a QNUM_I64, so should be deserialized into a
> * QNUM_DOUBLE field instead, leading to an error if we pass it to
> - * visit_type_int. confirm this.
> + * visit_type_int(). Confirm this.
> */
> v = visitor_input_test_init(data, "%f", DBL_MAX);
>
> diff --git a/tests/test-qobject-output-visitor.c
> b/tests/test-qobject-output-visitor.c
> index d23c8eb..749c540 100644
> --- a/tests/test-qobject-output-visitor.c
> +++ b/tests/test-qobject-output-visitor.c
> @@ -609,11 +609,13 @@ static void check_native_list(QObject *qobj,
> for (i = 0; i < 32; i++) {
> QObject *tmp;
> QNum *qvalue;
> + uint64_t val;
>
> tmp = qlist_peek(qlist);
> g_assert(tmp);
> qvalue = qobject_to_qnum(tmp);
> - g_assert_cmpuint(qnum_get_uint(qvalue), ==, i);
> + g_assert(qnum_get_try_uint(qvalue, &val));
> + g_assert_cmpint(val, ==, i);
> qobject_decref(qlist_pop(qlist));
> }
> break;
>
^ permalink raw reply [flat|nested] 70+ messages in thread
* Re: [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/
2017-06-08 17:43 ` Markus Armbruster
2017-06-09 10:11 ` Marc-André Lureau
@ 2017-06-09 14:34 ` Max Reitz
1 sibling, 0 replies; 70+ messages in thread
From: Max Reitz @ 2017-06-09 14:34 UTC (permalink / raw)
To: Markus Armbruster, Marc-André Lureau; +Cc: qemu-devel, Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 7460 bytes --]
On 2017-06-08 19:43, Markus Armbruster wrote:
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
>> The dump functions could be generally useful for any qobject user or for
>> debugging etc.
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>> include/qapi/qmp/qdict.h | 2 ++
>> include/qapi/qmp/qlist.h | 2 ++
>> include/qapi/qmp/qobject.h | 7 ++++
>> block/qapi.c | 90 +++-------------------------------------------
>> qobject/qdict.c | 30 ++++++++++++++++
>> qobject/qlist.c | 23 ++++++++++++
>> qobject/qobject.c | 19 ++++++++++
>> tests/check-qjson.c | 19 ++++++++++
>> 8 files changed, 106 insertions(+), 86 deletions(-)
>>
>> diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
>> index 8c7c2b762b..1ef3bc8cda 100644
>> --- a/include/qapi/qmp/qdict.h
>> +++ b/include/qapi/qmp/qdict.h
>> @@ -91,4 +91,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp);
>>
>> void qdict_join(QDict *dest, QDict *src, bool overwrite);
>>
>> +char *qdict_to_string(QDict *dict, int indent);
>> +
>> #endif /* QDICT_H */
>> diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
>> index c4b5fdad9b..c93ac3e15b 100644
>> --- a/include/qapi/qmp/qlist.h
>> +++ b/include/qapi/qmp/qlist.h
>> @@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist);
>> QList *qobject_to_qlist(const QObject *obj);
>> void qlist_destroy_obj(QObject *obj);
>>
>> +char *qlist_to_string(QList *list, int indent);
>> +
>> static inline const QListEntry *qlist_first(const QList *qlist)
>> {
>> return QTAILQ_FIRST(&qlist->head);
>> diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
>> index b8ddbca405..0d6ae5048a 100644
>> --- a/include/qapi/qmp/qobject.h
>> +++ b/include/qapi/qmp/qobject.h
>> @@ -101,4 +101,11 @@ static inline QObject *qnull(void)
>> return &qnull_;
>> }
>>
>> +char *qobject_to_string_indent(QObject *obj, int indent);
>> +
>> +static inline char *qobject_to_string(QObject *obj)
>> +{
>> + return qobject_to_string_indent(obj, 0);
>> +}
>> +
>> #endif /* QOBJECT_H */
>> diff --git a/block/qapi.c b/block/qapi.c
>> index 2050df29e4..9b7d42e50a 100644
>> --- a/block/qapi.c
>> +++ b/block/qapi.c
>> @@ -586,101 +586,19 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,
>> }
>> }
>>
>> -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
>> - QDict *dict);
>> -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
>> - QList *list);
>> -
>> -static void dump_qobject(fprintf_function func_fprintf, void *f,
>> - int comp_indent, QObject *obj)
>> -{
>> - switch (qobject_type(obj)) {
>> - case QTYPE_QNUM: {
>> - QNum *value = qobject_to_qnum(obj);
>> - char *tmp = qnum_to_string(value);
>> - func_fprintf(f, "%s", tmp);
>> - g_free(tmp);
>> - break;
>> - }
>> - case QTYPE_QSTRING: {
>> - QString *value = qobject_to_qstring(obj);
>> - func_fprintf(f, "%s", qstring_get_str(value));
>> - break;
>> - }
>> - case QTYPE_QDICT: {
>> - QDict *value = qobject_to_qdict(obj);
>> - dump_qdict(func_fprintf, f, comp_indent, value);
>> - break;
>> - }
>> - case QTYPE_QLIST: {
>> - QList *value = qobject_to_qlist(obj);
>> - dump_qlist(func_fprintf, f, comp_indent, value);
>> - break;
>> - }
>> - case QTYPE_QBOOL: {
>> - QBool *value = qobject_to_qbool(obj);
>> - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false");
>> - break;
>> - }
>> - default:
>> - abort();
>> - }
>> -}
>> -
>> -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation,
>> - QList *list)
>> -{
>> - const QListEntry *entry;
>> - int i = 0;
>> -
>> - for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) {
>> - QType type = qobject_type(entry->value);
>> - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
>> - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i,
>> - composite ? '\n' : ' ');
>> - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
>> - if (!composite) {
>> - func_fprintf(f, "\n");
>> - }
>> - }
>> -}
>> -
>> -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
>> - QDict *dict)
>> -{
>> - const QDictEntry *entry;
>> -
>> - for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
>> - QType type = qobject_type(entry->value);
>> - bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
>> - char *key = g_malloc(strlen(entry->key) + 1);
>> - int i;
>> -
>> - /* replace dashes with spaces in key (variable) names */
>> - for (i = 0; entry->key[i]; i++) {
>> - key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
>> - }
>> - key[i] = 0;
>> - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key,
>> - composite ? '\n' : ' ');
>> - dump_qobject(func_fprintf, f, indentation + 1, entry->value);
>> - if (!composite) {
>> - func_fprintf(f, "\n");
>> - }
>> - g_free(key);
>> - }
>> -}
>> -
>> void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
>> ImageInfoSpecific *info_spec)
>> {
>> QObject *obj, *data;
>> Visitor *v = qobject_output_visitor_new(&obj);
>> + char *tmp;
>>
>> visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort);
>> visit_complete(v, &obj);
>> data = qdict_get(qobject_to_qdict(obj), "data");
>> - dump_qobject(func_fprintf, f, 1, data);
>> + tmp = qobject_to_string_indent(data, 1);
>> + func_fprintf(f, "%s", tmp);
>> + g_free(tmp);
>> qobject_decref(obj);
>> visit_free(v);
>> }
>
> The title claims "move dump_qobject() from block/ to qobject/", but
> that's not what the patch does. It *replaces* dump_qobject() by
> qobject_to_string(). The former dumps to a callback, the latter to a
> dynamic string buffer.
>
> Providing dump functionality in one way doesn't preclude the other way:
> given callback, one could define a callback that builds up a string
> buffer, and given buffer, one could (and you actually do) pass the
> buffer to a callback. That's less efficient, though.
>
> Trading efficiency for ease-of-use should be okay here, but I'm cc'ing
> Max and Kevin to double-check.
Given that this function is called only by HMP's "info block -v" and
qemu-img, I don't think efficiency is too important. In the former case,
it's your own fault for using HMP, in the latter you'll have only a
single image anyway.
So I'm OK with this change.
Max
>
> Two ways forward:
>
> 1. Get Max / Kevin's blessing, change the commit message to match the
> code.
>
> 2. Change the code to match the commit message.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]
^ permalink raw reply [flat|nested] 70+ messages in thread
* [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type
@ 2017-06-07 16:30 Marc-André Lureau
0 siblings, 0 replies; 70+ messages in thread
From: Marc-André Lureau @ 2017-06-07 16:30 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Marc-André Lureau
Hi,
In previously sent series "[PATCH 00/21] WIP: dump: add kaslr support
(for after 2.9)", I proposed changes to accept uint64 values from
json, by adding a QUint type. During review, it was suggested to
introduce a QNum type to hold various number representations.
This series introduces the QNum type, adds uint representation to it,
and make uint64 values over json possible (while keeping json negative
int for values >INT64_MAX to unsigned cast compatibility). It also
improves some int vs uint usage for object properties and other
QObject related clean-ups.
v3:
- rebased, drop the first keyval-related patches now upstream
- update "tests: Remove test cases for alternates of 'number' and 'int'"
commit message, and drop now useless conflict checks
- added "qapi: minor refactoring"
- add missing Author/Copyright lines lost during merge
- add qnum_get_try_(u)int() and simplify related code
- fix some code comments
- replace g_assert_not_reached() with assert(0) in qapi/
- replace qapi/qmp/types.h include with the min required headers
- add comment about changes in json serialization in "qapi: update the
qobject visitor to use QNUM_U64"
- update comment in "object: use more specific property type names"
with the externally visible changes
- split "qdev: make default property int" patch, rename macros
DEFINE_PROP_SIGNED/DEFINE_PROP_UNSIGNED
- in tests, compare with expected float value
- add r-b and suggested tags
v2:
- add set_default_value() callback in PropertyInfo
- use Markus version of "remove alt num-int cases"
- add more int/number ranges visitor checks
- replace Error usage for success bool return value in get_int/uint()
- various updated comments, patch and code reorganization
- avoid temporary regression from patch "json: learn to parse uint64
numbers", drop related patch
- split get_mmcfg_size() fix in a seperate patch
- added "apic-common: make "id" property a uint32" patch
- split the qdev uint proprety patch
- split "Use uint property getter/setter where appropriate" in various
patches
- add some qdict tests
- dropped s3/s4 bool patch
- add some r-b tags
Marc-André Lureau (43):
qdev: remove PropertyInfo.qtype field
object: fix potential leak in getters
tests: Remove test cases for alternates of 'number' and 'int'
tests: add more int/number ranges checks
qapi: minor refactoring
qapi: merge QInt and QFloat in QNum
qapi: Remove visit_start_alternate() parameter promote_int
tests: remove /{qnum,qlist,dict}/destroy test
qnum: add uint type
json: learn to parse uint64 numbers
qapi: update the qobject visitor to use QNUM_U64
object: add uint property setter/getter
q35: fix get_mmcfg_size to use uint64 visitor
object: use more specific property type names
qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED()
qdev: wrap default property value in an union
qdev: avoid type casts between signed and unsigned
apic-common: make "id" property a uint32
qdev: use appropriate getter/setters type
isa: use get_uint() for "io-base"
pc-dimm: use get_uint() for dimm properties
pc-dimm: make "size" property uint64
pcihp: use get_uint() for "bsel" property
aspeed: use {set,get}_uint() for "ram-size" property
bcm2835_fb: use {get,set}_uint() for "vcram-size" and "vcram-base"
platform-bus: use get_uint() for "addr" property
acpi: use get_uint() for "acpi-pcihp-io*" properties
acpi: use get_uint() for various acpi properties
acpi: use get_uint() for "pci-hole*" properties
pc: use get_uint() for "iobase" property
pc: use get_uint() for "apic-id" property
pc: use get_uint() for "hpet-intcap" property
xen: use get_uint() for "max-ram-below-4g" property
arm: use get_uint() for "mp-affinity" property
auxbus: use get_uint() for "addr" property
pvpanic: use get_uint() for "ioport" property
pnv-core: use get_uint() for "core-pir" property
numa: use get_uint() for "size" property
i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties
console: use get_uint() for "head" property
tests/qdict: check more get_try_int() cases
RFC: qdict: add uint
qobject: move dump_qobject() from block/ to qobject/
include/qapi/visitor.h | 4 +-
include/qapi/visitor-impl.h | 2 +-
scripts/qapi.py | 36 +++--
scripts/qapi-visit.py | 12 +-
include/hw/isa/isa.h | 2 +-
include/hw/qdev-core.h | 7 +-
include/hw/qdev-properties.h | 50 ++++---
include/qapi/qmp/qdict.h | 10 +-
include/qapi/qmp/qfloat.h | 29 ----
include/qapi/qmp/qint.h | 28 ----
include/qapi/qmp/qlist.h | 5 +-
include/qapi/qmp/qnum.h | 53 ++++++++
include/qapi/qmp/qobject.h | 7 +
include/qapi/qmp/types.h | 3 +-
include/qapi/qobject-input-visitor.h | 6 +-
include/qapi/qobject-output-visitor.h | 8 +-
include/qom/object.h | 23 ++++
qapi/qapi-visit-core.c | 6 +-
backends/cryptodev.c | 2 +-
block/blkdebug.c | 1 -
block/nbd.c | 1 -
block/nfs.c | 1 -
block/qapi.c | 93 +------------
block/quorum.c | 1 -
block/sheepdog.c | 1 -
block/ssh.c | 1 -
block/vvfat.c | 1 -
blockdev.c | 8 +-
hw/acpi/memory_hotplug.c | 12 +-
hw/acpi/nvdimm.c | 18 +--
hw/acpi/pcihp.c | 7 +-
hw/arm/aspeed.c | 8 +-
hw/arm/bcm2835_peripherals.c | 9 +-
hw/arm/raspi.c | 4 +-
hw/block/fdc.c | 18 +--
hw/core/platform-bus.c | 2 +-
hw/core/qdev-properties.c | 40 +++++-
hw/core/qdev.c | 13 +-
hw/i386/acpi-build.c | 71 +++++-----
hw/i386/pc.c | 6 +-
hw/i386/xen/xen-hvm.c | 6 +-
hw/intc/apic_common.c | 10 +-
hw/intc/arm_gicv3_common.c | 2 +-
hw/mem/pc-dimm.c | 23 ++--
hw/misc/auxbus.c | 2 +-
hw/misc/pvpanic.c | 2 +-
hw/net/e1000e.c | 6 +-
hw/pci-host/gpex.c | 2 +-
hw/pci-host/piix.c | 8 +-
hw/pci-host/q35.c | 15 +--
hw/pci-host/xilinx-pcie.c | 2 +-
hw/ppc/pnv.c | 2 +-
hw/ppc/pnv_core.c | 2 +-
hw/ppc/spapr.c | 7 +-
hw/usb/xen-usb.c | 1 -
monitor.c | 2 +-
net/dump.c | 2 +-
net/filter-buffer.c | 2 +-
numa.c | 6 +-
qapi/qapi-clone-visitor.c | 2 +-
qapi/qapi-dealloc-visitor.c | 2 +-
qapi/qobject-input-visitor.c | 58 ++++----
qapi/qobject-output-visitor.c | 7 +-
qga/commands.c | 2 +-
qga/main.c | 1 -
qobject/json-lexer.c | 4 +
qobject/json-parser.c | 56 +++++---
qobject/qdict.c | 100 +++++++++++---
qobject/qfloat.c | 62 ---------
qobject/qint.c | 61 ---------
qobject/qjson.c | 37 +-----
qobject/qlist.c | 23 ++++
qobject/qnum.c | 221 +++++++++++++++++++++++++++++++
qobject/qobject.c | 22 ++-
qom/object.c | 51 +++++--
target/i386/cpu.c | 10 +-
tests/check-qdict.c | 80 ++++++++---
tests/check-qfloat.c | 53 --------
tests/check-qint.c | 87 ------------
tests/check-qjson.c | 154 +++++++++++++++------
tests/check-qlist.c | 40 ++----
tests/check-qnum.c | 170 ++++++++++++++++++++++++
tests/check-qstring.c | 9 --
tests/test-keyval.c | 4 +-
tests/test-qmp-commands.c | 8 +-
tests/test-qmp-event.c | 9 +-
tests/test-qobject-input-visitor.c | 110 ++++++++-------
tests/test-qobject-output-visitor.c | 91 ++++++++-----
tests/test-x86-cpuid-compat.c | 18 ++-
ui/console.c | 4 +-
ui/spice-core.c | 1 -
ui/vnc-enc-tight.c | 1 -
util/qemu-option.c | 24 ++--
MAINTAINERS | 3 +-
qapi/trace-events | 2 +-
qobject/Makefile.objs | 2 +-
scripts/coccinelle/qobject.cocci | 4 +-
tests/.gitignore | 3 +-
tests/Makefile.include | 13 +-
tests/qapi-schema/comments.out | 2 +-
tests/qapi-schema/doc-good.out | 2 +-
tests/qapi-schema/empty.out | 2 +-
tests/qapi-schema/event-case.out | 2 +-
tests/qapi-schema/ident-with-escape.out | 2 +-
tests/qapi-schema/include-relpath.out | 2 +-
tests/qapi-schema/include-repetition.out | 2 +-
tests/qapi-schema/include-simple.out | 2 +-
tests/qapi-schema/indented-expr.out | 2 +-
tests/qapi-schema/qapi-schema-test.json | 2 -
tests/qapi-schema/qapi-schema-test.out | 10 +-
110 files changed, 1331 insertions(+), 1019 deletions(-)
delete mode 100644 include/qapi/qmp/qfloat.h
delete mode 100644 include/qapi/qmp/qint.h
create mode 100644 include/qapi/qmp/qnum.h
delete mode 100644 qobject/qfloat.c
delete mode 100644 qobject/qint.c
create mode 100644 qobject/qnum.c
delete mode 100644 tests/check-qfloat.c
delete mode 100644 tests/check-qint.c
create mode 100644 tests/check-qnum.c
--
2.13.0.91.g00982b8dd
^ permalink raw reply [flat|nested] 70+ messages in thread
end of thread, other threads:[~2017-06-09 14:34 UTC | newest]
Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-07 16:35 [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 01/43] qdev: remove PropertyInfo.qtype field Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 02/43] object: fix potential leak in getters Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 03/43] tests: Remove test cases for alternates of 'number' and 'int' Marc-André Lureau
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 04/43] tests: add more int/number ranges checks Marc-André Lureau
2017-06-08 14:55 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 05/43] qapi: minor refactoring Marc-André Lureau
2017-06-08 14:57 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 06/43] qapi: merge QInt and QFloat in QNum Marc-André Lureau
2017-06-08 15:54 ` Markus Armbruster
2017-06-07 16:35 ` [Qemu-devel] [PATCH v3 07/43] qapi: Remove visit_start_alternate() parameter promote_int Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 08/43] tests: remove /{qnum, qlist, dict}/destroy test Marc-André Lureau
2017-06-08 15:00 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 09/43] qnum: add uint type Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 10/43] json: learn to parse uint64 numbers Marc-André Lureau
2017-06-08 16:27 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 11/43] qapi: update the qobject visitor to use QNUM_U64 Marc-André Lureau
2017-06-08 16:36 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 12/43] object: add uint property setter/getter Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 13/43] q35: fix get_mmcfg_size to use uint64 visitor Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 14/43] object: use more specific property type names Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 15/43] qdev: rename DEFINE_PROP_DEFAULT() to DEFINE_PROP_SIGNED() Marc-André Lureau
2017-06-08 16:42 ` Markus Armbruster
2017-06-08 17:01 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 16/43] qdev: wrap default property value in an union Marc-André Lureau
2017-06-08 17:01 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 17/43] qdev: avoid type casts between signed and unsigned Marc-André Lureau
2017-06-08 17:08 ` Markus Armbruster
2017-06-09 10:04 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 18/43] apic-common: make "id" property a uint32 Marc-André Lureau
2017-06-08 16:39 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 19/43] qdev: use appropriate getter/setters type Marc-André Lureau
2017-06-08 17:23 ` Markus Armbruster
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 20/43] isa: use get_uint() for "io-base" Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 21/43] pc-dimm: use get_uint() for dimm properties Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 22/43] pc-dimm: make "size" property uint64 Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 23/43] pcihp: use get_uint() for "bsel" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 24/43] aspeed: use {set, get}_uint() for "ram-size" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 25/43] bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base" Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 26/43] platform-bus: use get_uint() for "addr" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 27/43] acpi: use get_uint() for "acpi-pcihp-io*" properties Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 28/43] acpi: use get_uint() for various acpi properties Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 29/43] acpi: use get_uint() for "pci-hole*" properties Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 30/43] pc: use get_uint() for "iobase" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 31/43] pc: use get_uint() for "apic-id" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 32/43] pc: use get_uint() for "hpet-intcap" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 33/43] xen: use get_uint() for "max-ram-below-4g" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 34/43] arm: use get_uint() for "mp-affinity" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 35/43] auxbus: use get_uint() for "addr" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 36/43] pvpanic: use get_uint() for "ioport" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 37/43] pnv-core: use get_uint() for "core-pir" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 38/43] numa: use get_uint() for "size" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 39/43] i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 40/43] console: use get_uint() for "head" property Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 41/43] tests/qdict: check more get_try_int() cases Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 42/43] RFC: qdict: add uint Marc-André Lureau
2017-06-08 17:25 ` Markus Armbruster
2017-06-09 10:05 ` Marc-André Lureau
2017-06-07 16:36 ` [Qemu-devel] [PATCH v3 43/43] qobject: move dump_qobject() from block/ to qobject/ Marc-André Lureau
2017-06-08 17:43 ` Markus Armbruster
2017-06-09 10:11 ` Marc-André Lureau
2017-06-09 10:15 ` Marc-André Lureau
2017-06-09 12:40 ` Markus Armbruster
2017-06-09 12:46 ` Eric Blake
2017-06-09 14:34 ` Max Reitz
2017-06-07 20:41 ` [Qemu-devel] [PATCH v3 00/43] qobject/qapi: add uint type no-reply
2017-06-08 1:47 ` no-reply
2017-06-09 12:32 ` Markus Armbruster
2017-06-09 13:06 ` Marc-André Lureau
-- strict thread matches above, loose matches on Subject: below --
2017-06-07 16:30 Marc-André Lureau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.