1. 15 5月, 2020 4 次提交
    • M
      Drop more @errp parameters after previous commit · 40c2281c
      Markus Armbruster 提交于
      Several functions can't fail anymore: ich9_pm_add_properties(),
      device_add_bootindex_property(), ppc_compat_add_property(),
      spapr_caps_add_properties(), PropertyInfo.create().  Drop their @errp
      parameter.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-16-armbru@redhat.com>
      40c2281c
    • M
      qom: Drop parameter @errp of object_property_add() & friends · d2623129
      Markus Armbruster 提交于
      The only way object_property_add() can fail is when a property with
      the same name already exists.  Since our property names are all
      hardcoded, failure is a programming error, and the appropriate way to
      handle it is passing &error_abort.
      
      Same for its variants, except for object_property_add_child(), which
      additionally fails when the child already has a parent.  Parentage is
      also under program control, so this is a programming error, too.
      
      We have a bit over 500 callers.  Almost half of them pass
      &error_abort, slightly fewer ignore errors, one test case handles
      errors, and the remaining few callers pass them to their own callers.
      
      The previous few commits demonstrated once again that ignoring
      programming errors is a bad idea.
      
      Of the few ones that pass on errors, several violate the Error API.
      The Error ** argument must be NULL, &error_abort, &error_fatal, or a
      pointer to a variable containing NULL.  Passing an argument of the
      latter kind twice without clearing it in between is wrong: if the
      first call sets an error, it no longer points to NULL for the second
      call.  ich9_pm_add_properties(), sparc32_ledma_realize(),
      sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
      are wrong that way.
      
      When the one appropriate choice of argument is &error_abort, letting
      users pick the argument is a bad idea.
      
      Drop parameter @errp and assert the preconditions instead.
      
      There's one exception to "duplicate property name is a programming
      error": the way object_property_add() implements the magic (and
      undocumented) "automatic arrayification".  Don't drop @errp there.
      Instead, rename object_property_add() to object_property_try_add(),
      and add the obvious wrapper object_property_add().
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-15-armbru@redhat.com>
      [Two semantic rebase conflicts resolved]
      d2623129
    • M
      e1000: Don't run e1000_instance_init() twice · a13f2042
      Markus Armbruster 提交于
      QOM object initialization runs .instance_init() for the type and all
      its supertypes; see object_init_with_type().
      
      Both TYPE_E1000_BASE and its concrete subtypes set .instance_init() to
      e1000_instance_init().  For the concrete subtypes, it duly gets run
      twice.  The second run fails, but the error gets ignored (a later
      commit will change that).
      
      Remove it from the subtypes.
      
      Cc: Jason Wang <jasowang@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-12-armbru@redhat.com>
      a13f2042
    • M
      qom: Clean up inconsistent use of gchar * vs. char * · ddfb0baa
      Markus Armbruster 提交于
      Uses of gchar * in qom/object.h:
      
      * ObjectProperty member @name
      
        Functions that take a property name argument all use char *.  Change
        the member to match.
      
      * ObjectProperty member @type
      
        Functions that take a property type argument or return it all use
        char *.  Change the member to match.
      
      * ObjectProperty member @description
      
        Functions that take a property description argument all use char *.
        Change the member to match.
      
      * object_resolve_path_component() parameter @part
      
        Path components are property names.  Most callers pass char *
        arguments.  Change the parameter to match.  Adjust the few callers
        that pass gchar * to pass char *.
      
      * Return value of object_get_canonical_path_component(),
        object_get_canonical_path()
      
        Most callers convert their return values right back to char *.
        Change the return value to match.  Adjust the few callers where that
        would add a conversion to gchar * to use char * instead.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-3-armbru@redhat.com>
      ddfb0baa
  2. 14 5月, 2020 5 次提交
  3. 30 4月, 2020 3 次提交
  4. 29 4月, 2020 2 次提交
    • M
      virtio-net: Fix duplex=... and speed=... error handling · 843c4cfc
      Markus Armbruster 提交于
      virtio_net_device_realize() rejects invalid duplex and speed values.
      The error handling is broken:
      
          $ ../qemu/bld-sani/x86_64-softmmu/qemu-system-x86_64 -S -display none -monitor stdio
          QEMU 4.2.93 monitor - type 'help' for more information
          (qemu) device_add virtio-net,duplex=x
          Error: 'duplex' must be 'half' or 'full'
          (qemu) c
          =================================================================
          ==15654==ERROR: AddressSanitizer: heap-use-after-free on address 0x62e000014590 at pc 0x560b75c8dc13 bp 0x7fffdf1a6950 sp 0x7fffdf1a6940
          READ of size 8 at 0x62e000014590 thread T0
      	#0 0x560b75c8dc12 in object_dynamic_cast_assert /work/armbru/qemu/qom/object.c:826
      	#1 0x560b74c38ac0 in virtio_vmstate_change /work/armbru/qemu/hw/virtio/virtio.c:3210
      	#2 0x560b74d9765e in vm_state_notify /work/armbru/qemu/softmmu/vl.c:1271
      	#3 0x560b7494ba72 in vm_prepare_start /work/armbru/qemu/cpus.c:2156
      	#4 0x560b7494bacd in vm_start /work/armbru/qemu/cpus.c:2162
      	#5 0x560b75a7d890 in qmp_cont /work/armbru/qemu/monitor/qmp-cmds.c:160
      	#6 0x560b75a8d70a in hmp_cont /work/armbru/qemu/monitor/hmp-cmds.c:1043
      	#7 0x560b75a799f2 in handle_hmp_command /work/armbru/qemu/monitor/hmp.c:1082
          [...]
      
          0x62e000014590 is located 33168 bytes inside of 42288-byte region [0x62e00000c400,0x62e000016930)
          freed by thread T1 here:
      	#0 0x7feadd39491f in __interceptor_free (/lib64/libasan.so.5+0x10d91f)
      	#1 0x7feadcebcd7c in g_free (/lib64/libglib-2.0.so.0+0x55d7c)
      	#2 0x560b75c8fd40 in object_unref /work/armbru/qemu/qom/object.c:1128
      	#3 0x560b7498a625 in memory_region_unref /work/armbru/qemu/memory.c:1762
      	#4 0x560b74999fa4 in do_address_space_destroy /work/armbru/qemu/memory.c:2788
      	#5 0x560b762362fc in call_rcu_thread /work/armbru/qemu/util/rcu.c:283
      	#6 0x560b761c8884 in qemu_thread_start /work/armbru/qemu/util/qemu-thread-posix.c:519
      	#7 0x7fead9be34bf in start_thread (/lib64/libpthread.so.0+0x84bf)
      
          previously allocated by thread T0 here:
      	#0 0x7feadd394d18 in __interceptor_malloc (/lib64/libasan.so.5+0x10dd18)
      	#1 0x7feadcebcc88 in g_malloc (/lib64/libglib-2.0.so.0+0x55c88)
      	#2 0x560b75c8cf8a in object_new /work/armbru/qemu/qom/object.c:699
      	#3 0x560b75010ad9 in qdev_device_add /work/armbru/qemu/qdev-monitor.c:654
      	#4 0x560b750120c2 in qmp_device_add /work/armbru/qemu/qdev-monitor.c:805
      	#5 0x560b75012c1b in hmp_device_add /work/armbru/qemu/qdev-monitor.c:905
          [...]
          ==15654==ABORTING
      
      Cause: virtio_net_device_realize() neglects to bail out after setting
      the error.  Fix that.
      
      Fixes: 9473939e
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200422130719.28225-9-armbru@redhat.com>
      Acked-by: NMichael S. Tsirkin <mst@redhat.com>
      843c4cfc
    • P
      various: Remove suspicious '\' character outside of #define in C code · 78ee6bd0
      Philippe Mathieu-Daudé 提交于
      Fixes the following coccinelle warnings:
      
        $ spatch --sp-file --verbose-parsing  ... \
            scripts/coccinelle/remove_local_err.cocci
        ...
        SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5213
        SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/translate_init.inc.c:5261
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:166
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:167
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:169
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:170
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:171
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:172
        SUSPICIOUS: a \ character appears outside of a #define at ./target/microblaze/cpu.c:173
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5787
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5789
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5800
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5801
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5802
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5804
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5805
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:5806
        SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/cpu.c:6329
        SUSPICIOUS: a \ character appears outside of a #define at ./hw/sd/sdhci.c:1133
        SUSPICIOUS: a \ character appears outside of a #define at ./hw/scsi/scsi-disk.c:3081
        SUSPICIOUS: a \ character appears outside of a #define at ./hw/net/virtio-net.c:1529
        SUSPICIOUS: a \ character appears outside of a #define at ./hw/riscv/sifive_u.c:468
        SUSPICIOUS: a \ character appears outside of a #define at ./dump/dump.c:1895
        SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2209
        SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2215
        SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2221
        SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:2222
        SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:172
        SUSPICIOUS: a \ character appears outside of a #define at ./block/replication.c:173
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-Id: <20200412223619.11284-2-f4bug@amsat.org>
      Reviewed-by: NAlistair Francis <alistair.francis@wdc.com>
      Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      78ee6bd0
  5. 28 4月, 2020 1 次提交
  6. 31 3月, 2020 11 次提交
  7. 17 3月, 2020 2 次提交
  8. 13 3月, 2020 1 次提交
  9. 09 3月, 2020 3 次提交
  10. 03 3月, 2020 8 次提交