Skip to contentSkip to conversation

WIP: dump: add kaslr support (for after 2.9)

PATCH In review Marc-André Lureau 10 participants 41 messages Mar 11, 2017 – Apr 23, 2017 1 message not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover WIP: dump: add kaslr support (for after 2.9)

Hi,

Latest linux kernel enabled kaslr to randomize phys/virt memory addresses. There has been some effort to support kexec/kdump so that crash utility can still works in case crashed kernel has kaslr enabled.

This series aims to provide enough information in qemu dumps so that crash utility can work with kaslr kernel too, with x86_64 guests (it hasn't been tested on other archs, help welcome).

Two pieces of informations are necessary: the phys_base (the physical address where the kernel is loaded) and the kaslr offset. Other useful informations for debugging are provided in Linux vmcoreinfo too.

There has been discussions to provide those details in early boot, with ACPI, fw_cfg, virtio-pstore etc, but none has reached a consensus yet. A possiblity for now is to provide the information when qemu-ga starts. This has the advantage of working with older guests and may not be incompatible with future methods (in this case it could ignore qga info for example). The drawback is that qemu will have to parse the json stream. For now it stops processing it whem VMDUMP_INFO is received. It would be wise to introduce a QMP welcome message, so that qemu would stop immediately processing the stream if the agent doesn't have the event. Another option is to create a seperate channel... I welcome other ideas and discussion.

crash upstream doesn't yet parse NUMBER(phys_base). You may pass it to crash with --machdep phys_base=0x.. provided you snooped on qga.

kdump kaslr-dumps should now work with crash out of the box.

A large part of the series has to do with json and the qobject type system to deal with uint64 values, so that addresses can now be sent over json. The second halfs adds qga VMDUMP_INFO event, and ELF/kdump dumping. Depending on the feedback, I will probably split the series, but for those who would like to try it, help or suggest ideas, here is the whole thing.

cheers

Marc-André Lureau (21):
qapi: add info comment for generated types
pci-host: use more specific type names
object: fix potential leak in getters
qobject: add quint type
qapi: update the qobject visitor to use QUInt
json: learn to parse uint64 numbers
object: add uint property setter/getter
qdev: use int and uint properties
qdev: use appropriate type
Use uint property getter/setter where appropriate
qdict: learn to lookup quint
test-qga: drop everything until guest-sync
qga: report error on keyfile dump error
qga: add and populate VMDumpInfo
qga: register event emit function
qga: emit VMDUMP_INFO event
virtio-channel: parse qga stream for VMDUMP_INFO event
dump: use qga VMDUMP_INFO for ELF dump
kdump: write vmcoreinfo in header scripts/dump-guest-memory.py: fix int128_get64 on recent gcc scripts/dump-guest-memory.py: add VMCOREINFO

 qapi/introspect.json                     |   2 +-
 scripts/qapi.py                          |  39 ++++---
 scripts/dump-guest-memory.py             |  66 ++++++++++-
 scripts/qapi-event.py                    |   4 +-
 scripts/qapi-types.py                    |  17 +--
 scripts/qapi-visit.py                    |   3 +-
 include/hw/isa/isa.h                     |   2 +-
 include/hw/qdev-core.h                   |   5 +-
 include/hw/qdev-properties.h             |  59 ++++++----
 include/qapi/qmp/qdict.h                 |   2 +
 include/qapi/qmp/quint.h                 |  25 +++++
 include/qapi/qmp/types.h                 |   1 +
 include/qom/object.h                     |  23 ++++
 include/sysemu/dump-info.h               |  15 +++
 include/sysemu/dump.h                    |   2 +
 qga/guest-agent-core.h                   |   2 +
 block/qapi.c                             |   5 +
 dump.c                                   | 184 ++++++++++++++++++++++++++++++-
 hw/acpi/memory_hotplug.c                 |  10 +-
 hw/acpi/nvdimm.c                         |  10 +-
 hw/acpi/pcihp.c                          |   6 +-
 hw/arm/aspeed.c                          |   4 +-
 hw/arm/bcm2835_peripherals.c             |   9 +-
 hw/arm/raspi.c                           |   4 +-
 hw/block/fdc.c                           |  54 ++++-----
 hw/char/virtio-console.c                 |  53 +++++++++
 hw/core/platform-bus.c                   |   2 +-
 hw/core/qdev-properties.c                |   8 +-
 hw/core/qdev.c                           |   8 +-
 hw/i386/acpi-build.c                     |  70 ++++++------
 hw/i386/pc.c                             |   6 +-
 hw/intc/arm_gicv3_common.c               |   2 +-
 hw/mem/pc-dimm.c                         |   5 +-
 hw/misc/auxbus.c                         |   2 +-
 hw/misc/pvpanic.c                        |   2 +-
 hw/net/e1000e.c                          |  14 +--
 hw/pci-host/gpex.c                       |   2 +-
 hw/pci-host/piix.c                       |   8 +-
 hw/pci-host/q35.c                        |  12 +-
 hw/pci-host/xilinx-pcie.c                |   2 +-
 hw/ppc/pnv_core.c                        |   2 +-
 hw/ppc/spapr.c                           |   8 +-
 numa.c                                   |   6 +-
 qapi/qobject-input-visitor.c             |  30 ++++-
 qapi/qobject-output-visitor.c            |   3 +-
 qga/channel-posix.c                      |  11 ++
 qga/main.c                               | 162 ++++++++++++++++++++++++++-
 qobject/json-lexer.c                     |   4 +
 qobject/json-parser.c                    |  19 +++-
 qobject/qdict.c                          |  37 ++++++-
 qobject/qjson.c                          |   8 ++
 qobject/qobject.c                        |   1 +
 qobject/quint.c                          |  58 ++++++++++
 qom/object.c                             |  38 ++++++-
 target/i386/cpu.c                        |   6 +-
 tests/check-qdict.c                      |  31 ++++++
 tests/check-qint.c                       |  59 ++++++++++
 tests/check-qjson.c                      |  28 +++++
 tests/test-qga.c                         |  27 +++--
 tests/test-qobject-input-visitor.c       |  15 +++
 tests/test-qobject-output-visitor.c      |  19 +++-
 ui/console.c                             |   4 +-
 util/qemu-option.c                       |   6 +
 xen-hvm.c                                |   6 +-
 Makefile                                 |   7 +-
 qga/Makefile.objs                        |   1 +
 qga/qapi-schema.json                     |  15 +++
 qobject/Makefile.objs                    |   2 +-
 tests/qapi-schema/comments.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 +-
 77 files changed, 1153 insertions(+), 227 deletions(-)
 create mode 100644 include/qapi/qmp/quint.h
 create mode 100644 include/sysemu/dump-info.h
 create mode 100644 qobject/quint.c
Signature · 1 line
2.12.0.191.gc5d8de91d
#1 lore raw

PATCH 1/21 qapi: add info comment for generated types

This may help to find where the origin of the type was declared in the json (when greping isn't easy enough).

---
 scripts/qapi.py       | 11 +++++++++--
 scripts/qapi-event.py |  4 +++-
 scripts/qapi-types.py | 17 +++++++++--------
 3 files changed, 21 insertions(+), 11 deletions(-)
scripts/qapi.py +9 -2
index 53a44779d0..9504ebd8c7 100644
@@ -1874,15 +1874,22 @@ const char *const %(c_name)s_lookup[] = {
     return ret
 
 
-def gen_enum(name, values, prefix=None):
+def gen_info_comment(info):
+    if info:
+        return "/* %s:%d */" % (info['file'], info['line'])
+    else:
+        return ""
+
+def gen_enum(info, name, values, prefix=None):
     # append automatically generated _MAX value
     enum_values = values + ['_MAX']
 
     ret = mcgen('''
 
+%(info)s
 typedef enum %(c_name)s {
 ''',
-                c_name=c_name(name))
+                c_name=c_name(name), info=gen_info_comment(info))
 
     i = 0
     for value in enum_values:
scripts/qapi-event.py +3 -1
index f4eb7f85b1..ca90d6a5df 100644
@@ -152,6 +152,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self.decl = None
         self.defn = None
         self._event_names = None
+        self.info = None
 
     def visit_begin(self, schema):
         self.decl = ''
@@ -159,7 +160,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self._event_names = []
 
     def visit_end(self):
-        self.decl += gen_enum(event_enum_name, self._event_names)
+        self.decl += gen_enum(self.info, event_enum_name, self._event_names)
         self.defn += gen_enum_lookup(event_enum_name, self._event_names)
         self._event_names = None
 
@@ -167,6 +168,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self.decl += gen_event_send_decl(name, arg_type, boxed)
         self.defn += gen_event_send(name, arg_type, boxed)
         self._event_names.append(name)
+        self.info = info
 
 
 (input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
scripts/qapi-types.py +9 -8
index dabc42e047..896749bf61 100644
@@ -19,12 +19,13 @@ from qapi import *
 objects_seen = set()
 
 
-def gen_fwd_object_or_array(name):
+def gen_fwd_object_or_array(info, name):
     return mcgen('''
 
+%(info)s
 typedef struct %(c_name)s %(c_name)s;
 ''',
-                 c_name=c_name(name))
+                 c_name=c_name(name), info=gen_info_comment(info))
 
 
 def gen_array(name, element_type):
@@ -199,22 +200,22 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         # Special case for our lone builtin enum type
         # TODO use something cleaner than existence of info
         if not info:
-            self._btin += gen_enum(name, values, prefix)
+            self._btin += gen_enum(info, name, values, prefix)
             if do_builtins:
                 self.defn += gen_enum_lookup(name, values, prefix)
         else:
-            self._fwdecl += gen_enum(name, values, prefix)
+            self._fwdecl += gen_enum(info, name, values, prefix)
             self.defn += gen_enum_lookup(name, values, prefix)
 
     def visit_array_type(self, name, info, element_type):
         if isinstance(element_type, QAPISchemaBuiltinType):
-            self._btin += gen_fwd_object_or_array(name)
+            self._btin += gen_fwd_object_or_array(info, name)
             self._btin += gen_array(name, element_type)
             self._btin += gen_type_cleanup_decl(name)
             if do_builtins:
                 self.defn += gen_type_cleanup(name)
         else:
-            self._fwdecl += gen_fwd_object_or_array(name)
+            self._fwdecl += gen_fwd_object_or_array(info, name)
             self.decl += gen_array(name, element_type)
             self._gen_type_cleanup(name)
 
@@ -222,7 +223,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         # Nothing to do for the special empty builtin
         if name == 'q_empty':
             return
-        self._fwdecl += gen_fwd_object_or_array(name)
+        self._fwdecl += gen_fwd_object_or_array(info, name)
         self.decl += gen_object(name, base, members, variants)
         if base and not base.is_implicit():
             self.decl += gen_upcast(name, base)
@@ -233,7 +234,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
             self._gen_type_cleanup(name)
 
     def visit_alternate_type(self, name, info, variants):
-        self._fwdecl += gen_fwd_object_or_array(name)
+        self._fwdecl += gen_fwd_object_or_array(info, name)
         self.decl += gen_object(name, None, [variants.tag_member], variants)
         self._gen_type_cleanup(name)
 
Signature · 1 line
2.12.0.191.gc5d8de91d
#2 lore raw

Re: [Qemu-devel] [PATCH 01/21] qapi: add info comment for generated types

Re qemu-trivial: since I got another lengthy series touching scripts/qapi* in the pipeline, I'd prefer to handle the conflicts in my tree.

Quoted 2 lines · Marc-André Lureau

This may help to find where the origin of the type was declared in the json (when greping isn't easy enough).

An example for the generated comment would be nice here.

Quoted 13 lines
---
 scripts/qapi.py       | 11 +++++++++--
 scripts/qapi-event.py |  4 +++-
 scripts/qapi-types.py | 17 +++++++++--------
 3 files changed, 21 insertions(+), 11 deletions(-)
scripts/qapi.py +0 -0
index 53a44779d0..9504ebd8c7 100644

scripts/qapi.py const char *const %(c_name)s_lookup[] = { · line 1877

Quoted 5 lines
scripts/qapi.py +1 -1
@@ -1874,15 +1874,22 @@ const char *const %(c_name)s_lookup[] = {
     return ret
 
 
-def gen_enum(name, values, prefix=None):
+def gen_info_comment(info):

Well, aren't all comments "info comments"? What distinguishes this one is that it's about the location of the source. Suggest to rename to gen_loc_comment() or maybe gen_src_loc_comment().

Hmm, the gen_ prefix is awkward. Generated C should go through cgen() exactly once (see commit 1f9a7a1). The common way to get this wrong is passing a foo=gen_foo() keyword argument to mcgen(). I'd like us to adopt a naming convention where gen_ means "something that's been piped through cgen(), and thus must not be passed to cgen() or mcgen()". Requires renaming gen_params(), gen_marshal_proto() and gen_event_send_proto().

scripts/qapi.py const char *const %(c_name)s_lookup[] = { · line 1881

Quoted 4 lines
scripts/qapi.py +4 -0
+    if info:
+        return "/* %s:%d */" % (info['file'], info['line'])
+    else:
+        return ""

Please stick to the prevalent use of single vs. double quotes: use single quotes unless double quotes let you avoid backslashes, except always use double quotes for error messages. See "[PATCH for-2.9 19/47]
qapi: Prefer single-quoted strings more consistently".

scripts/qapi.py const char *const %(c_name)s_lookup[] = { · line 1892

Quoted 12 lines
scripts/qapi.py +4 -1
+
+def gen_enum(info, name, values, prefix=None):
     # append automatically generated _MAX value
     enum_values = values + ['_MAX']
 
     ret = mcgen('''
 
+%(info)s
 typedef enum %(c_name)s {
 ''',
-                c_name=c_name(name))
+                c_name=c_name(name), info=gen_info_comment(info))

Your chance to use identifier infocom ;-P

Seriously, I'd prefer comment to info.

Quoted 25 lines
scripts/qapi.py +0 -0
     i = 0
     for value in enum_values:
scripts/qapi-event.py +2 -1
index f4eb7f85b1..ca90d6a5df 100644
@@ -152,6 +152,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self.decl = None
         self.defn = None
         self._event_names = None
+        self.info = None
 
     def visit_begin(self, schema):
         self.decl = ''
@@ -159,7 +160,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self._event_names = []
 
     def visit_end(self):
-        self.decl += gen_enum(event_enum_name, self._event_names)
+        self.decl += gen_enum(self.info, event_enum_name, self._event_names)
         self.defn += gen_enum_lookup(event_enum_name, self._event_names)
         self._event_names = None
 

scripts/qapi-event.py class QAPISchemaGenEventVisitor(QAPISchemaVisitor): · line 173

Quoted 6 lines
scripts/qapi-event.py +1 -0
@@ -167,6 +168,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self.decl += gen_event_send_decl(name, arg_type, boxed)
         self.defn += gen_event_send(name, arg_type, boxed)
         self._event_names.append(name)
+        self.info = info
 
 

I'm afraid this doesn't make sense.

You set self.info in each visit_event(), then use it in visit_end(). visit_end() thus sees the info of whatever event was visited last. Won't produce a sane location comment. None of the others would, either. That's because the enumeration is defined implicitly by all the events together.

Let's pass info=None for this enum.

Quoted 6 lines
scripts/qapi-event.py +0 -0
 (input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
scripts/qapi-types.py +0 -0
index dabc42e047..896749bf61 100644

scripts/qapi-types.py from qapi import * · line 26

Quoted 9 lines
scripts/qapi-types.py +2 -1
@@ -19,12 +19,13 @@ from qapi import *
 objects_seen = set()
 
 
-def gen_fwd_object_or_array(name):
+def gen_fwd_object_or_array(info, name):
     return mcgen('''
 
+%(info)s
 typedef struct %(c_name)s %(c_name)s;

If info=None, gen_info_comment(info) is '', and we get an unwanted blank line.

scripts/qapi-types.py class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): · line 203

Quoted 12 lines
scripts/qapi-types.py +2 -2
 ''',
-                 c_name=c_name(name))
+                 c_name=c_name(name), info=gen_info_comment(info))
 
 
 def gen_array(name, element_type):
@@ -199,22 +200,22 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         # Special case for our lone builtin enum type
         # TODO use something cleaner than existence of info
         if not info:
-            self._btin += gen_enum(name, values, prefix)
+            self._btin += gen_enum(info, name, values, prefix)

gen_enum(None, ...) feels slightly clearer to me.

Quoted 11 lines
scripts/qapi-types.py +2 -2
             if do_builtins:
                 self.defn += gen_enum_lookup(name, values, prefix)
         else:
-            self._fwdecl += gen_enum(name, values, prefix)
+            self._fwdecl += gen_enum(info, name, values, prefix)
             self.defn += gen_enum_lookup(name, values, prefix)
 
     def visit_array_type(self, name, info, element_type):
         if isinstance(element_type, QAPISchemaBuiltinType):
-            self._btin += gen_fwd_object_or_array(name)
+            self._btin += gen_fwd_object_or_array(info, name)

scripts/qapi-types.py class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): · line 221

Quoted 10 lines
scripts/qapi-types.py +1 -1
             self._btin += gen_array(name, element_type)
             self._btin += gen_type_cleanup_decl(name)
             if do_builtins:
                 self.defn += gen_type_cleanup(name)
         else:
-            self._fwdecl += gen_fwd_object_or_array(name)
+            self._fwdecl += gen_fwd_object_or_array(info, name)
             self.decl += gen_array(name, element_type)
             self._gen_type_cleanup(name)
 

Note that @info points to an arbitrarily chosen user of the array type, *not* to the definition of the element type. The resulting source location comment feels useless to me. Suggest to pass None for arrays.

Quoted 17 lines
scripts/qapi-types.py +2 -2
@@ -222,7 +223,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         # Nothing to do for the special empty builtin
         if name == 'q_empty':
             return
-        self._fwdecl += gen_fwd_object_or_array(name)
+        self._fwdecl += gen_fwd_object_or_array(info, name)
         self.decl += gen_object(name, base, members, variants)
         if base and not base.is_implicit():
             self.decl += gen_upcast(name, base)
@@ -233,7 +234,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
             self._gen_type_cleanup(name)
 
     def visit_alternate_type(self, name, info, variants):
-        self._fwdecl += gen_fwd_object_or_array(name)
+        self._fwdecl += gen_fwd_object_or_array(info, name)
         self.decl += gen_object(name, None, [variants.tag_member], variants)
         self._gen_type_cleanup(name)
#3 lore raw

PATCH 2/21 pci-host: use more specific type names

In reply to Marc-André Lureau

Use the actual unsigned integer type name (this should't break since property type aren't directly accessed from outside).

---
 hw/pci-host/piix.c |  8 ++++----
 hw/pci-host/q35.c  | 10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)
hw/pci-host/piix.c +4 -4
index f9218aa952..9aed6225bf 100644
@@ -279,19 +279,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);
 }
hw/pci-host/q35.c +5 -5
index 344f77b10c..5438be8253 100644
@@ -176,23 +176,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, "uint32",
                         q35_host_get_mmcfg_size,
                         NULL, NULL, NULL, NULL);
 
Signature · 1 line
2.12.0.191.gc5d8de91d
#4 lore raw

PATCH 3/21 object: fix potential leak in getters

In reply to Marc-André Lureau

If the property is not of the requested type, the getters will leak a QObject.

---
 qom/object.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qom/object.c +3 -3
index eb4bc924ff..c7b8079df6 100644
@@ -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;
 }
 
Signature · 1 line
2.12.0.191.gc5d8de91d
Reviewed-by on v1 3/21
#5 lore raw

Re: [Qemu-devel] [PATCH 03/21] object: fix potential leak in getters

Quoted 8 lines · Marc-André Lureau

If the property is not of the requested type, the getters will leak a QObject.

---
 qom/object.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

This one should be safe for 2.9.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

Re: [Qemu-devel] [PATCH 03/21] object: fix potential leak in getters

In reply to Marc-André Lureau
Quoted 2 lines · Marc-André Lureau

If the property is not of the requested type, the getters will leak a QObject.

I'm not really sure it's -trivial material.

Not applying 01/23 either.

Should whole series be applied to the same tree perhaps?

Thanks,

/mjt

#7 lore raw

PATCH 4/21 qobject: add quint type

In reply to Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

---
 qapi/introspect.json                     |  2 +-
 scripts/qapi.py                          | 28 ++++++++-------
 include/qapi/qmp/quint.h                 | 25 ++++++++++++++
 include/qapi/qmp/types.h                 |  1 +
 block/qapi.c                             |  5 +++
 qobject/qobject.c                        |  1 +
 qobject/quint.c                          | 58 +++++++++++++++++++++++++++++++
 tests/check-qint.c                       | 59 ++++++++++++++++++++++++++++++++
 qobject/Makefile.objs                    |  2 +-
 tests/qapi-schema/comments.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 +-
 18 files changed, 175 insertions(+), 24 deletions(-)
 create mode 100644 include/qapi/qmp/quint.h
 create mode 100644 qobject/quint.c
qapi/introspect.json +1 -1
index f6adc439bb..512a961ab3 100644
@@ -125,7 +125,7 @@
 # Since: 2.5
 ##
 { 'enum': 'JSONType',
-  'data': [ 'string', 'number', 'int', 'boolean', 'null',
+  'data': [ 'string', 'number', 'int', 'uint', 'boolean', 'null',
             'object', 'array', 'value' ] }
 
 ##
scripts/qapi.py +15 -13
index 9504ebd8c7..80ecc821cb 100644
@@ -28,11 +28,11 @@ builtin_types = {
     'int16':    'QTYPE_QINT',
     'int32':    'QTYPE_QINT',
     'int64':    'QTYPE_QINT',
-    'uint8':    'QTYPE_QINT',
-    'uint16':   'QTYPE_QINT',
-    'uint32':   'QTYPE_QINT',
-    'uint64':   'QTYPE_QINT',
-    'size':     'QTYPE_QINT',
+    'uint8':    'QTYPE_QUINT',
+    'uint16':   'QTYPE_QUINT',
+    'uint32':   'QTYPE_QUINT',
+    'uint64':   'QTYPE_QUINT',
+    'size':     'QTYPE_QUINT',
     'any':      None,           # any QType possible, actually
     'QType':    'QTYPE_QSTRING',
 }
@@ -1093,6 +1093,7 @@ class QAPISchemaType(QAPISchemaEntity):
             'string':  'QTYPE_QSTRING',
             'number':  'QTYPE_QFLOAT',
             'int':     'QTYPE_QINT',
+            'uint':    'QTYPE_QUINT',
             'boolean': 'QTYPE_QBOOL',
             'object':  'QTYPE_QDICT'
         }
@@ -1103,8 +1104,8 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
         QAPISchemaType.__init__(self, name, None)
         assert not c_type or isinstance(c_type, str)
-        assert json_type in ('string', 'number', 'int', 'boolean', 'null',
-                             'value')
+        assert json_type in ('string', 'number', 'int', 'uint',
+                             'boolean', 'null', 'value')
         self._json_type_name = json_type
         self._c_type_name = c_type
 
@@ -1519,18 +1520,19 @@ class QAPISchema(object):
                   ('int16',  'int',     'int16_t'),
                   ('int32',  'int',     'int32_t'),
                   ('int64',  'int',     'int64_t'),
-                  ('uint8',  'int',     'uint8_t'),
-                  ('uint16', 'int',     'uint16_t'),
-                  ('uint32', 'int',     'uint32_t'),
-                  ('uint64', 'int',     'uint64_t'),
-                  ('size',   'int',     'uint64_t'),
+                  ('uint8',  'uint',    'uint8_t'),
+                  ('uint16', 'uint',    'uint16_t'),
+                  ('uint32', 'uint',    'uint32_t'),
+                  ('uint64', 'uint',    'uint64_t'),
+                  ('size',   'uint',    'uint64_t'),
                   ('bool',   'boolean', 'bool'),
                   ('any',    'value',   'QObject' + pointer_suffix)]:
             self._def_builtin_type(*t)
         self.the_empty_object_type = QAPISchemaObjectType('q_empty', 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',
+                                                'qint', 'quint',
                                                 'qstring', 'qdict', 'qlist',
                                                 'qfloat', 'qbool'])
         self._def_entity(QAPISchemaEnumType('QType', None, qtype_values,
include/qapi/qmp/quint.h new file +25 -0
new file mode 100644
index 0000000000..5b920ece5d
@@ -0,0 +1,25 @@
+/*
+ * QUInt Module
+ *
+ * Copyright (C) 2017 Red Hat Inc.
+ *
+ * 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 QUINT_H
+#define QUINT_H
+
+#include "qapi/qmp/qobject.h"
+
+typedef struct QUInt {
+    QObject base;
+    uint64_t value;
+} QUInt;
+
+QUInt *quint_from_uint(uint64_t value);
+uint64_t quint_get_uint(const QUInt *qi);
+QUInt *qobject_to_quint(const QObject *obj);
+void quint_destroy_obj(QObject *obj);
+
+#endif /* QUINT_H */
include/qapi/qmp/types.h +1 -0
index 27cfbd84e5..99a60f75d0 100644
@@ -15,6 +15,7 @@
 
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/quint.h"
 #include "qapi/qmp/qfloat.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qstring.h"
block/qapi.c +5 -0
index a40922ea26..6261a49b4d 100644
@@ -600,6 +600,11 @@ static void dump_qobject(fprintf_function func_fprintf, void *f,
             func_fprintf(f, "%" PRId64, qint_get_int(value));
             break;
         }
+        case QTYPE_QUINT: {
+            QUInt *value = qobject_to_quint(obj);
+            func_fprintf(f, "%" PRIu64, quint_get_uint(value));
+            break;
+        }
         case QTYPE_QSTRING: {
             QString *value = qobject_to_qstring(obj);
             func_fprintf(f, "%s", qstring_get_str(value));
qobject/qobject.c +1 -0
index fe4fa10989..9bdb5e5947 100644
@@ -15,6 +15,7 @@ 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_QUINT] = quint_destroy_obj,
     [QTYPE_QSTRING] = qstring_destroy_obj,
     [QTYPE_QDICT] = qdict_destroy_obj,
     [QTYPE_QLIST] = qlist_destroy_obj,
qobject/quint.c new file +58 -0

58 lines not on this page · raw message

tests/check-qint.c +59 -0

76 lines not on this page · raw message

qobject/Makefile.objs +1 -1
index bed55084bb..1f7b95552f 100644
@@ -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 qint.o quint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
 util-obj-y += qjson.o qobject.o json-lexer.o json-streamer.o json-parser.o
tests/qapi-schema/comments.out +1 -1
index a962fb2d2e..42ea87a1a1 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
tests/qapi-schema/empty.out +1 -1
index 8a5b034424..5dcccb1d55 100644
@@ -1,3 +1,3 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 object q_empty
tests/qapi-schema/event-case.out +1 -1
index 2865714ad5..3464bd30f6 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 event oops None
    boxed=False
tests/qapi-schema/ident-with-escape.out +1 -1
index 69fc908e68..a81ef8cd34 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 command fooA q_obj_fooA-arg -> None
    gen=True success_response=True boxed=False
tests/qapi-schema/include-relpath.out +1 -1
index a962fb2d2e..42ea87a1a1 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
tests/qapi-schema/include-repetition.out +1 -1
index a962fb2d2e..42ea87a1a1 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
tests/qapi-schema/include-simple.out +1 -1
index a962fb2d2e..42ea87a1a1 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
tests/qapi-schema/indented-expr.out +1 -1
index 285d052257..b158bcd6eb 100644
@@ -1,4 +1,4 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+enum QType ['none', 'qnull', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 command eins None -> None
    gen=True success_response=True boxed=False
tests/qapi-schema/qapi-schema-test.out +1 -1
index bc8d496ff4..690460658c 100644
@@ -54,7 +54,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', 'qint', 'quint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
     prefix QTYPE
 object TestStruct
     member integer: int optional=False
Signature · 1 line
2.12.0.191.gc5d8de91d
#8 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

If the user passes in a value in the range [0, INT64_MAX], the number is representable in both uint64_t and int64_t. So the internal sign bit would be omitted, as in { value=v, sign=false }. Input visitors can visit this value with both the 'uint64' and the 'int64' visitors, and output visitors will output the same value.

If the user passes in a value in the range [-INT64_MAX-1, -1], the number is intended to be used as a negative signed number. So the QInt representation would be the 2s complement representation, { value=-v, sign=true }. On input, the uint64_t visitor would reject the value as out of range, the int64_t visitor would return the appropriate negative value, and the generic int visitor will return the uint64_t value. On output, the number would be given the negative signed value representation in anything that stringizes the value.

If the user passes in a value in the range [INT64_MAX+1, UINT64_MAX}, the number is intended to be used as a large unsigned number. So the QInt representation would be { value=v, sign=false }. On input, the uint64_t visitor would accept the value, the int64_t visitor would reject it as out of range, and the generic int visitor will return the uint64_t value. On output, the number would be given the positive unsigned value representation in the stringized form.

That way, you don't have to complicate the (already-awkward) type promotion rules of QFloat vs QInt with yet another scalar type. The input parser becomes friendlier - you can either use generic 'int' when you want to allow the user to pass in either signed or unsigned values (important for back-compat, where callers like libvirt learned that only signed values worked even when large unsigned values were wanted); or the specific 'int64' and 'uint64' types to force proper ranges.

It's definitely an alternative implementation to the one you pursued in your series, so maybe we should first figure out WHAT we want represented, before implementing something that will be more baggage than we want (you at least have the advantage of patches that are written; my idea of adding a sign bool to QInt is still just in the initial idea stage).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#9 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Quoted 42 lines · Eric Blake
Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

If the user passes in a value in the range [0, INT64_MAX], the number is representable in both uint64_t and int64_t. So the internal sign bit would be omitted, as in { value=v, sign=false }. Input visitors can visit this value with both the 'uint64' and the 'int64' visitors, and output visitors will output the same value.

If the user passes in a value in the range [-INT64_MAX-1, -1], the number is intended to be used as a negative signed number. So the QInt representation would be the 2s complement representation, { value=-v, sign=true }. On input, the uint64_t visitor would reject the value as out of range, the int64_t visitor would return the appropriate negative value, and the generic int visitor will return the uint64_t value. On output, the number would be given the negative signed value representation in anything that stringizes the value.

If the user passes in a value in the range [INT64_MAX+1, UINT64_MAX}, the number is intended to be used as a large unsigned number. So the QInt representation would be { value=v, sign=false }. On input, the uint64_t visitor would accept the value, the int64_t visitor would reject it as out of range, and the generic int visitor will return the uint64_t value. On output, the number would be given the positive unsigned value representation in the stringized form.

That way, you don't have to complicate the (already-awkward) type promotion rules of QFloat vs QInt with yet another scalar type. The input parser becomes friendlier - you can either use generic 'int' when you want to allow the user to pass in either signed or unsigned values (important for back-compat, where callers like libvirt learned that only signed values worked even when large unsigned values were wanted); or the specific 'int64' and 'uint64' types to force proper ranges.

Quoted 6 lines

It's definitely an alternative implementation to the one you pursued in your series, so maybe we should first figure out WHAT we want represented, before implementing something that will be more baggage than we want (you at least have the advantage of patches that are written; my idea of adding a sign bool to QInt is still just in the initial idea stage).

RFC 7159 gives implementations wide latitude on number representation (this is one of the several reasons why JSON is a poor standard from an interoperability point of view). Our current representation effectively is "if it fits into int64_t, use that, else double". What we need is something that can represent uint64_t exactly, too.

You say you've been thinking about extending QInt's range to cover uint64_t. I've been thinking even more radically: replace both QInt and QFloat by QNumber. This is how JSON *actually* works.

The new QNumber type provides constructors from double, int64_t and uint64_t. It also provides conversion functions to double, int64_t and uint64_t. The latter two can fail.

I'd expect these to be perfectly servicable for the visitors.

Code messing with QObject directly might become slightly more elaborate. But such code should be minimized anyway.

#10 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Quoted 14 lines · Markus Armbruster
Quoted 11 lines · Eric Blake
Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

Quoted 7 lines

You say you've been thinking about extending QInt's range to cover uint64_t. I've been thinking even more radically: replace both QInt and QFloat by QNumber. This is how JSON *actually* works.

The new QNumber type provides constructors from double, int64_t and uint64_t. It also provides conversion functions to double, int64_t and uint64_t. The latter two can fail.

Interesting - I like it, as it takes my idea and goes one step further. You'd want to track 64 bits of precision rather than just 53, when the input was integral, but the idea seems to have some merit (we have some special case in the testsuite for what happens in alternates with various combinations of 'number' vs. 'int' that may need tweaking when they are no longer distinguishable as QInt vs QFloat, but that's not too onerous).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#11 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Hi

----- Original Message -----

Quoted 23 lines · Markus Armbruster
Quoted 14 lines
Quoted 11 lines · Eric Blake
Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

Quoted 7 lines

You say you've been thinking about extending QInt's range to cover uint64_t. I've been thinking even more radically: replace both QInt and QFloat by QNumber. This is how JSON *actually* works.

The new QNumber type provides constructors from double, int64_t and uint64_t. It also provides conversion functions to double, int64_t and uint64_t. The latter two can fail.

Quoted 8 lines

Interesting - I like it, as it takes my idea and goes one step further. You'd want to track 64 bits of precision rather than just 53, when the input was integral, but the idea seems to have some merit (we have some special case in the testsuite for what happens in alternates with various combinations of 'number' vs. 'int' that may need tweaking when they are no longer distinguishable as QInt vs QFloat, but that's not too onerous).

I wonder the benefits from hiding the real type behind a QNumber "superclass", then having to type check at a lower level. QType is not only used for json, so I see some benefits from having a bit stricter type declaration and compile-time check. But I don't have a very good idea of what it would mean to have a generic QNumber type, I could try to implement it to have a more informed opinion.

Quoted 5 lines

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org

#12 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Hi

On Mon, Mar 13, 2017 at 5:29 PM Marc-André Lureau <[email protected]> wrote:

Hi

----- Original Message -----

Quoted 23 lines · Markus Armbruster
Quoted 14 lines
Quoted 11 lines · Eric Blake
Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

Quoted 7 lines

You say you've been thinking about extending QInt's range to cover uint64_t. I've been thinking even more radically: replace both QInt and QFloat by QNumber. This is how JSON *actually* works.

The new QNumber type provides constructors from double, int64_t and uint64_t. It also provides conversion functions to double, int64_t and uint64_t. The latter two can fail.

Quoted 8 lines

Interesting - I like it, as it takes my idea and goes one step further. You'd want to track 64 bits of precision rather than just 53, when the input was integral, but the idea seems to have some merit (we have some special case in the testsuite for what happens in alternates with various combinations of 'number' vs. 'int' that may need tweaking when they are no longer distinguishable as QInt vs QFloat, but that's not too onerous).

I wonder the benefits from hiding the real type behind a QNumber "superclass", then having to type check at a lower level. QType is not only used for json, so I see some benefits from having a bit stricter type declaration and compile-time check. But I don't have a very good idea of what it would mean to have a generic QNumber type, I could try to implement it to have a more informed opinion.

I have looked a bit more into implementing a QNumber type.

There is a bit more error handling to add everywhere for getting a value (for get_int, get_uint), as some conversions will fail. The qdict getters will have to throw those errors too. Whereas the QObject type check or dispatch is there, so less error handling to add.

In my proposal, conversion from int to uint is done for positive values, with the qdict helper (is it the only way we access json parsed values?). Do we want to cast a negative int to a uint? Do we have qmp clients using this representation today, and can we break this?

The qdev-properties will be slightly less convenient to define, but that's minor since it's behind macros, ex:

-            .qtype     = QTYPE_QUINT,                                   \
-            .defval.u  = (_type)_defval,                                \
+            .qtype     = QTYPE_QNUM,                                    \
+            .defval.type  = QNUM_U64,                                   \
+            .defval.u.u64  = (_type)_defval,                            \

The biggest issue I have is how to handle the alt visitors if all ints are numbers, ex with AltIntNum:

    switch ((*obj)->type) {
    case QTYPE_QNUM:
        visit_type_int(v, name, &(*obj)->u.i, &err);
        break;
    case QTYPE_QNUM:
        visit_type_number(v, name, &(*obj)->u.n, &err);
        break;

Should the generator have special handling for QNUM and dispatch based on underlying type?

Overall, it seems to me that using QUINT like I proposed is more straightforward and equally convenient provided we have conversion helpers where needed (mostly for qdict).

thanks for your comments

Signature · 1 line
Marc-André Lureau
#13 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Quoted 40 lines · Marc-André Lureau

Hi

On Mon, Mar 13, 2017 at 5:29 PM Marc-André Lureau <[email protected]> wrote:

Hi

----- Original Message -----

Quoted 23 lines · Markus Armbruster
Quoted 14 lines
Quoted 11 lines · Eric Blake
Quoted 1 line · Marc-André Lureau

The type is not used at all yet. Add some tests to exercice it.

s/exercice/exercise/

I wonder if we need this patch at all.

I've been thinking about a possible alternative representation, such that a single QInt type can cover _both_ signed and unsigned types, by having QInt track a sign bit bool in addition to a uint64_t value.

Quoted 7 lines

You say you've been thinking about extending QInt's range to cover uint64_t. I've been thinking even more radically: replace both QInt and QFloat by QNumber. This is how JSON *actually* works.

The new QNumber type provides constructors from double, int64_t and uint64_t. It also provides conversion functions to double, int64_t and uint64_t. The latter two can fail.

Quoted 8 lines

Interesting - I like it, as it takes my idea and goes one step further. You'd want to track 64 bits of precision rather than just 53, when the input was integral, but the idea seems to have some merit (we have some special case in the testsuite for what happens in alternates with various combinations of 'number' vs. 'int' that may need tweaking when they are no longer distinguishable as QInt vs QFloat, but that's not too onerous).

Quoted 3 lines

I wonder the benefits from hiding the real type behind a QNumber "superclass", then having to type check at a lower level. QType is not only used for json,

The less it is used for non-JSON purposes, the better.

Quoted 6 lines

so I see some benefits from having a bit stricter type
declaration and compile-time check. But I don't have a very good idea of what it would mean to have a generic QNumber type, I could try to implement it to have a more informed opinion.

Quoted 6 lines

I have looked a bit more into implementing a QNumber type.

There is a bit more error handling to add everywhere for getting a value (for get_int, get_uint), as some conversions will fail. The qdict getters will have to throw those errors too. Whereas the QObject type check or dispatch is there, so less error handling to add.

How many places convert QNumber to C integer type?

How many of them have to do range checking anyway?

If range checking turns out to be common, we could fuse it into the conversion, say return -EINVAL for qtype other than QNumber, and -ERANGE for a QNumber out of range, like qemu_strtol() does.

Quoted 2 lines

In my proposal, conversion from int to uint is done for positive values, with the qdict helper (is it the only way we access json parsed values?).

I doubt it.

Quoted 2 lines

Do we want to cast a negative int to a uint? Do we have qmp clients using this representation today, and can we break this?

We don't have "intepret negative as large unsigned" issues in the JSON parser, but we have them in the QObject input visitor:
visit_type_uint64() rejects integers above INT64_MAX, but happily accepts integers between INT64_MIN and -1, and cast them to uint64_t.

This makes no sense for QMP. It crept in right at the beginning because visitors were added without adequate test coverage. Eric noticed this problem and added the FIXME in commit f755dea, four and a half years later. We still lack an adequate test case. I'll add one.

We're awfully slow learners.

QMP clients that work around the "large positive integers are rejected" bugs by sending large negative ones instead may well exist. Fixing the interface would break them. Depressing. Eric, could you have a peek at libvirt?

Additionally, direct users of QObject could conceivably convert QInt to int64_t, then silently cast to unsigned. Or narrower integer types; same bad idea, really. The only way to find them is to review all the code getting integers out of QObject.

Quoted 19 lines

The qdev-properties will be slightly less convenient to define, but that's minor since it's behind macros, ex:

(quoted diff) +3 -2
-            .qtype     = QTYPE_QUINT,                                   \
-            .defval.u  = (_type)_defval,                                \
+            .qtype     = QTYPE_QNUM,                                    \
+            .defval.type  = QNUM_U64,                                   \
+            .defval.u.u64  = (_type)_defval,                            \

The biggest issue I have is how to handle the alt visitors if all ints are numbers, ex with AltIntNum:

    switch ((*obj)->type) {
    case QTYPE_QNUM:
        visit_type_int(v, name, &(*obj)->u.i, &err);
        break;
    case QTYPE_QNUM:
        visit_type_number(v, name, &(*obj)->u.n, &err);
        break;
Quoted 2 lines

Should the generator have special handling for QNUM and dispatch based on underlying type?

I'm afraid we'll need that for keyval anyway.

I've been playing with alternates a bit. I think visit_start_alternate() needs to be redone. Need to find time to finish my experiments and post patches.

Quoted 3 lines

Overall, it seems to me that using QUINT like I proposed is more straightforward and equally convenient provided we have conversion helpers where needed (mostly for qdict).

Contradicts my gut feeling, but my gut is anything but infallible. I guess I'd like to see (sketches of) both, so we can make an informed decision.

Quoted 1 line

thanks for your comments

#14 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Quoted 5 lines · Markus Armbruster

QMP clients that work around the "large positive integers are rejected" bugs by sending large negative ones instead may well exist. Fixing the interface would break them. Depressing. Eric, could you have a peek at libvirt?

Yes, libvirt is such a client already. From
util/virjson.c:virJSONValueObjectAddVArgs():

* Adds the key-value pairs supplied as variable argument list to @obj. *
* Keys look like s:name the first letter is a type code:
...
* U: unsigned long integer value (see below for quirks)
* P: unsigned long integer value, omitted if zero
...

        case 'P':
        case 'U': {
            /* qemu silently truncates numbers larger than LLONG_MAX,
             * so passing the full range of unsigned 64 bit integers
             * is not safe here.  Pass them as signed 64 bit integers
             * instead.
             */
            long long val = va_arg(args, long long);

            if (!val && type == 'P')
                continue;

            rc = virJSONValueObjectAppendNumberLong(obj, key, val);
        }   break;

So if we "fix" QMP to reject negative values in place of large unsigned values, we'll need to also fix libvirt to have a way to introspect the difference and cope accordingly. (I'm thinking that we'll have to keep the negative parsing indefinitely, and can merely improve the parser to also parse large positive - but that we can still reject values < INT64_MIN that would have a weird wraparound).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#15 lore raw

Re: [Qemu-devel] [PATCH 04/21] qobject: add quint type

Hi

Quoted 34 lines · Eric Blake
Quoted 5 lines · Markus Armbruster

QMP clients that work around the "large positive integers are rejected" bugs by sending large negative ones instead may well exist. Fixing the interface would break them. Depressing. Eric, could you have a peek at libvirt?

Yes, libvirt is such a client already. From
util/virjson.c:virJSONValueObjectAddVArgs():

* Adds the key-value pairs supplied as variable argument list to @obj. *
* Keys look like s:name the first letter is a type code:
...
* U: unsigned long integer value (see below for quirks)
* P: unsigned long integer value, omitted if zero
...

        case 'P':
        case 'U': {
            /* qemu silently truncates numbers larger than LLONG_MAX,
             * so passing the full range of unsigned 64 bit integers
             * is not safe here.  Pass them as signed 64 bit integers
             * instead.
             */
            long long val = va_arg(args, long long);

            if (!val && type == 'P')
                continue;

            rc = virJSONValueObjectAppendNumberLong(obj, key, val);
        }   break;
Quoted 7 lines

So if we "fix" QMP to reject negative values in place of large unsigned values, we'll need to also fix libvirt to have a way to introspect the difference and cope accordingly. (I'm thinking that we'll have to keep the negative parsing indefinitely, and can merely improve the parser to also parse large positive - but that we can still reject values < INT64_MIN that would have a weird wraparound).

Currently, parsing is done without expected type information. So if the number fits in an int64, it should be a QINT, otherwise a QFLOAT (see parse_literal). With this series, it will try QUINT before QFLOAT. But what I was afraid though is that the int is sometime assigned back to a uint64. And with my series, get_uint() will fail if the number is negative int, but for compatibility reasons, I think it should cast it instead. We may want to have a qmp capability bit to change this silent casting behaviour.

Signature · 1 line
Marc-André Lureau
#16 lore raw

PATCH 5/21 qapi: update the qobject visitor to use QUInt

In reply to Marc-André Lureau
---
 scripts/qapi-visit.py               |  3 ++-
 qapi/qobject-input-visitor.c        | 30 ++++++++++++++++++++++++------
 qapi/qobject-output-visitor.c       |  3 +--
 tests/test-qobject-input-visitor.c  | 15 +++++++++++++++
 tests/test-qobject-output-visitor.c | 19 +++++++++++++++----
 5 files changed, 57 insertions(+), 13 deletions(-)
scripts/qapi-visit.py +2 -1
index 330b9f321b..532f929e18 100644
@@ -165,7 +165,8 @@ 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_QINT' \
+            or var.type.alternate_qtype() == 'QTYPE_QUINT':
             promote_int = 'false'
 
     ret += mcgen('''
qapi/qobject-input-visitor.c +24 -6
index 865e948ac0..41a825b06b 100644
@@ -21,6 +21,7 @@
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/types.h"
 #include "qapi/qmp/qerror.h"
+#include "qemu/error-report.h"
 #include "qemu/cutils.h"
 #include "qemu/option.h"
 
@@ -349,7 +350,8 @@ 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) {
+    if (promote_int &&
+        ((*obj)->type == QTYPE_QINT || (*obj)->type == QTYPE_QUINT)) {
         (*obj)->type = QTYPE_QFLOAT;
     }
 }
@@ -395,22 +397,38 @@ 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 */
     QObjectInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
+    QUInt *quint;
     QInt *qint;
+    int64_t val;
 
     if (!qobj) {
         return;
     }
+
+    quint = qobject_to_quint(qobj);
+    if (quint) {
+        *obj = quint_get_uint(quint);
+        return;
+    }
+
     qint = qobject_to_qint(qobj);
     if (!qint) {
-        error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-                   full_name(qiv, name), "integer");
-        return;
+        goto error;
     }
 
-    *obj = qint_get_int(qint);
+    val = qint_get_int(qint);
+    if (val < 0) {
+        goto error;
+    }
+
+    *obj = val;
+    return;
+
+error:
+    error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
+               full_name(qiv, name), "unsigned integer");
 }
 
 static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,
qapi/qobject-output-visitor.c +1 -2
index 871127079d..7066b3b59b 100644
@@ -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, qint_from_int(*obj));
+    qobject_output_add(qov, name, quint_from_uint(*obj));
 }
 
 static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,
tests/test-qobject-input-visitor.c +15 -0
index 6eb48fee7b..011366a65b 100644
@@ -170,6 +170,19 @@ static void test_visitor_in_int_str_fail(TestInputVisitorData *data,
     error_free_or_abort(&err);
 }
 
+static void test_visitor_in_uint(TestInputVisitorData *data,
+                                const void *unused)
+{
+    uint64_t res = 0;
+    uint64_t value = G_MAXUINT64;
+    Visitor *v;
+
+    v = visitor_input_test_init(data, "%" PRIu64, value);
+
+    visit_type_uint64(v, NULL, &res, &error_abort);
+    g_assert_cmpint(res, ==, value);
+}
+
 static void test_visitor_in_bool(TestInputVisitorData *data,
                                  const void *unused)
 {
@@ -1233,6 +1246,8 @@ int main(int argc, char **argv)
                            NULL, test_visitor_in_int_str_keyval);
     input_visitor_test_add("/visitor/input/int_str_fail",
                            NULL, test_visitor_in_int_str_fail);
+    input_visitor_test_add("/visitor/input/uint",
+                           NULL, test_visitor_in_uint);
     input_visitor_test_add("/visitor/input/bool",
                            NULL, test_visitor_in_bool);
     input_visitor_test_add("/visitor/input/bool_keyval",
tests/test-qobject-output-visitor.c +15 -4
index 500b452d98..047c6b5c6c 100644
@@ -597,14 +597,25 @@ 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;
+            QUInt *qvalue;
+            tmp = qlist_peek(qlist);
+            g_assert(tmp);
+            qvalue = qobject_to_quint(tmp);
+            g_assert_cmpint(quint_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 QInts when
          * we convert to QObjects, so we can check them all in the same
          * fashion, so simply fall through here
Signature · 1 line
2.12.0.191.gc5d8de91d
#17 lore raw

PATCH 6/21 json: learn to parse uint64 numbers

In reply to Marc-André Lureau

If the parsed number doesn't fit in a int64, try with a uint64 before falling back to double.

Switch strtoll() usage to qemu_strtoi64() helper while at it.

Add a few tests for large numbers.

---
 qobject/json-lexer.c  |  4 ++++
 qobject/json-parser.c | 19 +++++++++++++++++--
 qobject/qjson.c       |  8 ++++++++
 tests/check-qjson.c   | 28 ++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)
qobject/json-lexer.c +4 -0
index af4a75e05b..a0beb0b106 100644
@@ -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,
+        ['u'] = JSON_ESCAPE,
         ['l'] = IN_ESCAPE_LL,
     },
 
     [IN_ESCAPE_I64] = {
         ['d'] = JSON_ESCAPE,
+        ['u'] = JSON_ESCAPE,
     },
 
     [IN_ESCAPE_I6] = {
@@ -247,6 +250,7 @@ static const uint8_t json_lexer[][256] =  {
     },
 
     [IN_ESCAPE] = {
+        ['u'] = JSON_ESCAPE,
         ['d'] = JSON_ESCAPE,
         ['i'] = JSON_ESCAPE,
         ['p'] = JSON_ESCAPE,
qobject/json-parser.c +17 -2
index c18e48ab94..b39cb4d8d6 100644
@@ -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(qint_from_int(va_arg(*ap, long long)));
+    } else if (!strcmp(token->str, "%u")) {
+        return QOBJECT(quint_from_uint(va_arg(*ap, unsigned int)));
+    } else if (!strcmp(token->str, "%lu")) {
+        return QOBJECT(quint_from_uint(va_arg(*ap, unsigned long)));
+    } else if (!strcmp(token->str, "%llu") ||
+               !strcmp(token->str, "%I64u")) {
+        return QOBJECT(quint_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")) {
@@ -504,14 +512,21 @@ static QObject *parse_literal(JSONParserContext *ctxt)
          * strtoll() indicates these instances by setting errno to ERANGE
          */
         int64_t value;
+        uint64_t uvalue;
 
-        errno = 0; /* strtoll doesn't set errno on success */
-        value = strtoll(token->str, NULL, 10);
+        qemu_strtoi64(token->str, NULL, 10, &value);
         if (errno != ERANGE) {
             return QOBJECT(qint_from_int(value));
         }
+
+        qemu_strtou64(token->str, NULL, 10, &uvalue);
+        if (errno != ERANGE) {
+            return QOBJECT(quint_from_uint(uvalue));
+        }
+
         /* fall through to JSON_FLOAT */
     }
+
     case JSON_FLOAT:
         /* FIXME dependent on locale; a pervasive issue in QEMU */
         /* FIXME our lexer matches RFC 7159 in forbidding Inf or NaN,
qobject/qjson.c +8 -0
index b2f3bfec53..6356cff594 100644
@@ -140,6 +140,14 @@ static void to_json(const QObject *obj, QString *str, int pretty, int indent)
         qstring_append(str, buffer);
         break;
     }
+    case QTYPE_QUINT: {
+        QUInt *val = qobject_to_quint(obj);
+        char buffer[1024];
+
+        snprintf(buffer, sizeof(buffer), "%" PRIu64, quint_get_uint(val));
+        qstring_append(str, buffer);
+        break;
+    }
     case QTYPE_QSTRING: {
         QString *val = qobject_to_qstring(obj);
         const char *ptr;
tests/check-qjson.c +28 -0
index 963dd46f07..fd44cd6207 100644
@@ -904,6 +904,33 @@ static void simple_number(void)
     }
 }
 
+static void large_number(void)
+{
+    const char *maxu64 = "18446744073709551615"; /* 2^64-1 */
+    const char *gtu64 = "18446744073709551616"; /* 2^64 */
+    QUInt *quint;
+    QFloat *qfloat;
+    QString *str;
+
+    quint = qobject_to_quint(qobject_from_json(maxu64, &error_abort));
+    g_assert(quint);
+    g_assert_cmpint(quint_get_uint(quint), ==, 18446744073709551615U);
+
+    str = qobject_to_json(QOBJECT(quint));
+    g_assert_cmpstr(qstring_get_str(str), ==, maxu64);
+    QDECREF(str);
+    QDECREF(quint);
+
+    qfloat = qobject_to_qfloat(qobject_from_json(gtu64, &error_abort));
+    g_assert(qfloat);
+    g_assert_cmpfloat(qfloat_get_double(qfloat), ==, 18446744073709551616.0);
+
+    str = qobject_to_json(QOBJECT(qfloat));
+    g_assert_cmpstr(qstring_get_str(str), ==, gtu64);
+    QDECREF(str);
+    QDECREF(qfloat);
+}
+
 static void float_number(void)
 {
     int i;
@@ -1468,6 +1495,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);
 
Signature · 1 line
2.12.0.191.gc5d8de91d
#18 lore raw

PATCH 7/21 object: add uint property setter/getter

In reply to Marc-André Lureau
---
 include/qom/object.h | 23 +++++++++++++++++++++++
 qom/object.c         | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
include/qom/object.h +23 -0
index cd0f412ce9..abaeb8cf4e 100644
@@ -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
qom/object.c +32 -0
index c7b8079df6..ca9d4137b3 100644
@@ -28,6 +28,7 @@
 #include "qapi/qmp/qobject.h"
 #include "qapi/qmp/qbool.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/quint.h"
 #include "qapi/qmp/qstring.h"
 
 #define MAX_INTERFACES 32
@@ -1218,6 +1219,37 @@ 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)
+{
+    QUInt *quint = quint_from_uint(value);
+    object_property_set_qobject(obj, QOBJECT(quint), name, errp);
+
+    QDECREF(quint);
+}
+
+uint64_t object_property_get_uint(Object *obj, const char *name,
+                                  Error **errp)
+{
+    QObject *ret = object_property_get_qobject(obj, name, errp);
+    QUInt *quint;
+    uint64_t retval;
+
+    if (!ret) {
+        return 0;
+    }
+    quint = qobject_to_quint(ret);
+    if (!quint) {
+        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint");
+        retval = 0;
+    } else {
+        retval = quint_get_uint(quint);
+    }
+
+    qobject_decref(ret);
+    return retval;
+}
+
 typedef struct EnumProperty {
     const char * const *strings;
     int (*get)(Object *, Error **);
Signature · 1 line
2.12.0.191.gc5d8de91d
#19 lore raw

PATCH 8/21 qdev: use int and uint properties

In reply to Marc-André Lureau

So the correct QObject type is used.

---
 include/hw/qdev-core.h       |  5 +++-
 include/hw/qdev-properties.h | 59 ++++++++++++++++++++++++++------------------
 hw/block/fdc.c               | 54 ++++++++++++++++++++--------------------
 hw/core/qdev-properties.c    |  8 +++---
 hw/core/qdev.c               |  8 +++---
 hw/net/e1000e.c              | 14 +++++------
 6 files changed, 82 insertions(+), 66 deletions(-)
include/hw/qdev-core.h +4 -1
index b44b476765..218f83b4a1 100644
@@ -239,7 +239,10 @@ struct Property {
     ptrdiff_t    offset;
     uint8_t      bitnr;
     QType        qtype;
-    int64_t      defval;
+    union {
+        int64_t      i;
+        uint64_t     u;
+    } defval;
     int          arrayoffset;
     PropertyInfo *arrayinfo;
     int          arrayfieldsize;
include/hw/qdev-properties.h +35 -24

107 lines not on this page · raw message

hw/block/fdc.c +27 -27

78 lines not on this page · raw message

hw/core/qdev-properties.c +4 -4
index 6ab4265eb4..fc2bf73369 100644
@@ -982,17 +982,17 @@ void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value)
 
 void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value)
 {
-    object_property_set_int(OBJECT(dev), value, name, &error_abort);
+    object_property_set_uint(OBJECT(dev), value, name, &error_abort);
 }
 
 void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value)
 {
-    object_property_set_int(OBJECT(dev), value, name, &error_abort);
+    object_property_set_uint(OBJECT(dev), value, name, &error_abort);
 }
 
 void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value)
 {
-    object_property_set_int(OBJECT(dev), value, name, &error_abort);
+    object_property_set_uint(OBJECT(dev), value, name, &error_abort);
 }
 
 void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value)
@@ -1002,7 +1002,7 @@ void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value)
 
 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value)
 {
-    object_property_set_int(OBJECT(dev), value, name, &error_abort);
+    object_property_set_uint(OBJECT(dev), value, name, &error_abort);
 }
 
 void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value)
hw/core/qdev.c +5 -3
index 1e7fb33246..0c47d92a1f 100644
@@ -833,12 +833,14 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
     }
 
     if (prop->qtype == QTYPE_QBOOL) {
-        object_property_set_bool(obj, prop->defval, prop->name, &error_abort);
+        object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort);
     } else if (prop->info->enum_table) {
-        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);
     } else if (prop->qtype == QTYPE_QINT) {
-        object_property_set_int(obj, prop->defval, prop->name, &error_abort);
+        object_property_set_int(obj, prop->defval.i, prop->name, &error_abort);
+    } else if (prop->qtype == QTYPE_QUINT) {
+        object_property_set_uint(obj, prop->defval.u, prop->name, &error_abort);
     }
 }
 
hw/net/e1000e.c +7 -7
index b0f429b8e5..5b50f1853a 100644
@@ -645,13 +645,13 @@ 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,
-                        e1000e_prop_disable_vnet, bool),
-    DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven,
-                        PCI_VENDOR_ID_INTEL,
-                        e1000e_prop_subsys_ven, uint16_t),
-    DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0,
-                        e1000e_prop_subsys, uint16_t),
+    DEFINE_PROP_INT("disable_vnet_hdr", E1000EState, disable_vnet, false,
+                    e1000e_prop_disable_vnet, bool),
+    DEFINE_PROP_INT("subsys_ven", E1000EState, subsys_ven,
+                    PCI_VENDOR_ID_INTEL,
+                    e1000e_prop_subsys_ven, uint16_t),
+    DEFINE_PROP_INT("subsys", E1000EState, subsys, 0,
+                    e1000e_prop_subsys, uint16_t),
     DEFINE_PROP_END_OF_LIST(),
 };
 
Signature · 1 line
2.12.0.191.gc5d8de91d
#20 lore raw

PATCH 9/21 qdev: use appropriate type

In reply to Marc-André Lureau
---
 hw/i386/acpi-build.c      | 15 ++++++++-------
 hw/pci-host/gpex.c        |  2 +-
 hw/pci-host/q35.c         |  2 +-
 hw/pci-host/xilinx-pcie.c |  2 +-
 target/i386/cpu.c         |  2 +-
 5 files changed, 12 insertions(+), 11 deletions(-)
hw/i386/acpi-build.c +8 -7
index 2073108577..76bff18e3f 100644
@@ -58,6 +58,7 @@
 #include "hw/acpi/aml-build.h"
 
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/quint.h"
 #include "qom/qom-qobject.h"
 #include "hw/i386/amd_iommu.h"
 #include "hw/i386/intel_iommu.h"
@@ -150,21 +151,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 = quint_get_uint(qobject_to_quint(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 = quint_get_uint(qobject_to_quint(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 = quint_get_uint(qobject_to_quint(o));
     } else {
         pm->s4_val = false;
     }
@@ -500,7 +501,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));
+        uint64_t bsel_val = quint_get_uint(qobject_to_quint(bsel));
 
         aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
         notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
@@ -610,7 +611,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 = qint_get_int(qobject_to_qint(bsel));
+        uint64_t bsel_val = quint_get_uint(qobject_to_quint(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 */)
@@ -2586,12 +2587,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 = quint_get_uint(qobject_to_quint(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 = quint_get_uint(qobject_to_quint(o));
     qobject_decref(o);
     return true;
 }
hw/pci-host/gpex.c +1 -1
index 66055ee5cc..8d3a64008c 100644
@@ -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);
 }
 
hw/pci-host/q35.c +1 -1
index 5438be8253..3cbe8cfcea 100644
@@ -173,7 +173,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",
hw/pci-host/xilinx-pcie.c +1 -1
index 8b71e2d950..461ed41151 100644
@@ -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);
 }
 
target/i386/cpu.c +1 -1
index fba92125ab..54f859bc8d 100644
@@ -3176,7 +3176,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
                               OBJECT(cpu->apic_state), &error_abort);
     object_unref(OBJECT(cpu->apic_state));
 
-    qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id);
+    qdev_prop_set_int32(cpu->apic_state, "id", cpu->apic_id);
     /* TODO: convert to link<> */
     apic = APIC_COMMON(cpu->apic_state);
     apic->cpu = cpu;
Signature · 1 line
2.12.0.191.gc5d8de91d
#21 lore raw

PATCH 10/21 Use uint property getter/setter where appropriate

In reply to Marc-André Lureau

All those property usages are associated with unsigned integers, so use appropriate getter/setter.

---
 include/hw/isa/isa.h         |  2 +-
 hw/acpi/memory_hotplug.c     | 10 ++++----
 hw/acpi/nvdimm.c             | 10 ++++----
 hw/acpi/pcihp.c              |  6 ++---
 hw/arm/aspeed.c              |  4 ++--
 hw/arm/bcm2835_peripherals.c |  9 ++++----
 hw/arm/raspi.c               |  4 ++--
 hw/core/platform-bus.c       |  2 +-
 hw/i386/acpi-build.c         | 55 ++++++++++++++++++++++----------------------
 hw/i386/pc.c                 |  6 ++---
 hw/intc/arm_gicv3_common.c   |  2 +-
 hw/mem/pc-dimm.c             |  5 ++--
 hw/misc/auxbus.c             |  2 +-
 hw/misc/pvpanic.c            |  2 +-
 hw/ppc/pnv_core.c            |  2 +-
 hw/ppc/spapr.c               |  8 ++++---
 numa.c                       |  6 ++---
 target/i386/cpu.c            |  4 ++--
 ui/console.c                 |  4 ++--
 xen-hvm.c                    |  6 ++---
 20 files changed, 77 insertions(+), 72 deletions(-)
include/hw/isa/isa.h +1 -1
index c2fdd70cdc..95593408ef 100644
@@ -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;
 }
hw/acpi/memory_hotplug.c +6 -4
index 210073d283..db3c89ceab 100644
@@ -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 */
@@ -95,11 +96,12 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
         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_int(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 */
-        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 */
hw/acpi/nvdimm.c +5 -5
index 8e7d6ec034..e57027149d 100644
@@ -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));
 
hw/acpi/pcihp.c +3 -3
index 2b0f3e1bfb..d0e9c4770a 100644
@@ -63,10 +63,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);
         }
hw/arm/aspeed.c +2 -2
index 283c038814..4af422909f 100644
@@ -187,8 +187,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,
hw/arm/bcm2835_peripherals.c +4 -5
index 369ef1e3bd..b168c6f83e 100644
@@ -126,7 +126,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);
@@ -208,15 +208,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;
hw/arm/raspi.c +2 -2
index 2b295f14c4..32cdc98c6d 100644
@@ -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);
 }
 
hw/core/platform-bus.c +1 -1
index 329ac670c0..33d32fbf22 100644
@@ -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)
hw/i386/acpi-build.c +28 -27

76 lines not on this page · raw message

hw/i386/pc.c +3 -3
index d24388e05f..3b3c2dc43c 100644
@@ -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;
@@ -1100,7 +1100,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);
@@ -1562,7 +1562,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);
hw/intc/arm_gicv3_common.c +1 -1
index c6493d6c07..e2064cd8c5 100644
@@ -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
hw/mem/pc-dimm.c +3 -2
index 9e8dab0e89..f6def8c239 100644
@@ -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;
     }
hw/misc/auxbus.c +1 -1
index e4a7ba41de..8a90ddda84 100644
@@ -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));
 }
 
hw/misc/pvpanic.c +1 -1
index 57da7f2199..2b1e9a6450 100644
@@ -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[] = {
hw/ppc/pnv_core.c +1 -1
index d79d530b48..fe3758754b 100644
@@ -50,7 +50,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
hw/ppc/spapr.c +5 -3
index c3bb991605..a7fdeab471 100644
@@ -2528,7 +2528,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;
@@ -2616,7 +2617,8 @@ static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev,
     uint64_t size = memory_region_size(mr);
     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;
     }
@@ -2818,7 +2820,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;
         }
numa.c +3 -3
index e01cb547a2..d22f3acc8a 100644
@@ -205,7 +205,7 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
         }
 
         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;
@@ -527,8 +527,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",
target/i386/cpu.c +2 -2
index 54f859bc8d..261b1002e9 100644
@@ -2309,8 +2309,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);
ui/console.c +2 -2
index d1ff7504ec..c5233c8daf 100644
@@ -1866,8 +1866,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;
         }
xen-hvm.c +3 -3
index 5043beb98f..16c3a259fa 100644
@@ -183,9 +183,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).
Signature · 1 line
2.12.0.191.gc5d8de91d
#22 lore raw

PATCH 11/21 qdict: learn to lookup quint

In reply to Marc-André Lureau

Since a number may be parsed as an integer if it fits, learn to deal with this situtation and fallback on QInt if QUint failed. There is no need for exact type getters in qemu yet.

---
 include/qapi/qmp/qdict.h |  2 ++
 qobject/qdict.c          | 37 ++++++++++++++++++++++++++++++++++++-
 tests/check-qdict.c      | 31 +++++++++++++++++++++++++++++++
 util/qemu-option.c       |  6 ++++++
 4 files changed, 75 insertions(+), 1 deletion(-)
include/qapi/qmp/qdict.h +2 -0
index fe9a4c5c60..dae3149603 100644
@@ -61,6 +61,8 @@ 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,
+                            Error **errp);
 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);
 
qobject/qdict.c +36 -1
index 291eef1a19..8d5c028181 100644
@@ -12,6 +12,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/quint.h"
 #include "qapi/qmp/qfloat.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qbool.h"
@@ -181,7 +182,7 @@ 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.
+ * QFloat, QInt or QUInt object.
  *
  * Return number mapped by 'key'.
  */
@@ -195,6 +196,8 @@ double qdict_get_double(const QDict *qdict, const char *key)
         return qfloat_get_double(qobject_to_qfloat(obj));
     case QTYPE_QINT:
         return qint_get_int(qobject_to_qint(obj));
+    case QTYPE_QUINT:
+        return quint_get_uint(qobject_to_quint(obj));
     default:
         abort();
     }
@@ -272,6 +275,38 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key,
 }
 
 /**
+ * qdict_get_try_uint(): Try to get unsigned mapped by 'key'
+ *
+ * Return integer mapped by 'key', if it is not present in
+ * the dictionary or with negative value, returns 0 and set error.
+ */
+uint64_t qdict_get_try_uint(const QDict *qdict, const char *key,
+                            Error **errp)
+{
+    QUInt *quint = qobject_to_quint(qdict_get(qdict, key));
+    QInt *qint;
+    int val;
+
+    if (quint) {
+        return quint_get_uint(quint);
+    }
+
+    qint = qobject_to_qint(qdict_get(qdict, key));
+    if (!qint) {
+        error_setg(errp, "Missing key or type mismatch");
+        return 0;
+    }
+
+    val = qint_get_int(qint);
+    if (val < 0) {
+        error_setg(errp, "Invalid value, unsigned int expected");
+        return 0;
+    }
+
+    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
tests/check-qdict.c +31 -0
index 81162ee572..80a8aef689 100644
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 
 #include "qapi/qmp/qint.h"
+#include "qapi/qmp/quint.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qstring.h"
 #include "qapi/error.h"
@@ -121,6 +122,35 @@ static void qdict_get_try_int_test(void)
     QDECREF(tests_dict);
 }
 
+static void qdict_get_try_uint_test(void)
+{
+    uint64_t ret;
+    const int ivalue = 100;
+    const uint64_t uvalue = G_MAXUINT64;
+    const char *key = "uint";
+    QDict *tests_dict = qdict_new();
+    Error *err = NULL;
+
+    qdict_put(tests_dict, key, qint_from_int(ivalue));
+    /* try_uint will work with int types too */
+    ret = qdict_get_try_uint(tests_dict, key, &err);
+    g_assert_cmpint(ret, ==, ivalue);
+    g_assert(!err);
+
+    qdict_put(tests_dict, key, quint_from_uint(uvalue));
+    ret = qdict_get_try_uint(tests_dict, key, &err);
+    g_assert_cmpint(ret, ==, uvalue);
+    g_assert(!err);
+
+    qdict_put(tests_dict, key, qint_from_int(-1));
+    /* try_uint will fail with negative values */
+    ret = qdict_get_try_uint(tests_dict, key, &err);
+    g_assert(err);
+    error_free(err);
+
+    QDECREF(tests_dict);
+}
+
 static void qdict_get_str_test(void)
 {
     const char *p;
@@ -854,6 +884,7 @@ int main(int argc, char **argv)
     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_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);
util/qemu-option.c +6 -0
index 5ce1b5c246..7338b943e1 100644
@@ -959,6 +959,12 @@ static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *opaque)
         assert(n < sizeof(buf));
         value = buf;
         break;
+    case QTYPE_QUINT:
+        n = snprintf(buf, sizeof(buf), "%" PRIu64,
+                     quint_get_uint(qobject_to_quint(obj)));
+        assert(n < sizeof(buf));
+        value = buf;
+        break;
     case QTYPE_QFLOAT:
         n = snprintf(buf, sizeof(buf), "%.17g",
                      qfloat_get_double(qobject_to_qfloat(obj)));
Signature · 1 line
2.12.0.191.gc5d8de91d
#23 lore raw

PATCH 12/21 test-qga: drop everything until guest-sync

In reply to Marc-André Lureau

In the following commits, qemu-ga will emit an event on connect that a real client should treat or ignore and test-qga can skip.

---
 tests/test-qga.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
tests/test-qga.c +20 -7
index c780f0079a..e1f59b7370 100644
@@ -13,6 +13,8 @@ typedef struct {
     GPid pid;
 } TestFixture;
 
+static void guest_sync_delimited(const TestFixture *fixture);
+
 static int connect_qga(char *path)
 {
     int s, ret, len, i = 0;
@@ -45,12 +47,13 @@ static void qga_watch(GPid pid, gint status, gpointer user_data)
     g_main_loop_quit(fixture->loop);
 }
 
+
 static void
 fixture_setup(TestFixture *fixture, gconstpointer data)
 {
     const gchar *extra_arg = data;
     GError *error = NULL;
-    gchar *cwd, *path, *cmd, **argv = NULL;
+    char *cwd, *path, *cmd, **argv = NULL;
 
     fixture->loop = g_main_loop_new(NULL, FALSE);
 
@@ -77,6 +80,8 @@ fixture_setup(TestFixture *fixture, gconstpointer data)
     fixture->fd = connect_qga(path);
     g_assert_cmpint(fixture->fd, !=, -1);
 
+    guest_sync_delimited(fixture);
+
     g_strfreev(argv);
     g_free(cmd);
     g_free(cwd);
@@ -138,9 +143,8 @@ static void qmp_assertion_message_error(const char     *domain,
     }                                                                   \
 } while (0)
 
-static void test_qga_sync_delimited(gconstpointer fix)
+static void guest_sync_delimited(const TestFixture *fixture)
 {
-    const TestFixture *fixture = fix;
     guint32 v, r = g_random_int();
     unsigned char c;
     QDict *ret;
@@ -148,12 +152,13 @@ static void test_qga_sync_delimited(gconstpointer fix)
 
     cmd = g_strdup_printf("%c{'execute': 'guest-sync-delimited',"
                           " 'arguments': {'id': %u } }", 0xff, r);
+
     qmp_fd_send(fixture->fd, cmd);
-    g_free(cmd);
 
-    v = read(fixture->fd, &c, 1);
-    g_assert_cmpint(v, ==, 1);
-    g_assert_cmpint(c, ==, 0xff);
+    do {
+        v = read(fixture->fd, &c, 1);
+        g_assert_cmpint(v, ==, 1);
+    } while (c != 0xff);
 
     ret = qmp_fd_receive(fixture->fd);
     g_assert_nonnull(ret);
@@ -163,6 +168,14 @@ static void test_qga_sync_delimited(gconstpointer fix)
     g_assert_cmpint(r, ==, v);
 
     QDECREF(ret);
+    g_free(cmd);
+}
+
+static void test_qga_sync_delimited(gconstpointer fix)
+{
+    const TestFixture *fixture = fix;
+
+    guest_sync_delimited(fixture);
 }
 
 static void test_qga_sync(gconstpointer fix)
Signature · 1 line
2.12.0.191.gc5d8de91d
#24 lore raw

Re: [Qemu-devel] [PATCH 12/21] test-qga: drop everything until guest-sync

Quoted 3 lines · Marc-André Lureau

In the following commits, qemu-ga will emit an event on connect that a real client should treat or ignore and test-qga can skip.

By the way, I still have a patch pending to fix test-qga:
https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg03664.html

that we may want to incorporate first

Quoted 5 lines
---
 tests/test-qga.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#25 lore raw

PATCH 13/21 qga: report error on keyfile dump error

In reply to Marc-André Lureau
---
 qga/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
qga/main.c +6 -1
index 92658bc0e2..beff041340 100644
@@ -1082,7 +1082,12 @@ static void config_dump(GAConfig *config)
     g_free(tmp);
 
     tmp = g_key_file_to_data(keyfile, NULL, &error);
-    printf("%s", tmp);
+    if (tmp) {
+        printf("%s", tmp);
+    } else if (error) {
+        g_critical("Failed to dump keyfile: %s", error->message);
+        g_clear_error(&error);
+    }
 
     g_free(tmp);
     g_key_file_free(keyfile);
Signature · 1 line
2.12.0.191.gc5d8de91d
#26 lore raw

PATCH 14/21 qga: add and populate VMDumpInfo

In reply to Marc-André Lureau

Get various addresses and informations that can be useful for qemu to generate dumps, and provide enough details for KASLR kernels to be exploitable by tools like crash.

phys-base: the physical address where the kernel is loaded
vmcoreinfo: can be used to read the guest vmcoreinfo ELF note _text: can be used to compute the kaslr offset (not needed when vmcoreinfo)

---
 qga/main.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)
qga/main.c +134 -0
index beff041340..1c39895baa 100644
@@ -65,6 +65,14 @@ typedef struct GAPersistentState {
     int64_t fd_counter;
 } GAPersistentState;
 
+typedef struct VMDumpInfo {
+    bool has_phys_base;
+    uint64_t phys_base;
+    bool has_text;
+    uint64_t text;
+    char *vmcoreinfo;
+} VMDumpInfo;
+
 struct GAState {
     JSONMessageParser parser;
     GMainLoop *main_loop;
@@ -90,6 +98,7 @@ struct GAState {
 #endif
     gchar *pstate_filepath;
     GAPersistentState pstate;
+    VMDumpInfo vmdump;
 };
 
 struct GAState *ga_state;
@@ -1357,6 +1366,128 @@ static int run_agent(GAState *s, GAConfig *config)
     return EXIT_SUCCESS;
 }
 
+#define __START_KERNEL_map    0xffffffff80000000UL
+
+static void update_vmdump_info(GAState *s)
+{
+#ifndef _WIN32
+    char *vmcoreinfo = NULL;
+    char *iomem = NULL;
+    char *kallsyms = NULL;
+    gsize len;
+    GError *err = NULL;
+#ifdef __x86_64__
+    guint64 kernel_code_start, text_start, phys_base;
+    char *tmp, *line, *eol;
+
+    if (!g_file_get_contents("/proc/iomem", &iomem, &len, &err)) {
+        g_critical("Failed to read /proc/iomem: %s", err->message);
+        g_clear_error(&err);
+        goto end;
+    }
+    if (!iomem[len] == '\0') {
+        g_critical("iomem is not null-terminated");
+        goto end;
+    }
+
+    for (line = iomem; line != NULL; line = eol ? eol + 1 : NULL) {
+        eol = strstr(line, "\n");
+        if (eol) {
+            *eol = '\0';
+        }
+        tmp = strstr(line, " : Kernel code");
+        if (!tmp || *(tmp + 14) != '\0') {
+            continue;
+        } else {
+            break;
+        }
+    }
+
+    if (line == NULL) {
+        g_critical("failed to find kernel_code_start");
+        goto end;
+    } else {
+        tmp = strstr(line, "-");
+        if (!tmp) {
+            g_critical("no -");
+            goto end;
+        }
+        *tmp = '\0';
+        kernel_code_start = g_ascii_strtoull(g_strstrip(line), &tmp, 16);
+        if (*tmp != '\0') {
+            g_critical("failed to parse hex value");
+            goto end;
+        }
+    }
+
+    if (!g_file_get_contents("/proc/kallsyms", &kallsyms, &len, &err)) {
+        g_critical("Failed to read /proc/kallsyms: %s", err->message);
+        g_clear_error(&err);
+        goto end;
+    }
+    if (!kallsyms[len] == '\0') {
+        g_critical("iomem is not null-terminated");
+        goto end;
+    }
+
+    for (line = kallsyms; line != NULL; line = eol ? eol + 1 : NULL) {
+        eol = strstr(line, "\n");
+        if (eol) {
+            *eol = '\0';
+        }
+        tmp = strstr(line, " T _text");
+        if (!tmp || *(tmp + 8) != '\0') {
+            continue;
+        } else {
+            *tmp = '\0';
+            break;
+        }
+    }
+
+    if (line == NULL) {
+        g_critical("failed to find _text");
+        goto end;
+    } else {
+        text_start = g_ascii_strtoull(g_strstrip(line), &tmp, 16);
+        if (*tmp != '\0') {
+            g_critical("failed to parse hex value");
+            goto end;
+        }
+    }
+
+    phys_base = kernel_code_start - (text_start - __START_KERNEL_map);
+    g_debug("_text: %lx, kernel_code_start: %lx",
+            text_start, kernel_code_start);
+    g_debug("-> phys_base: %lx", phys_base);
+    g_debug("vmcoreinfo: %s", vmcoreinfo);
+
+    s->vmdump.has_phys_base = true;
+    s->vmdump.phys_base = phys_base;
+    s->vmdump.has_text = true;
+    s->vmdump.text = text_start;
+#endif /* x86_64 */
+
+    if (!g_file_get_contents("/sys/kernel/vmcoreinfo",
+                             &vmcoreinfo, &len, &err)) {
+        g_critical("Failed to read vmcoreinfo: %s", err->message);
+        g_clear_error(&err);
+        goto end;
+    }
+    if (!vmcoreinfo[len] == '\0') {
+        g_critical("vmcoreinfo is not null-terminated");
+        goto end;
+    }
+
+    s->vmdump.vmcoreinfo = vmcoreinfo;
+    vmcoreinfo = NULL;
+
+end:
+    g_free(vmcoreinfo);
+    g_free(kallsyms);
+    g_free(iomem);
+#endif
+}
+
 int main(int argc, char **argv)
 {
     int ret = EXIT_SUCCESS;
@@ -1364,6 +1495,8 @@ int main(int argc, char **argv)
     GAConfig *config = g_new0(GAConfig, 1);
     int listen_fd;
 
+    update_vmdump_info(s);
+
     config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
 
     qga_qmp_init_marshal(&ga_commands);
@@ -1460,6 +1593,7 @@ end:
     if (s->main_loop) {
         g_main_loop_unref(s->main_loop);
     }
+    g_free(s->vmdump.vmcoreinfo);
     g_free(s);
 
     return ret;
Signature · 1 line
2.12.0.191.gc5d8de91d
#27 lore raw

PATCH 15/21 qga: register event emit function

In reply to Marc-André Lureau
---
 qga/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
qga/main.c +8 -0
index 1c39895baa..8e852bd556 100644
@@ -39,6 +39,7 @@
 #define CONFIG_FSFREEZE
 #endif
 #endif
+#include "qapi/qmp-event.h"
 
 #ifndef _WIN32
 #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
@@ -1488,6 +1489,12 @@ end:
 #endif
 }
 
+static void
+monitor_qapi_event_queue(qga_QAPIEvent event, QDict *qdict, Error **errp)
+{
+    send_response(ga_state, QOBJECT(qdict));
+}
+
 int main(int argc, char **argv)
 {
     int ret = EXIT_SUCCESS;
@@ -1496,6 +1503,7 @@ int main(int argc, char **argv)
     int listen_fd;
 
     update_vmdump_info(s);
+    qmp_event_set_func_emit(monitor_qapi_event_queue);
 
     config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
 
Signature · 1 line
2.12.0.191.gc5d8de91d
#28 lore raw

PATCH 16/21 qga: emit VMDUMP_INFO event

In reply to Marc-André Lureau

When client connects, emit the VMDUMP_INFO.

---
 qga/guest-agent-core.h |  2 ++
 qga/channel-posix.c    | 11 +++++++++++
 qga/main.c             | 13 +++++++++++++
 Makefile               |  7 ++++++-
 qga/Makefile.objs      |  1 +
 qga/qapi-schema.json   | 15 +++++++++++++++
 6 files changed, 48 insertions(+), 1 deletion(-)
qga/guest-agent-core.h +2 -0
index 3e8a4acff2..1880b0f0ac 100644
@@ -46,3 +46,5 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp);
 #ifndef _WIN32
 void reopen_fd_to_null(int fd);
 #endif
+
+void ga_client_added(void);
qga/channel-posix.c +11 -0
index 3f34465159..5999df0684 100644
@@ -3,6 +3,7 @@
 #include "qapi/error.h"
 #include "qemu/sockets.h"
 #include "qga/channel.h"
+#include "qga/guest-agent-core.h"
 
 #ifdef CONFIG_SOLARIS
 #include <stropts.h>
@@ -98,6 +99,13 @@ static gboolean ga_channel_client_event(GIOChannel *channel,
     return true;
 }
 
+static gboolean client_added_idle_cb(gpointer user_data)
+{
+    ga_client_added();
+
+    return false;
+}
+
 static int ga_channel_client_add(GAChannel *c, int fd)
 {
     GIOChannel *client_channel;
@@ -115,6 +123,9 @@ static int ga_channel_client_add(GAChannel *c, int fd)
     g_io_add_watch(client_channel, G_IO_IN | G_IO_HUP,
                    ga_channel_client_event, c);
     c->client_channel = client_channel;
+
+    g_idle_add(client_added_idle_cb, NULL);
+
     return 0;
 }
 
qga/main.c +13 -0
index 8e852bd556..d2a874e67a 100644
@@ -40,6 +40,7 @@
 #endif
 #endif
 #include "qapi/qmp-event.h"
+#include "qga-qapi-event.h"
 
 #ifndef _WIN32
 #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
@@ -691,6 +692,18 @@ static gboolean channel_event_cb(GIOCondition condition, gpointer data)
     return true;
 }
 
+void ga_client_added(void)
+{
+#ifndef _WIN32
+    GAState *s = ga_state;
+
+    qapi_event_send_vmdump_info(s->vmdump.has_phys_base, s->vmdump.phys_base,
+                                s->vmdump.has_text, s->vmdump.text,
+                                s->vmdump.vmcoreinfo != NULL,
+                                s->vmdump.vmcoreinfo, NULL);
+#endif
+}
+
 static gboolean channel_init(GAState *s, const gchar *method, const gchar *path,
                              int listen_fd)
 {
Makefile +6 -1
index 1c4c04f6f2..fc7e321041 100644
@@ -404,6 +404,11 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
 		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
 		"GEN","$@")
+qga/qapi-generated/qga-qapi-event.c qga/qapi-generated/qga-qapi-event.h :\
+$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
+		$(gen-out-type)  -o qga/qapi-generated -p "qga-" $<, \
+		"GEN","$@")
 
 qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
                $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
@@ -437,7 +442,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
 		$(gen-out-type) -o "." $<, \
 		"GEN","$@")
 
-QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
+QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h qga-qapi-event.h)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
 qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
qga/Makefile.objs +1 -0
index 1c5986c0bb..d22977f0e1 100644
@@ -4,5 +4,6 @@ qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o
 qga-obj-$(CONFIG_WIN32) += vss-win32.o
 qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o
 qga-obj-y += qapi-generated/qga-qmp-marshal.o
+qga-obj-y += qapi-generated/qga-qapi-event.o
 
 qga-vss-dll-obj-$(CONFIG_QGA_VSS) += vss-win32/
qga/qapi-schema.json +15 -0
index d421609dcb..2a95af3399 100644
@@ -48,6 +48,21 @@
   'returns': 'int' }
 
 ##
+# @VMDUMP_INFO:
+#
+# Provides VM dump information details to qemu.
+#
+# @phys-base: base address
+#
+# @text: "_text" location
+#
+# @vmcoreinfo: the content of /sys/kernel/vmcoreinfo on Linux
+#
+##
+{ 'event': 'VMDUMP_INFO',
+  'data': { '*phys-base': 'uint64', '*text': 'uint64', '*vmcoreinfo': 'str' } }
+
+##
 # @guest-sync:
 #
 # Echo back a unique integer value
Signature · 1 line
2.12.0.191.gc5d8de91d
#29 lore raw

PATCH 17/21 virtio-channel: parse qga stream for VMDUMP_INFO event

In reply to Marc-André Lureau

On virtio channel "org.qemu.guest_agent.0", parse the json stream until the VMDUMP_INFO is received and retrieve the dump details.

---
 include/sysemu/dump-info.h | 15 +++++++++++++
 dump.c                     |  3 +++
 hw/char/virtio-console.c   | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 include/sysemu/dump-info.h
include/sysemu/dump-info.h new file +15 -0
new file mode 100644
index 0000000000..fb1ddff9af
@@ -0,0 +1,15 @@
+#ifndef DUMP_INFO_H
+#define DUMP_INFO_H
+
+typedef struct DumpInfo {
+    bool received;
+    bool has_phys_base;
+    uint64_t phys_base;
+    bool has_text;
+    uint64_t text;
+    char *vmcoreinfo;
+} DumpInfo;
+
+extern DumpInfo dump_info;
+
+#endif /* DUMP_INFO_H */
dump.c +3 -0
index f7b80d856b..68b406459e 100644
@@ -20,6 +20,7 @@
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
+#include "sysemu/dump-info.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/memory_mapping.h"
 #include "sysemu/cpus.h"
@@ -38,6 +39,8 @@
 #define ELF_MACHINE_UNAME "Unknown"
 #endif
 
+DumpInfo dump_info = { 0, };
+
 uint16_t cpu_to_dump16(DumpState *s, uint16_t val)
 {
     if (s->dump_info.d_endian == ELFDATA2LSB) {
hw/char/virtio-console.c +53 -0

95 lines not on this page · raw message

Signature · 1 line
2.12.0.191.gc5d8de91d
#30 lore raw

Re: [Qemu-devel] [PATCH 17/21] virtio-channel: parse qga stream for VMDUMP_INFO event

Quoted 76 lines · Marc-André Lureau

On virtio channel "org.qemu.guest_agent.0", parse the json stream until the VMDUMP_INFO is received and retrieve the dump details.

---
 include/sysemu/dump-info.h | 15 +++++++++++++
 dump.c                     |  3 +++
 hw/char/virtio-console.c   | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 include/sysemu/dump-info.h
include/sysemu/dump-info.h new file +15 -0
new file mode 100644
index 0000000000..fb1ddff9af
@@ -0,0 +1,15 @@
+#ifndef DUMP_INFO_H
+#define DUMP_INFO_H
+
+typedef struct DumpInfo {
+    bool received;
+    bool has_phys_base;
+    uint64_t phys_base;
+    bool has_text;
+    uint64_t text;
+    char *vmcoreinfo;
+} DumpInfo;
+
+extern DumpInfo dump_info;
+
+#endif /* DUMP_INFO_H */
dump.c +3 -0
index f7b80d856b..68b406459e 100644
@@ -20,6 +20,7 @@
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
+#include "sysemu/dump-info.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/memory_mapping.h"
 #include "sysemu/cpus.h"
@@ -38,6 +39,8 @@
 #define ELF_MACHINE_UNAME "Unknown"
 #endif
 
+DumpInfo dump_info = { 0, };
+
 uint16_t cpu_to_dump16(DumpState *s, uint16_t val)
 {
     if (s->dump_info.d_endian == ELFDATA2LSB) {
hw/char/virtio-console.c +4 -0
index 798d9b69fd..796b7c85aa 100644
@@ -16,6 +16,9 @@
 #include "trace.h"
 #include "hw/virtio/virtio-serial.h"
 #include "qapi-event.h"
+#include "qapi/qmp/json-streamer.h"
+#include "qapi/qmp/json-parser.h"
+#include "sysemu/dump-info.h"
 
 #define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport"
 #define VIRTIO_CONSOLE(obj) \
@@ -26,6 +29,7 @@ typedef struct VirtConsole {
 
     CharBackend chr;
     guint watch;
+    JSONMessageParser parser;
 } VirtConsole;
 
 /*

hw/char/virtio-console.c static ssize_t flush_buf(VirtIOSerialPort *port, · line 59

Quoted 7 lines
hw/char/virtio-console.c +4 -0
@@ -49,6 +53,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
     VirtConsole *vcon = VIRTIO_CONSOLE(port);
     ssize_t ret;
 
+    if (vcon->parser.emit &&
+        !dump_info.received) {
+        json_message_parser_feed(&vcon->parser, (const char *)buf, len);
+    }

[snip]

so we just continually feed data into the json parser until we see the event we care about....

What kind of denial of service protection does our JSON parser have. Now that QEMU is directly parsing JSON from QEMU guest agent, it is exposed to malicious attack by the guest agent.

eg what happens if the 'vmcoreinfo' string in the JSON doc received from the guest ends up being 10GB in size ? Is that going to cause our JSON parser to allocate QString which is 10GB in size which we'll further try to strdup just below too...

Quoted 24 lines
hw/char/virtio-console.c +20 -0
@@ -163,6 +177,37 @@ static void chr_event(void *opaque, int event)
     }
 }
 
+
+static void qga_message(JSONMessageParser *parser, GQueue *tokens)
+{
+    /* VirtConsole *vcon = container_of(parser, VirtConsole, parser); */
+    QObject *obj;
+    QDict *msg, *data;
+    const char *event;
+
+    obj = json_parser_parse(tokens, NULL);
+    msg = qobject_to_qdict(obj);
+    if (!msg) {
+        error_report("JSON parsing failed");
+        return;
+    }
+
+    event = qdict_get_try_str(msg, "event");
+    data = qdict_get_qdict(msg, "data");
+    if (event && g_str_equal(event, "VMDUMP_INFO") && data) {
+        dump_info.received = true;
+        if (qdict_haskey(data, "phys-base")) {

hw/char/virtio-console.c static void chr_event(void *opaque, int event) · line 209

Quoted 10 lines
hw/char/virtio-console.c +10 -0
+            dump_info.has_phys_base = true;
+            dump_info.phys_base = qdict_get_try_uint(data, "phys-base", 0);
+        }
+        if (qdict_haskey(data, "text")) {
+            dump_info.has_text = true;
+            dump_info.text = qdict_get_try_uint(data, "text", 0);
+        }
+        dump_info.vmcoreinfo = g_strdup(qdict_get_try_str(data, "vmcoreinfo"));
+    }
+}

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

A message that is not in the archive (sent off-list or not yet received): CAJ+F1C+2x=0pZxMz8FgxbkQD59zM2pngHKv7AT-hv-KA6xjN+Q@mail.gmail.com

#32 lore raw

Re: [Qemu-devel] [PATCH 17/21] virtio-channel: parse qga stream for VMDUMP_INFO event

Hi

Le 5 avr. 2017 18:13, "Daniel P. Berrange" <[email protected]> a écrit :

Quoted 8 lines · Marc-André Lureau

On virtio channel "org.qemu.guest_agent.0", parse the json stream until the VMDUMP_INFO is received and retrieve the dump details.

---
 include/sysemu/dump-info.h | 15 +++++++++++++
 dump.c                     |  3 +++
 hw/char/virtio-console.c   | 53 ++++++++++++++++++++++++++++++

++++++++++++++++

Quoted 68 lines
 3 files changed, 71 insertions(+)
 create mode 100644 include/sysemu/dump-info.h
include/sysemu/dump-info.h new file +15 -0
new file mode 100644
index 0000000000..fb1ddff9af
@@ -0,0 +1,15 @@
+#ifndef DUMP_INFO_H
+#define DUMP_INFO_H
+
+typedef struct DumpInfo {
+    bool received;
+    bool has_phys_base;
+    uint64_t phys_base;
+    bool has_text;
+    uint64_t text;
+    char *vmcoreinfo;
+} DumpInfo;
+
+extern DumpInfo dump_info;
+
+#endif /* DUMP_INFO_H */
dump.c +3 -0
index f7b80d856b..68b406459e 100644
@@ -20,6 +20,7 @@
 #include "monitor/monitor.h"
 #include "sysemu/kvm.h"
 #include "sysemu/dump.h"
+#include "sysemu/dump-info.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/memory_mapping.h"
 #include "sysemu/cpus.h"
@@ -38,6 +39,8 @@
 #define ELF_MACHINE_UNAME "Unknown"
 #endif
 
+DumpInfo dump_info = { 0, };
+
 uint16_t cpu_to_dump16(DumpState *s, uint16_t val)
 {
     if (s->dump_info.d_endian == ELFDATA2LSB) {
hw/char/virtio-console.c +4 -0
index 798d9b69fd..796b7c85aa 100644
@@ -16,6 +16,9 @@
 #include "trace.h"
 #include "hw/virtio/virtio-serial.h"
 #include "qapi-event.h"
+#include "qapi/qmp/json-streamer.h"
+#include "qapi/qmp/json-parser.h"
+#include "sysemu/dump-info.h"
 
 #define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport"
 #define VIRTIO_CONSOLE(obj) \
@@ -26,6 +29,7 @@ typedef struct VirtConsole {
 
     CharBackend chr;
     guint watch;
+    JSONMessageParser parser;
 } VirtConsole;
 
 /*

hw/char/virtio-console.c static ssize_t flush_buf(VirtIOSerialPort *port, · line 59

Quoted 7 lines
hw/char/virtio-console.c +4 -0
@@ -49,6 +53,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
     VirtConsole *vcon = VIRTIO_CONSOLE(port);
     ssize_t ret;
 
+    if (vcon->parser.emit &&
+        !dump_info.received) {
+        json_message_parser_feed(&vcon->parser, (const char *)buf, len);
+    }

[snip]

so we just continually feed data into the json parser until we see the event we care about....

What kind of denial of service protection does our JSON parser have. Now that QEMU is directly parsing JSON from QEMU guest agent, it is exposed to malicious attack by the guest agent.

eg what happens if the 'vmcoreinfo' string in the JSON doc received from the guest ends up being 10GB in size ? Is that going to cause our JSON parser to allocate QString which is 10GB in size which we'll further try to strdup just below too...

I haven't done research on our parsing robustness, but it's not the most complicated task qemu has. The alternative is to have a fixed size message on a different virtio port. But again, once we have a kernel alternative (pstore?) we should switch.

Quoted 16 lines
hw/char/virtio-console.c +12 -0
@@ -163,6 +177,37 @@ static void chr_event(void *opaque, int event)
     }
 }
 
+
+static void qga_message(JSONMessageParser *parser, GQueue *tokens)
+{
+    /* VirtConsole *vcon = container_of(parser, VirtConsole, parser); */
+    QObject *obj;
+    QDict *msg, *data;
+    const char *event;
+
+    obj = json_parser_parse(tokens, NULL);
+    msg = qobject_to_qdict(obj);
+    if (!msg) {
+        error_report("JSON parsing failed");

hw/char/virtio-console.c static void chr_event(void *opaque, int event) · line 201

Quoted 10 lines
hw/char/virtio-console.c +10 -0
+        return;
+    }
+
+    event = qdict_get_try_str(msg, "event");
+    data = qdict_get_qdict(msg, "data");
+    if (event && g_str_equal(event, "VMDUMP_INFO") && data) {
+        dump_info.received = true;
+        if (qdict_haskey(data, "phys-base")) {
+            dump_info.has_phys_base = true;
+            dump_info.phys_base = qdict_get_try_uint(data, "phys-base",

0);

hw/char/virtio-console.c static void chr_event(void *opaque, int event)

Quoted 6 lines
hw/char/virtio-console.c +6 -0
+        }
+        if (qdict_haskey(data, "text")) {
+            dump_info.has_text = true;
+            dump_info.text = qdict_get_try_uint(data, "text", 0);
+        }
+        dump_info.vmcoreinfo = g_strdup(qdict_get_try_str(data,

"vmcoreinfo"));

hw/char/virtio-console.c static void chr_event(void *opaque, int event) · line 209

Quoted 2 lines
hw/char/virtio-console.c +2 -0
+    }
+}

Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/
:|
|: http://libvirt.org -o- http://virt-manager.org
:|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/
:|

#33 lore raw

Re: [Qemu-devel] [PATCH 17/21] virtio-channel: parse qga stream for VMDUMP_INFO event

In reply to Daniel P. Berrange
Quoted 6 lines · Daniel P. Berrange
Quoted 3 lines · Marc-André Lureau

On virtio channel "org.qemu.guest_agent.0", parse the json stream until the VMDUMP_INFO is received and retrieve the dump details.

Quoted 6 lines

so we just continually feed data into the json parser until we see the event we care about....

What kind of denial of service protection does our JSON parser have. Now that QEMU is directly parsing JSON from QEMU guest agent, it is exposed to malicious attack by the guest agent.

Our JSON parser rejects input that exceeds various limits:

json-lexer.c:
#define MAX_TOKEN_SIZE (64ULL << 20)

json-streamer.c:
#define MAX_TOKEN_SIZE (64ULL << 20)
#define MAX_TOKEN_COUNT (2ULL << 20)
#define MAX_NESTING (1ULL << 10)

Quoted 5 lines

eg what happens if the 'vmcoreinfo' string in the JSON doc received from the guest ends up being 10GB in size ? Is that going to cause our JSON parser to allocate QString which is 10GB in size which we'll further try to strdup just below too...

The parser will have rejected the guest data long before the 10GB mark. But our error recovery from that rejection may not be ideal...

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#34 lore raw

Re: [Qemu-devel] [PATCH 17/21] virtio-channel: parse qga stream for VMDUMP_INFO event

Quoted 25 lines · Eric Blake
Quoted 6 lines · Daniel P. Berrange
Quoted 3 lines · Marc-André Lureau

On virtio channel "org.qemu.guest_agent.0", parse the json stream until the VMDUMP_INFO is received and retrieve the dump details.

Quoted 6 lines

so we just continually feed data into the json parser until we see the event we care about....

What kind of denial of service protection does our JSON parser have. Now that QEMU is directly parsing JSON from QEMU guest agent, it is exposed to malicious attack by the guest agent.

Our JSON parser rejects input that exceeds various limits:

json-lexer.c:
#define MAX_TOKEN_SIZE (64ULL << 20)

json-streamer.c:
#define MAX_TOKEN_SIZE (64ULL << 20)
#define MAX_TOKEN_COUNT (2ULL << 20)
#define MAX_NESTING (1ULL << 10)

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

eg what happens if the 'vmcoreinfo' string in the JSON doc received from the guest ends up being 10GB in size ? Is that going to cause our JSON parser to allocate QString which is 10GB in size which we'll further try to strdup just below too...

The parser will have rejected the guest data long before the 10GB mark. But our error recovery from that rejection may not be ideal...

Ok, good, we should be pretty much ok then

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#35 lore raw

PATCH 18/21 dump: use qga VMDUMP_INFO for ELF dump

In reply to Marc-André Lureau

Add vmcoreinfo ELF note.

NUMBRE(phys_base) in vmcoreinfo has only been recently introduced in Linux 4.10 ("kexec: export the value of phys_base instead of symbol address"). To accomadate for older kernels, modify the vmcoreinfo to add the new fields and help newer crash that will use it.

---
 include/sysemu/dump.h |   2 +
 dump.c                | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)
include/sysemu/dump.h +2 -0
index ef931be469..ff0e9894b7 100644
@@ -191,6 +191,8 @@ typedef struct DumpState {
                                   * this could be used to calculate
                                   * how much work we have
                                   * finished. */
+    uint8_t *vmcoreinfo;
+    size_t vmcoreinfo_size;
 } DumpState;
 
 uint16_t cpu_to_dump16(DumpState *s, uint16_t val);
dump.c +133 -0

181 lines not on this page · raw message

Signature · 1 line
2.12.0.191.gc5d8de91d
#36 lore raw

PATCH 19/21 kdump: write vmcoreinfo in header

In reply to Marc-André Lureau
---
 dump.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 4 deletions(-)
dump.c +44 -4
index 0ebfb5471a..bf88cb362b 100644
@@ -785,8 +785,9 @@ static void create_header32(DumpState *s, Error **errp)
     uint32_t sub_hdr_size;
     uint32_t bitmap_blocks;
     uint32_t status = 0;
-    uint64_t offset_note;
+    uint64_t offset_note, offset_vmcoreinfo, size_vmcoreinfo = 0;
     Error *local_err = NULL;
+    uint8_t *vmcoreinfo = NULL;
 
     /* write common header, the version of kdump-compressed format is 6th */
     size = sizeof(DiskDumpHeader32);
@@ -835,7 +836,18 @@ static void create_header32(DumpState *s, Error **errp)
     kh->phys_base = cpu_to_dump32(s, s->dump_info.phys_base);
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
 
-    offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
+    offset_vmcoreinfo = DISKDUMP_HEADER_BLOCKS * block_size + size;
+    if (s->vmcoreinfo) {
+        uint64_t hsize, name_size;
+
+        get_note_sizes(s, s->vmcoreinfo, &hsize, &name_size, &size_vmcoreinfo);
+        vmcoreinfo =
+            s->vmcoreinfo + ((hsize + 3) / 4 + (name_size + 3) / 4) * 4;
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
+        kh->size_vmcoreinfo = cpu_to_dump32(s, size_vmcoreinfo);
+    }
+
+    offset_note = offset_vmcoreinfo + size_vmcoreinfo;
     kh->offset_note = cpu_to_dump64(s, offset_note);
     kh->note_size = cpu_to_dump32(s, s->note_size);
 
@@ -845,6 +857,14 @@ static void create_header32(DumpState *s, Error **errp)
         goto out;
     }
 
+    if (vmcoreinfo) {
+        if (write_buffer(s->fd, offset_vmcoreinfo, vmcoreinfo,
+                         size_vmcoreinfo) < 0) {
+            error_setg(errp, "dump: failed to vmcoreinfo");
+            goto out;
+        }
+    }
+
     /* write note */
     s->note_buf = g_malloc0(s->note_size);
     s->note_buf_offset = 0;
@@ -885,8 +905,9 @@ static void create_header64(DumpState *s, Error **errp)
     uint32_t sub_hdr_size;
     uint32_t bitmap_blocks;
     uint32_t status = 0;
-    uint64_t offset_note;
+    uint64_t offset_note, offset_vmcoreinfo, size_vmcoreinfo = 0;
     Error *local_err = NULL;
+    uint8_t *vmcoreinfo = NULL;
 
     /* write common header, the version of kdump-compressed format is 6th */
     size = sizeof(DiskDumpHeader64);
@@ -935,7 +956,18 @@ static void create_header64(DumpState *s, Error **errp)
     kh->phys_base = cpu_to_dump64(s, s->dump_info.phys_base);
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
 
-    offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
+    offset_vmcoreinfo = DISKDUMP_HEADER_BLOCKS * block_size + size;
+    if (s->vmcoreinfo) {
+        uint64_t hsize, name_size;
+
+        get_note_sizes(s, s->vmcoreinfo, &hsize, &name_size, &size_vmcoreinfo);
+        vmcoreinfo =
+            s->vmcoreinfo + ((hsize + 3) / 4 + (name_size + 3) / 4) * 4;
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
+        kh->size_vmcoreinfo = cpu_to_dump64(s, size_vmcoreinfo);
+    }
+
+    offset_note = offset_vmcoreinfo + size_vmcoreinfo;
     kh->offset_note = cpu_to_dump64(s, offset_note);
     kh->note_size = cpu_to_dump64(s, s->note_size);
 
@@ -945,6 +977,14 @@ static void create_header64(DumpState *s, Error **errp)
         goto out;
     }
 
+    if (vmcoreinfo) {
+        if (write_buffer(s->fd, offset_vmcoreinfo, vmcoreinfo,
+                         size_vmcoreinfo) < 0) {
+            error_setg(errp, "dump: failed to vmcoreinfo");
+            goto out;
+        }
+    }
+
     /* write note */
     s->note_buf = g_malloc0(s->note_size);
     s->note_buf_offset = 0;
Signature · 1 line
2.12.0.191.gc5d8de91d
#37 lore raw

PATCH 20/21 scripts/dump-guest-memory.py: fix int128_get64 on recent gcc

In reply to Marc-André Lureau

The Int128 is no longer a struct, reaching a python exception:
Python Exception <class 'gdb.error'> Attempt to extract a component of a value that is not a (null).:

Replace struct access with a cast to uint64 instead.

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1427466

---
 scripts/dump-guest-memory.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
scripts/dump-guest-memory.py +12 -2
index 9956fc036c..f7c6635f15 100644
@@ -314,8 +314,18 @@ def get_arch_phdr(endianness, elfclass):
 def int128_get64(val):
     """Returns low 64bit part of Int128 struct."""
 
-    assert val["hi"] == 0
-    return val["lo"]
+    try:
+        assert val["hi"] == 0
+        return val["lo"]
+    except gdb.error:
+        u64t = gdb.lookup_type('uint64_t').array(2)
+        u64 = val.cast(u64t)
+        if sys.byteorder == 'little':
+            assert u64[1] == 0
+            return u64[0]
+        else:
+            assert u64[0] == 0
+            return u64[1]
 
 
 def qlist_foreach(head, field_str):
Signature · 1 line
2.12.0.191.gc5d8de91d
#38 lore raw

PATCH 21/21 scripts/dump-guest-memory.py: add VMCOREINFO

In reply to Marc-André Lureau
---
 scripts/dump-guest-memory.py | 52 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
scripts/dump-guest-memory.py +52 -0
index f7c6635f15..0ce32b2a3f 100644
@@ -120,6 +120,33 @@ class ELF(object):
         self.segments[0].p_filesz += ctypes.sizeof(note)
         self.segments[0].p_memsz += ctypes.sizeof(note)
 
+
+    def add_vmcoreinfo_note(self, vmcoreinfo, phys_base=None):
+        """Adds a vmcoreinfo note to the ELF."""
+        chead = type(get_arch_note(self.endianness, 0, 0))
+        header = chead.from_buffer_copy(vmcoreinfo[0:ctypes.sizeof(chead)])
+        note = get_arch_note(self.endianness,
+                             header.n_namesz - 1, header.n_descsz)
+        ctypes.memmove(ctypes.pointer(note), vmcoreinfo, ctypes.sizeof(note))
+        header_size = ctypes.sizeof(note) - header.n_descsz
+
+        if phys_base:
+            desc = bytearray(note.n_desc).decode().split()
+            if not next((v for v in desc if v.startswith('NUMBER(phys_base)=')),
+                        False):
+                desc.append('NUMBER(phys_base)=%ld' % phys_base)
+            desc = "\n".join(desc) + '\n'
+            descsz = (len(desc) + 3) // 4 * 4
+            desc += '\0' * (descsz - len(desc))
+            note = get_arch_note(self.endianness, header.n_namesz - 1, descsz)
+            ctypes.memmove(ctypes.pointer(note), vmcoreinfo, header_size)
+            note.n_descsz = descsz
+            ctypes.memmove(note.n_desc, desc.encode(), descsz)
+
+        self.notes.append(note)
+        self.segments[0].p_filesz += ctypes.sizeof(note)
+        self.segments[0].p_memsz += ctypes.sizeof(note)
+
     def add_segment(self, p_type, p_paddr, p_size):
         """Adds a segment to the elf."""
 
@@ -505,6 +532,30 @@ shape and this command should mostly work."""
                 cur += chunk_size
                 left -= chunk_size
 
+    def get_vmcoreinfo(self):
+        qemu_core = gdb.inferiors()[0]
+
+        try:
+            coreinfo = gdb.parse_and_eval("dump_info.vmcoreinfo")
+        except gdb.error:
+            return
+
+        if coreinfo == 0:
+            return
+
+        phys_base = None
+        has_phys_base = gdb.parse_and_eval("dump_info.has_phys_base")
+        if has_phys_base:
+            phys_base = int(gdb.parse_and_eval("dump_info.phys_base"))
+
+        addr, size = [int(val, 16) for val in coreinfo.string().split()]
+        for block in self.guest_phys_blocks:
+            if block["target_start"] <= addr < block["target_end"]:
+                haddr = block["host_addr"] + (addr - block["target_start"])
+                vmcoreinfo = qemu_core.read_memory(haddr, size)
+                self.elf.add_vmcoreinfo_note(vmcoreinfo.tobytes(), phys_base)
+                return
+
     def invoke(self, args, from_tty):
         """Handles command invocation from gdb."""
 
@@ -518,6 +569,7 @@ shape and this command should mostly work."""
 
         self.elf = ELF(argv[1])
         self.guest_phys_blocks = get_guest_phys_blocks()
+        self.get_vmcoreinfo()
 
         with open(argv[0], "wb") as vmcore:
             self.dump_init(vmcore)
Signature · 1 line
2.12.0.191.gc5d8de91d
#39 lore raw
In reply to Marc-André Lureau
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.

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 00/21] WIP: dump: add kaslr support (for after 2.9)
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=16
make docker-test-quick@centos6
make docker-test-mingw@fedora
make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
c4258ed scripts/dump-guest-memory.py: add VMCOREINFO 12f2cd9 scripts/dump-guest-memory.py: fix int128_get64 on recent gcc 53ab76c kdump: write vmcoreinfo in header
f856c12 dump: use qga VMDUMP_INFO for ELF dump
2ef806a virtio-channel: parse qga stream for VMDUMP_INFO event dcebb93 qga: emit VMDUMP_INFO event
c1774df qga: register event emit function
a0e47b1 qga: add and populate VMDumpInfo
86a1fa2 qga: report error on keyfile dump error
9137503 test-qga: drop everything until guest-sync 96cac9b qdict: learn to lookup quint
39f3ad6 Use uint property getter/setter where appropriate 98547af qdev: use appropriate type
be8b857 qdev: use int and uint properties
e7b693f object: add uint property setter/getter
ded1bba json: learn to parse uint64 numbers
222ed0a qapi: update the qobject visitor to use QUInt f71f11e qobject: add quint type
0888419 object: fix potential leak in getters
47fff1e pci-host: use more specific type names
2de8460 qapi: add info comment for generated types

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into 'dtc'...
Submodule path 'dtc': checked out 'fa8bc7f928ac25f23532afc8beb2073efc8fb063'
BUILD centos6
make[1]: Entering directory `/var/tmp/patchew-tester-tmp-g_4q0obe/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=30eb98410084
TERM=xterm
MAKEFLAGS= -j16
HISTSIZE=1000
J=16
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
Archipelago support no

gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
QOM debugging     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
mkdir -p dtc/libfdt
mkdir -p dtc/tests

  GEN     x86_64-softmmu/config-devices.mak.tmp
  GEN     aarch64-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     qmp-introspect.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-tcg-tracers.h
  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     x86_64-softmmu/config-devices.mak
  GEN     tests/test-qapi-event.h
  GEN     aarch64-softmmu/config-devices.mak
  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     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/sparc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/ppc/trace.h
  GEN     qom/trace.h
  GEN     linux-user/trace.h
  GEN     config-all-devices.mak
  GEN     qapi/trace.h

DEP /tmp/qemu-test/src/dtc/tests/trees.S
DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
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/truncated_property.c DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.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/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/addr_size_cells.c DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.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_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/tests/get_mem_rsv.c DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.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_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/fdtput.c
DEP /tmp/qemu-test/src/dtc/util.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
DEP /tmp/qemu-test/src/dtc/srcpos.c
BISON dtc-parser.tab.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/livetree.c
DEP /tmp/qemu-test/src/dtc/flattree.c
DEP /tmp/qemu-test/src/dtc/fstree.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
CHK version_gen.h
UPD version_gen.h
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
make[1]: flex: Command not found
DEP /tmp/qemu-test/src/dtc/util.c
LEX convert-dtsv0-lexer.lex.c
make[1]: flex: Command not found
BISON dtc-parser.tab.c
LEX dtc-lexer.lex.c
make[1]: bison: Command not found
make[1]: flex: Command not found
CC libfdt/fdt.o
CC libfdt/fdt_ro.o
CC libfdt/fdt_rw.o
CC libfdt/fdt_wip.o
CC libfdt/fdt_empty_tree.o
CC libfdt/fdt_sw.o
CC libfdt/fdt_strerror.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 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
make[1]: flex: Command not found

  CC      tests/qemu-iotests/socket_scm_helper.o
  GEN     qga/qapi-generated/qga-qapi-types.h
  GEN     qga/qapi-generated/qga-qapi-visit.h
  GEN     qga/qapi-generated/qga-qmp-commands.h
  GEN     qga/qapi-generated/qga-qapi-visit.c
  GEN     qga/qapi-generated/qga-qapi-event.h
  GEN     qga/qapi-generated/qga-qapi-types.c
  GEN     qga/qapi-generated/qga-qmp-marshal.c
  GEN     qga/qapi-generated/qga-qapi-event.c
  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     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/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     qmp-introspect.c
  GEN     qapi-types.c
  GEN     qapi-visit.c
  GEN     qapi-event.c
  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/qint.o
  CC      qobject/quint.o
  CC      qobject/qstring.o
  CC      qobject/qdict.o
  CC      qobject/qlist.o
  CC      qobject/qfloat.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/control.o
  CC      trace/qmp.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/async.o
  CC      util/aiocb.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/envlist.o
  CC      util/path.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/crc32c.o
  CC      util/uuid.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      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/blk-commit-all.o
  CC      stubs/blockdev-close-all-bdrv-states.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/machine-init-done.o
  CC      stubs/monitor.o
  CC      stubs/migr-blocker.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/vm-stop.o
  CC      stubs/vmstate.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      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      replication.o
  CC      qemu-io-cmds.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      page_cache.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
  GEN     qmp-marshal.c
  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/msmouse.o
  CC      backends/wctablet.o
  CC      backends/testdev.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      disas/arm.o
  CC      disas/i386.o
  CC      fsdev/qemu-fsdev-dummy.o
  CC      fsdev/qemu-fsdev-throttle.o
  CC      fsdev/qemu-fsdev-opts.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/gus.o
  CC      hw/audio/adlib.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/lm4549.o
  CC      hw/audio/marvell_88w8618.o
  CC      hw/audio/pl041.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-properties.o
  CC      hw/core/qdev.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/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/input/hid.o
  CC      hw/ide/ich.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/rtl8139.o
  CC      hw/net/vmxnet3.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/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/lsi53c895a.o
  CC      hw/scsi/scsi-bus.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-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/colo-comm.o
  CC      migration/colo.o
  CC      migration/colo-failover.o
  CC      migration/vmstate.o
  CC      migration/qemu-file.o
  CC      migration/qemu-file-channel.o
  CC      migration/xbzrle.o
  CC      migration/qjson.o
  CC      migration/postcopy-ram.o
  CC      migration/block.o
  CC      net/net.o
  CC      net/checksum.o
  CC      net/queue.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/tap.o
  CC      net/vhost-user.o
  CC      net/tap-linux.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      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
  CC      replay/replay-snapshot.o
  CC      replay/replay-net.o
  CC      replay/replay-audio.o
  CC      slirp/cksum.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      slirp/if.o
  CC      slirp/ip_icmp.o
  CC      slirp/ip6_icmp.o
  CC      slirp/ip6_input.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/sbuf.o
  CC      slirp/socket.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      ui/console.o
  CC      ui/keymaps.o
  CC      ui/cursor.o
  CC      ui/qemu-pixman.o
  CC      ui/input.o
  CC      ui/input-keymap.o
  CC      ui/input-legacy.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

/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/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-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
  LINK    tests/qemu-iotests/socket_scm_helper
  CC      qga/commands.o
  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
  CC      qga/commands-posix.o
  CC      qga/channel-posix.o
  CC      qga/qapi-generated/qga-qapi-types.o
  AS      optionrom/multiboot.o
  AS      optionrom/linuxboot.o
  CC      optionrom/linuxboot_dma.o
  AS      optionrom/kvmvapic.o
  CC      qga/qapi-generated/qga-qapi-visit.o
cc unrecognized option '-no-integrated-as'
cc unrecognized option '-no-integrated-as'
  CC      qga/qapi-generated/qga-qmp-marshal.o
  BUILD   optionrom/multiboot.img
  BUILD   optionrom/linuxboot.img
  BUILD   optionrom/linuxboot_dma.img
  BUILD   optionrom/kvmvapic.img
  CC      qga/qapi-generated/qga-qapi-event.o
  BUILD   optionrom/multiboot.raw
  BUILD   optionrom/linuxboot.raw
  BUILD   optionrom/linuxboot_dma.raw
  BUILD   optionrom/kvmvapic.raw
  SIGN    optionrom/multiboot.bin
  SIGN    optionrom/linuxboot.bin
  SIGN    optionrom/linuxboot_dma.bin
  SIGN    optionrom/kvmvapic.bin
  CC      qmp-introspect.o
  AR      libqemustub.a
  CC      qapi-types.o
  CC      qapi-visit.o
  CC      qapi-event.o
  CC      qemu-img.o
  CC      trace-root.o
  CC      qmp-marshal.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      hw/block/trace.o
  CC      hw/char/trace.o
  CC      hw/block/dataplane/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/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
  AR      libqemuutil.a
  LINK    qemu-ga
  LINK    ivshmem-client
  LINK    ivshmem-server
  LINK    qemu-nbd
  LINK    qemu-img
  LINK    qemu-io
  LINK    qemu-bridge-helper
  GEN     aarch64-softmmu/hmp-commands.h
  GEN     aarch64-softmmu/hmp-commands-info.h
  GEN     aarch64-softmmu/config-target.h
  GEN     x86_64-softmmu/hmp-commands.h
  GEN     x86_64-softmmu/hmp-commands-info.h
  GEN     x86_64-softmmu/config-target.h
  CC      aarch64-softmmu/exec.o
  CC      aarch64-softmmu/translate-all.o
  CC      aarch64-softmmu/cpu-exec.o
  CC      aarch64-softmmu/translate-common.o
  CC      aarch64-softmmu/cpu-exec-common.o
  CC      aarch64-softmmu/tcg/tcg.o
  CC      aarch64-softmmu/tcg/tcg-op.o
  CC      aarch64-softmmu/tcg/optimize.o
  CC      aarch64-softmmu/tcg/tcg-common.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      x86_64-softmmu/exec.o
  CC      aarch64-softmmu/cpus.o
  CC      aarch64-softmmu/monitor.o
  CC      x86_64-softmmu/translate-all.o
  CC      aarch64-softmmu/gdbstub.o
  CC      aarch64-softmmu/balloon.o
  CC      x86_64-softmmu/cpu-exec.o
  CC      x86_64-softmmu/translate-common.o
  CC      aarch64-softmmu/ioport.o
  CC      x86_64-softmmu/cpu-exec-common.o
  CC      x86_64-softmmu/tcg/tcg.o
  CC      x86_64-softmmu/tcg/tcg-op.o
  CC      x86_64-softmmu/tcg/optimize.o
  CC      x86_64-softmmu/tcg/tcg-common.o
  CC      x86_64-softmmu/fpu/softfloat.o
  CC      aarch64-softmmu/numa.o
  CC      aarch64-softmmu/qtest.o
  CC      aarch64-softmmu/bootdevice.o
  CC      aarch64-softmmu/memory.o
  CC      aarch64-softmmu/cputlb.o
  CC      x86_64-softmmu/disas.o
  CC      aarch64-softmmu/memory_mapping.o
  CC      aarch64-softmmu/dump.o
  CC      aarch64-softmmu/migration/ram.o
  CC      x86_64-softmmu/tcg-runtime.o
  CC      x86_64-softmmu/arch_init.o
  CC      x86_64-softmmu/hax-stub.o
  CC      aarch64-softmmu/migration/savevm.o
  CC      x86_64-softmmu/cpus.o
  CC      x86_64-softmmu/monitor.o
  CC      x86_64-softmmu/gdbstub.o
  CC      aarch64-softmmu/xen-common-stub.o
  CC      aarch64-softmmu/xen-hvm-stub.o
  CC      x86_64-softmmu/balloon.o
  CC      x86_64-softmmu/ioport.o
  CC      aarch64-softmmu/hw/adc/stm32f2xx_adc.o
  CC      aarch64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/numa.o
  CC      aarch64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/hw/char/exynos4210_uart.o
  CC      aarch64-softmmu/hw/char/omap_uart.o
  CC      x86_64-softmmu/qtest.o
  CC      x86_64-softmmu/bootdevice.o
  CC      x86_64-softmmu/kvm-all.o
  CC      x86_64-softmmu/memory.o
  CC      aarch64-softmmu/hw/char/digic-uart.o
  CC      x86_64-softmmu/cputlb.o
  CC      x86_64-softmmu/memory_mapping.o
  CC      x86_64-softmmu/dump.o
  CC      x86_64-softmmu/migration/ram.o
  CC      x86_64-softmmu/migration/savevm.o
  CC      aarch64-softmmu/hw/char/stm32f2xx_usart.o
  CC      x86_64-softmmu/xen-common-stub.o
  CC      aarch64-softmmu/hw/char/bcm2835_aux.o
  CC      x86_64-softmmu/xen-hvm-stub.o
  CC      aarch64-softmmu/hw/char/virtio-serial-bus.o
  CC      x86_64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/hw/core/nmi.o
  CC      x86_64-softmmu/hw/char/virtio-serial-bus.o
  CC      x86_64-softmmu/hw/core/nmi.o
  CC      aarch64-softmmu/hw/core/generic-loader.o
  CC      aarch64-softmmu/hw/core/null-machine.o
  CC      aarch64-softmmu/hw/cpu/arm11mpcore.o
  CC      aarch64-softmmu/hw/cpu/realview_mpcore.o
  CC      x86_64-softmmu/hw/core/generic-loader.o
  CC      x86_64-softmmu/hw/core/null-machine.o
  CC      x86_64-softmmu/hw/cpu/core.o
  CC      x86_64-softmmu/hw/display/vga.o
  CC      aarch64-softmmu/hw/cpu/a9mpcore.o
  CC      aarch64-softmmu/hw/cpu/a15mpcore.o
  CC      x86_64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-3d.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-pci.o
  CC      x86_64-softmmu/hw/display/virtio-vga.o
  CC      x86_64-softmmu/hw/intc/apic.o
  CC      x86_64-softmmu/hw/intc/apic_common.o
  CC      x86_64-softmmu/hw/intc/ioapic.o
  CC      x86_64-softmmu/hw/isa/lpc_ich9.o
  CC      aarch64-softmmu/hw/cpu/core.o
  CC      aarch64-softmmu/hw/display/omap_dss.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      aarch64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/misc/vmport.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-3d.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-pci.o
  CC      x86_64-softmmu/hw/misc/ivshmem.o
  CC      x86_64-softmmu/hw/misc/pvpanic.o
  CC      aarch64-softmmu/hw/display/dpcd.o
  CC      x86_64-softmmu/hw/misc/edu.o
  CC      x86_64-softmmu/hw/misc/hyperv_testdev.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      aarch64-softmmu/hw/dma/soc_dma.o
  CC      aarch64-softmmu/hw/dma/pxa2xx_dma.o
  CC      x86_64-softmmu/hw/net/virtio-net.o
  CC      aarch64-softmmu/hw/gpio/omap_gpio.o
  CC      x86_64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/dma/bcm2835_dma.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi.o
  CC      x86_64-softmmu/hw/timer/mc146818rtc.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      x86_64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/input/pxa2xx_keypad.o
  CC      aarch64-softmmu/hw/input/tsc210x.o
  CC      aarch64-softmmu/hw/intc/armv7m_nvic.o
  CC      x86_64-softmmu/hw/vfio/platform.o
  CC      x86_64-softmmu/hw/vfio/pci.o
  CC      x86_64-softmmu/hw/vfio/pci-quirks.o
  CC      x86_64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/intc/exynos4210_gic.o
  CC      x86_64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/intc/exynos4210_combiner.o
  CC      aarch64-softmmu/hw/intc/omap_intc.o
  CC      aarch64-softmmu/hw/intc/bcm2835_ic.o
  CC      x86_64-softmmu/hw/virtio/virtio-balloon.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      aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
  CC      aarch64-softmmu/hw/misc/ivshmem.o
  CC      x86_64-softmmu/hw/virtio/vhost.o
  CC      x86_64-softmmu/hw/virtio/vhost-backend.o
  CC      aarch64-softmmu/hw/misc/arm_sysctl.o
  CC      aarch64-softmmu/hw/misc/cbus.o
  CC      x86_64-softmmu/hw/virtio/vhost-user.o
  CC      x86_64-softmmu/hw/virtio/vhost-vsock.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/misc/exynos4210_pmu.o
  CC      aarch64-softmmu/hw/misc/exynos4210_clk.o
  CC      aarch64-softmmu/hw/misc/imx_ccm.o
  CC      aarch64-softmmu/hw/misc/imx31_ccm.o
  CC      x86_64-softmmu/hw/i386/multiboot.o
  CC      aarch64-softmmu/hw/misc/imx25_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6_ccm.o
  CC      x86_64-softmmu/hw/i386/pc.o
  CC      x86_64-softmmu/hw/i386/pc_piix.o
  CC      aarch64-softmmu/hw/misc/mst_fpga.o
  CC      aarch64-softmmu/hw/misc/omap_clk.o
  CC      aarch64-softmmu/hw/misc/imx6_src.o
  CC      aarch64-softmmu/hw/misc/omap_gpmc.o
  CC      x86_64-softmmu/hw/i386/pc_q35.o
  CC      x86_64-softmmu/hw/i386/pc_sysfw.o
  CC      x86_64-softmmu/hw/i386/x86-iommu.o
  CC      aarch64-softmmu/hw/misc/omap_l4.o
  CC      aarch64-softmmu/hw/misc/omap_sdrc.o
  CC      x86_64-softmmu/hw/i386/intel_iommu.o
  CC      x86_64-softmmu/hw/i386/amd_iommu.o
  CC      aarch64-softmmu/hw/misc/omap_tap.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      x86_64-softmmu/hw/i386/kvmvapic.o
  CC      aarch64-softmmu/hw/misc/zynq_slcr.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:1055: warning: ‘pch_rev_id’ may be used uninitialized in this function
  CC      x86_64-softmmu/hw/i386/acpi-build.o
  CC      aarch64-softmmu/hw/misc/zynq-xadc.o
  CC      x86_64-softmmu/hw/i386/pci-assign-load-rom.o
  CC      aarch64-softmmu/hw/misc/stm32f2xx_syscfg.o
  CC      aarch64-softmmu/hw/misc/edu.o
  CC      x86_64-softmmu/hw/i386/kvm/apic.o
  CC      x86_64-softmmu/hw/i386/kvm/clock.o
  CC      aarch64-softmmu/hw/misc/auxbus.o
  CC      x86_64-softmmu/hw/i386/kvm/i8259.o
  CC      x86_64-softmmu/hw/i386/kvm/ioapic.o
  CC      aarch64-softmmu/hw/misc/aspeed_scu.o
  CC      x86_64-softmmu/hw/i386/kvm/i8254.o
  CC      aarch64-softmmu/hw/misc/aspeed_sdmc.o
  CC      x86_64-softmmu/hw/i386/kvm/pci-assign.o
  CC      aarch64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/target/i386/translate.o
  CC      x86_64-softmmu/target/i386/helper.o
  CC      aarch64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/pcmcia/pxa2xx.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/target/i386/cpu.o
  CC      x86_64-softmmu/target/i386/bpt_helper.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi.o
  CC      x86_64-softmmu/target/i386/excp_helper.o
  CC      x86_64-softmmu/target/i386/fpu_helper.o
  CC      aarch64-softmmu/hw/sd/omap_mmc.o
  CC      x86_64-softmmu/target/i386/cc_helper.o
  CC      x86_64-softmmu/target/i386/int_helper.o
  CC      aarch64-softmmu/hw/sd/pxa2xx_mmci.o
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      aarch64-softmmu/hw/sd/bcm2835_sdhost.o
  CC      aarch64-softmmu/hw/ssi/omap_spi.o
  CC      x86_64-softmmu/target/i386/smm_helper.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:498: warning: ‘notify_method’ may be used uninitialized in this function
  CC      aarch64-softmmu/hw/ssi/imx_spi.o
  CC      x86_64-softmmu/target/i386/misc_helper.o
  CC      x86_64-softmmu/target/i386/mem_helper.o
  CC      x86_64-softmmu/target/i386/seg_helper.o
  CC      aarch64-softmmu/hw/timer/exynos4210_mct.o
  CC      x86_64-softmmu/target/i386/mpx_helper.o
  CC      aarch64-softmmu/hw/timer/exynos4210_pwm.o
  CC      x86_64-softmmu/target/i386/gdbstub.o
  CC      aarch64-softmmu/hw/timer/exynos4210_rtc.o
  CC      x86_64-softmmu/target/i386/machine.o
  CC      aarch64-softmmu/hw/timer/omap_gptimer.o
  CC      x86_64-softmmu/target/i386/arch_memory_mapping.o
  CC      x86_64-softmmu/target/i386/arch_dump.o
  CC      x86_64-softmmu/target/i386/monitor.o
  CC      x86_64-softmmu/target/i386/kvm.o
  CC      x86_64-softmmu/target/i386/hyperv.o
  CC      aarch64-softmmu/hw/timer/omap_synctimer.o
  GEN     trace/generated-helpers.c
  CC      x86_64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/hw/timer/pxa2xx_timer.o
  CC      aarch64-softmmu/hw/timer/digic-timer.o
  CC      aarch64-softmmu/hw/timer/allwinner-a10-pit.o
  CC      aarch64-softmmu/hw/usb/tusb6010.o
  CC      x86_64-softmmu/trace/generated-helpers.o
  CC      aarch64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/vfio/pci.o
  CC      aarch64-softmmu/hw/vfio/pci-quirks.o
  CC      aarch64-softmmu/hw/vfio/platform.o
  CC      aarch64-softmmu/hw/vfio/calxeda-xgmac.o
  CC      aarch64-softmmu/hw/vfio/amd-xgbe.o
  CC      aarch64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/virtio/virtio-balloon.o
  CC      aarch64-softmmu/hw/virtio/vhost.o
  CC      aarch64-softmmu/hw/virtio/vhost-backend.o
  CC      aarch64-softmmu/hw/virtio/vhost-user.o
  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/mainstone.o
  CC      aarch64-softmmu/hw/arm/musicpal.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/bcm2836.o
  CC      aarch64-softmmu/hw/arm/raspi.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/arch_dump.o
  CC      aarch64-softmmu/target/arm/monitor.o
  CC      aarch64-softmmu/target/arm/kvm-stub.o
  CC      aarch64-softmmu/target/arm/translate.o
  CC      aarch64-softmmu/target/arm/op_helper.o
  CC      aarch64-softmmu/target/arm/helper.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/cpu64.o
  CC      aarch64-softmmu/target/arm/translate-a64.o
  CC      aarch64-softmmu/target/arm/helper-a64.o
  CC      aarch64-softmmu/target/arm/gdbstub64.o
  CC      aarch64-softmmu/target/arm/crypto_helper.o
  CC      aarch64-softmmu/target/arm/arm-powerctl.o
  GEN     trace/generated-helpers.c
  CC      aarch64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/trace/generated-helpers.o
  LINK    x86_64-softmmu/qemu-system-x86_64

/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘handle_shri_with_rndacc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:6359: 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:8086: warning: ‘rmode’ may be used uninitialized in this function
LINK aarch64-softmmu/qemu-system-aarch64
LEX convert-dtsv0-lexer.lex.c
make[1]: BISON dtc-parser.tab.c
flex: Command not found
make[1]: bison: Command not found
LEX dtc-lexer.lex.c
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-clash.out
  TEST    tests/qapi-schema/alternate-conflict-dict.out
  TEST    tests/qapi-schema/alternate-conflict-string.out
  TEST    tests/qapi-schema/alternate-empty.out
  TEST    tests/qapi-schema/alternate-nested.out
  TEST    tests/qapi-schema/alternate-unknown.out
  TEST    tests/qapi-schema/args-any.out
  TEST    tests/qapi-schema/args-alternate.out
  TEST    tests/qapi-schema/args-array-unknown.out
  TEST    tests/qapi-schema/args-array-empty.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-union.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/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/comments.out
  TEST    tests/qapi-schema/doc-bad-args.out
  TEST    tests/qapi-schema/doc-bad-symbol.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-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-colon.out
  TEST    tests/qapi-schema/doc-missing-space.out
  TEST    tests/qapi-schema/doc-missing-expr.out
  TEST    tests/qapi-schema/doc-optional.out
  TEST    tests/qapi-schema/double-data.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-clash-member.out
  TEST    tests/qapi-schema/flat-union-base-union.out
  TEST    tests/qapi-schema/flat-union-empty.out
  TEST    tests/qapi-schema/flat-union-incomplete-branch.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-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/indented-expr.out
  TEST    tests/qapi-schema/include-simple.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-comma-object.out
  TEST    tests/qapi-schema/missing-type.out
  TEST    tests/qapi-schema/nested-struct-data.out
  TEST    tests/qapi-schema/non-objects.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-event.out
  TEST    tests/qapi-schema/redefined-type.out
  TEST    tests/qapi-schema/redefined-command.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-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
  CC      tests/check-qdict.o
  CC      tests/test-char.o
  CC      tests/check-qint.o
  CC      tests/check-qfloat.o
  CC      tests/check-qstring.o
  CC      tests/check-qlist.o
  CC      tests/check-qnull.o
  GEN     tests/test-qapi-visit.c
  CC      tests/check-qjson.o
  CC      tests/test-qobject-output-visitor.o
  GEN     tests/test-qmp-introspect.c
  GEN     tests/test-qapi-types.c
  GEN     tests/test-qapi-event.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
  CC      tests/rcutorture.o
/tmp/qemu-test/src/tests/test-int128.c:180: warning: ‘__noclone__’ attribute directive ignored
  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-interface.o
  CC      tests/check-qom-proplist.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/test-uuid.o
  CC      tests/ptimer-test.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/fw_cfg-test.o
  CC      tests/i440fx-test.o
  CC      tests/drive_del-test.o
  CC      tests/wdt_ib700-test.o
  CC      tests/tco-test.o
  CC      tests/e1000-test.o

/tmp/qemu-test/src/tests/ide-test.c: In function ‘cdrom_pio_impl’:
/tmp/qemu-test/src/tests/ide-test.c:803: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result /tmp/qemu-test/src/tests/ide-test.c: In function ‘test_cdrom_dma’:
/tmp/qemu-test/src/tests/ide-test.c:899: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result

  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/test-x86-cpuid-compat.o
  CC      tests/postcopy-test.o
  CC      tests/qmp-test.o
  CC      tests/device-introspect-test.o
  CC      tests/qom-test.o
  LINK    tests/check-qdict
  LINK    tests/test-char
  LINK    tests/check-qfloat
  LINK    tests/check-qint
  LINK    tests/check-qstring
  LINK    tests/check-qlist
  LINK    tests/check-qnull
  CC      tests/test-qapi-visit.o
  CC      tests/test-qapi-types.o
  LINK    tests/check-qjson
  CC      tests/test-qapi-event.o
  CC      tests/test-qmp-introspect.o
  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-cutils
  LINK    tests/test-vmstate
  LINK    tests/test-shift128
  LINK    tests/test-mul64
  LINK    tests/test-int128
  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/qmp-test
  LINK    tests/device-introspect-test
  LINK    tests/qom-test
  GTESTER tests/test-char
  GTESTER tests/check-qint
  GTESTER tests/check-qdict
  GTESTER tests/check-qlist
  GTESTER tests/check-qnull
  GTESTER tests/check-qfloat
  GTESTER tests/check-qstring
  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
LINK tests/test-visitor-serialization
GTESTER tests/test-iov
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
GTESTER tests/test-cutils
GTESTER tests/test-shift128
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/rcutorture
GTESTER tests/test-mul64
GTESTER tests/test-int128
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-secret
GTESTER tests/test-crypto-hmac
GTESTER tests/test-crypto-cipher
GTESTER tests/test-qga
GTESTER tests/test-timed-average
GTESTER tests/test-io-channel-socket
GTESTER tests/test-io-task
GTESTER tests/test-io-channel-file
GTESTER tests/test-io-channel-command

** (process:13846): CRITICAL **: Failed to read /proc/kallsyms: Failed to open file '/proc/kallsyms': Permission denied
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 tests/test-qobject-output-visitor
GTESTER check-qtest-aarch64
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
ftruncate: Permission denied
ftruncate: Permission denied

** (process:14030): CRITICAL **: Failed to read /proc/kallsyms: Failed to open file '/proc/kallsyms': Permission denied
ftruncate: Permission denied
**
ERROR:/tmp/qemu-test/src/tests/vhost-user-test.c:672:test_migrate: assertion failed: (qdict_haskey(rsp, "return"))
GTester: last random seed: R02Se5203afc216a801d7c90e2df7d936b54
ftruncate: Permission denied
ftruncate: Permission denied
**
ERROR:/tmp/qemu-test/src/tests/test-qga.c:750:test_qga_config: assertion failed (err == ""): ("\n** (process:14115): CRITICAL **: Failed to read /proc/kallsyms: Failed to open file '/proc/kallsyms': Permission denied\n" == "")
GTester: last random seed: R02S5dff2a4423169c670b231a3c46957333

** (process:14117): CRITICAL **: Failed to read /proc/kallsyms: Failed to open file '/proc/kallsyms': Permission denied
make: *** [check-tests/test-qga] Error 1
make: *** Waiting for unfinished jobs....
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.
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]: *** [docker-run] Error 2
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-g_4q0obe/src'
make: *** [docker-run-test-quick@centos6] Error 2
=== OUTPUT END ===

Test command exited with code: 2

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#40 lore raw
In reply to Marc-André Lureau

----- Original Message -----

Quoted 27 lines

Hi,

Latest linux kernel enabled kaslr to randomize phys/virt memory addresses. There has been some effort to support kexec/kdump so that crash utility can still works in case crashed kernel has kaslr enabled.

This series aims to provide enough information in qemu dumps so that crash utility can work with kaslr kernel too, with x86_64 guests (it hasn't been tested on other archs, help welcome).

Two pieces of informations are necessary: the phys_base (the physical address where the kernel is loaded) and the kaslr offset. Other useful informations for debugging are provided in Linux vmcoreinfo too.

There has been discussions to provide those details in early boot, with ACPI, fw_cfg, virtio-pstore etc, but none has reached a consensus yet. A possiblity for now is to provide the information when qemu-ga starts. This has the advantage of working with older guests and may not be incompatible with future methods (in this case it could ignore qga info for example). The drawback is that qemu will have to parse the json stream. For now it stops processing it whem VMDUMP_INFO is received. It would be wise to introduce a QMP welcome message, so that qemu would stop immediately processing the stream if the agent doesn't have the event. Another option is to create a seperate channel... I welcome other ideas and discussion.

Quoted 2 lines

crash upstream doesn't yet parse NUMBER(phys_base). You may pass it to crash with --machdep phys_base=0x.. provided you snooped on qga.

FYI: a patch to utilize NUMBER(phys_base) has been checked in upstream:

https://github.com/crash-utility/crash/commit/ed60e97e319a1cfc9e2779aa1baac305677393d8

Linux 4.10 commit 401721ecd1dcb0a428aa5d6832ee05ffbdbffbbe finally exports the x86_64 "phys_base" value in the VMCOREINFO note, so utilize it whenever it exists.
([email protected])

Thanks,
Dave

Quoted 121 lines

kdump kaslr-dumps should now work with crash out of the box.

A large part of the series has to do with json and the qobject type system to deal with uint64 values, so that addresses can now be sent over json. The second halfs adds qga VMDUMP_INFO event, and ELF/kdump dumping. Depending on the feedback, I will probably split the series, but for those who would like to try it, help or suggest ideas, here is the whole thing.

cheers

Marc-André Lureau (21):
qapi: add info comment for generated types
pci-host: use more specific type names
object: fix potential leak in getters
qobject: add quint type
qapi: update the qobject visitor to use QUInt
json: learn to parse uint64 numbers
object: add uint property setter/getter
qdev: use int and uint properties
qdev: use appropriate type
Use uint property getter/setter where appropriate
qdict: learn to lookup quint
test-qga: drop everything until guest-sync
qga: report error on keyfile dump error
qga: add and populate VMDumpInfo
qga: register event emit function
qga: emit VMDUMP_INFO event
virtio-channel: parse qga stream for VMDUMP_INFO event
dump: use qga VMDUMP_INFO for ELF dump
kdump: write vmcoreinfo in header scripts/dump-guest-memory.py: fix int128_get64 on recent gcc scripts/dump-guest-memory.py: add VMCOREINFO

 qapi/introspect.json                     |   2 +-
 scripts/qapi.py                          |  39 ++++---
 scripts/dump-guest-memory.py             |  66 ++++++++++-
 scripts/qapi-event.py                    |   4 +-
 scripts/qapi-types.py                    |  17 +--
 scripts/qapi-visit.py                    |   3 +-
 include/hw/isa/isa.h                     |   2 +-
 include/hw/qdev-core.h                   |   5 +-
 include/hw/qdev-properties.h             |  59 ++++++----
 include/qapi/qmp/qdict.h                 |   2 +
 include/qapi/qmp/quint.h                 |  25 +++++
 include/qapi/qmp/types.h                 |   1 +
 include/qom/object.h                     |  23 ++++
 include/sysemu/dump-info.h               |  15 +++
 include/sysemu/dump.h                    |   2 +
 qga/guest-agent-core.h                   |   2 +
 block/qapi.c                             |   5 +
 dump.c                                   | 184
 ++++++++++++++++++++++++++++++-
 hw/acpi/memory_hotplug.c                 |  10 +-
 hw/acpi/nvdimm.c                         |  10 +-
 hw/acpi/pcihp.c                          |   6 +-
 hw/arm/aspeed.c                          |   4 +-
 hw/arm/bcm2835_peripherals.c             |   9 +-
 hw/arm/raspi.c                           |   4 +-
 hw/block/fdc.c                           |  54 ++++-----
 hw/char/virtio-console.c                 |  53 +++++++++
 hw/core/platform-bus.c                   |   2 +-
 hw/core/qdev-properties.c                |   8 +-
 hw/core/qdev.c                           |   8 +-
 hw/i386/acpi-build.c                     |  70 ++++++------
 hw/i386/pc.c                             |   6 +-
 hw/intc/arm_gicv3_common.c               |   2 +-
 hw/mem/pc-dimm.c                         |   5 +-
 hw/misc/auxbus.c                         |   2 +-
 hw/misc/pvpanic.c                        |   2 +-
 hw/net/e1000e.c                          |  14 +--
 hw/pci-host/gpex.c                       |   2 +-
 hw/pci-host/piix.c                       |   8 +-
 hw/pci-host/q35.c                        |  12 +-
 hw/pci-host/xilinx-pcie.c                |   2 +-
 hw/ppc/pnv_core.c                        |   2 +-
 hw/ppc/spapr.c                           |   8 +-
 numa.c                                   |   6 +-
 qapi/qobject-input-visitor.c             |  30 ++++-
 qapi/qobject-output-visitor.c            |   3 +-
 qga/channel-posix.c                      |  11 ++
 qga/main.c                               | 162 ++++++++++++++++++++++++++-
 qobject/json-lexer.c                     |   4 +
 qobject/json-parser.c                    |  19 +++-
 qobject/qdict.c                          |  37 ++++++-
 qobject/qjson.c                          |   8 ++
 qobject/qobject.c                        |   1 +
 qobject/quint.c                          |  58 ++++++++++
 qom/object.c                             |  38 ++++++-
 target/i386/cpu.c                        |   6 +-
 tests/check-qdict.c                      |  31 ++++++
 tests/check-qint.c                       |  59 ++++++++++
 tests/check-qjson.c                      |  28 +++++
 tests/test-qga.c                         |  27 +++--
 tests/test-qobject-input-visitor.c       |  15 +++
 tests/test-qobject-output-visitor.c      |  19 +++-
 ui/console.c                             |   4 +-
 util/qemu-option.c                       |   6 +
 xen-hvm.c                                |   6 +-
 Makefile                                 |   7 +-
 qga/Makefile.objs                        |   1 +
 qga/qapi-schema.json                     |  15 +++
 qobject/Makefile.objs                    |   2 +-
 tests/qapi-schema/comments.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 +-
 77 files changed, 1153 insertions(+), 227 deletions(-)
 create mode 100644 include/qapi/qmp/quint.h
 create mode 100644 include/sysemu/dump-info.h
 create mode 100644 qobject/quint.c

--
2.12.0.191.gc5d8de91d

#41 lore raw
Quoted 31 lines · Dave Anderson

----- Original Message -----

Quoted 27 lines

Hi,

Latest linux kernel enabled kaslr to randomize phys/virt memory addresses. There has been some effort to support kexec/kdump so that crash utility can still works in case crashed kernel has kaslr enabled.

This series aims to provide enough information in qemu dumps so that crash utility can work with kaslr kernel too, with x86_64 guests (it hasn't been tested on other archs, help welcome).

Two pieces of informations are necessary: the phys_base (the physical address where the kernel is loaded) and the kaslr offset. Other useful informations for debugging are provided in Linux vmcoreinfo too.

There has been discussions to provide those details in early boot, with ACPI, fw_cfg, virtio-pstore etc, but none has reached a consensus yet. A possiblity for now is to provide the information when qemu-ga starts. This has the advantage of working with older guests and may not be incompatible with future methods (in this case it could ignore qga info for example). The drawback is that qemu will have to parse the json stream. For now it stops processing it whem VMDUMP_INFO is received. It would be wise to introduce a QMP welcome message, so that qemu would stop immediately processing the stream if the agent doesn't have the event. Another option is to create a seperate channel... I welcome other ideas and discussion.

Quoted 2 lines

crash upstream doesn't yet parse NUMBER(phys_base). You may pass it to crash with --machdep phys_base=0x.. provided you snooped on qga.

Quoted 8 lines

FYI: a patch to utilize NUMBER(phys_base) has been checked in upstream:

https://github.com/crash-utility/crash/commit/ed60e97e319a1cfc9e2779aa1baac305677393d8

Linux 4.10 commit 401721ecd1dcb0a428aa5d6832ee05ffbdbffbbe finally exports the x86_64 "phys_base" value in the VMCOREINFO note, so utilize it whenever it exists.
([email protected])

Marc-André, what is the plan here? Do we still need it (maybe for Windows)?

Paolo