All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs()
@ 2020-04-12 21:29 Philippe Mathieu-Daudé
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Stafford Horne, John Snow,
	Aleksandar Rikalo, Aurelien Jarno

Use a coccinelle script to convert few qemu_allocate_irqs()
calls to the qdev gpio API.

One memory leak removed in hw/openrisc/pic_cpu.c

Philippe Mathieu-Daudé (3):
  hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  hw/mips/mips_int: Use qdev gpio rather than qemu_allocate_irqs()
  hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()

 hw/ide/ahci.c         | 6 ++----
 hw/mips/mips_int.c    | 6 ++----
 hw/openrisc/pic_cpu.c | 5 ++---
 3 files changed, 6 insertions(+), 11 deletions(-)

-- 
2.21.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH-for-5.1 1/3] hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
@ 2020-04-12 21:29 ` Philippe Mathieu-Daudé
  2020-04-13 21:10   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2020-04-12 21:29 ` [PATCH-for-5.1 2/3] hw/mips/mips_int: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-block, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Stafford Horne, John Snow,
	Aleksandar Rikalo, Aurelien Jarno

Switch to using the qdev gpio API which is preferred over
qemu_allocate_irqs(). One step to eventually deprecate and
remove qemu_allocate_irqs() one day.

Patch created mechanically using spatch with this script
inspired from commit d6ef883d9d7:

  @@
  typedef qemu_irq;
  identifier irqs, handler;
  expression opaque, count, i;
  @@
  -   qemu_irq *irqs;
      ...
  -   irqs = qemu_allocate_irqs(handler, opaque, count);
  +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
      <+...
  -   irqs[i]
  +   qdev_get_gpio_in(DEVICE(opaque), i)
      ...+>
  ?-  g_free(irqs);

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/ide/ahci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 13d91e109a..ef0a0a22ee 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1534,19 +1534,18 @@ void ahci_init(AHCIState *s, DeviceState *qdev)
 
 void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
 {
-    qemu_irq *irqs;
     int i;
 
     s->as = as;
     s->ports = ports;
     s->dev = g_new0(AHCIDevice, ports);
     ahci_reg_init(s);
-    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
+    qdev_init_gpio_in(DEVICE(s), ahci_irq_set, s->ports);
     for (i = 0; i < s->ports; i++) {
         AHCIDevice *ad = &s->dev[i];
 
         ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);
-        ide_init2(&ad->port, irqs[i]);
+        ide_init2(&ad->port, qdev_get_gpio_in(DEVICE(s), i));
 
         ad->hba = s;
         ad->port_no = i;
@@ -1554,7 +1553,6 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
         ad->port.dma->ops = &ahci_dma_ops;
         ide_register_restart_cb(&ad->port);
     }
-    g_free(irqs);
 }
 
 void ahci_uninit(AHCIState *s)
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH-for-5.1 2/3] hw/mips/mips_int: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
@ 2020-04-12 21:29 ` Philippe Mathieu-Daudé
  2020-04-12 21:29 ` [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-block, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Stafford Horne, John Snow,
	Aleksandar Rikalo, Aurelien Jarno

Switch to using the qdev gpio API which is preferred over
qemu_allocate_irqs(). One step to eventually deprecate and
remove qemu_allocate_irqs() one day.

Patch created mechanically using spatch with this script
inspired from commit d6ef883d9d7:

  @@
  typedef qemu_irq;
  identifier irqs, handler;
  expression opaque, count, i;
  @@
  -   qemu_irq *irqs;
      ...
  -   irqs = qemu_allocate_irqs(handler, opaque, count);
  +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
      <+...
  -   irqs[i]
  +   qdev_get_gpio_in(DEVICE(opaque), i)
      ...+>
  ?-  g_free(irqs);

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/mips/mips_int.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/mips/mips_int.c b/hw/mips/mips_int.c
index 796730b11d..91788c51a9 100644
--- a/hw/mips/mips_int.c
+++ b/hw/mips/mips_int.c
@@ -74,14 +74,12 @@ static void cpu_mips_irq_request(void *opaque, int irq, int level)
 void cpu_mips_irq_init_cpu(MIPSCPU *cpu)
 {
     CPUMIPSState *env = &cpu->env;
-    qemu_irq *qi;
     int i;
 
-    qi = qemu_allocate_irqs(cpu_mips_irq_request, cpu, 8);
+    qdev_init_gpio_in(DEVICE(cpu), cpu_mips_irq_request, 8);
     for (i = 0; i < 8; i++) {
-        env->irq[i] = qi[i];
+        env->irq[i] = qdev_get_gpio_in(DEVICE(cpu), i);
     }
-    g_free(qi);
 }
 
 void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level)
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
  2020-04-12 21:29 ` [PATCH-for-5.1 2/3] hw/mips/mips_int: " Philippe Mathieu-Daudé
@ 2020-04-12 21:29 ` Philippe Mathieu-Daudé
  2020-04-12 23:33   ` Stafford Horne
  2020-04-12 23:39 ` [PATCH 0/3] hw: " no-reply
  2020-04-12 23:55 ` no-reply
  4 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-12 21:29 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, qemu-block, Philippe Mathieu-Daudé,
	Aleksandar Markovic, Stafford Horne, John Snow,
	Aleksandar Rikalo, Aurelien Jarno

Switch to using the qdev gpio API which is preferred over
qemu_allocate_irqs(). Doing so we also stop leaking the
allocated memory. One step to eventually deprecate and
remove qemu_allocate_irqs() one day.

Patch created mechanically using spatch with this script
inspired from commit d6ef883d9d7:

  @@
  typedef qemu_irq;
  identifier irqs, handler;
  expression opaque, count, i;
  @@
  -   qemu_irq *irqs;
      ...
  -   irqs = qemu_allocate_irqs(handler, opaque, count);
  +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
      <+...
  -   irqs[i]
  +   qdev_get_gpio_in(DEVICE(opaque), i)
      ...+>
  ?-  g_free(irqs);

Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/openrisc/pic_cpu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/openrisc/pic_cpu.c b/hw/openrisc/pic_cpu.c
index 36f9350830..4b0c92f842 100644
--- a/hw/openrisc/pic_cpu.c
+++ b/hw/openrisc/pic_cpu.c
@@ -52,10 +52,9 @@ static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
 void cpu_openrisc_pic_init(OpenRISCCPU *cpu)
 {
     int i;
-    qemu_irq *qi;
-    qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, cpu, NR_IRQS);
+    qdev_init_gpio_in(DEVICE(cpu), openrisc_pic_cpu_handler, NR_IRQS);
 
     for (i = 0; i < NR_IRQS; i++) {
-        cpu->env.irq[i] = qi[i];
+        cpu->env.irq[i] = qdev_get_gpio_in(DEVICE(cpu), i);
     }
 }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 ` [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: " Philippe Mathieu-Daudé
@ 2020-04-12 23:33   ` Stafford Horne
  2020-04-13 21:15     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 13+ messages in thread
From: Stafford Horne @ 2020-04-12 23:33 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, qemu-block, qemu-devel, Aleksandar Markovic,
	Aleksandar Rikalo, John Snow, Aurelien Jarno

On Sun, Apr 12, 2020 at 11:29:43PM +0200, Philippe Mathieu-Daudé wrote:
> Switch to using the qdev gpio API which is preferred over
> qemu_allocate_irqs(). Doing so we also stop leaking the
> allocated memory. One step to eventually deprecate and
> remove qemu_allocate_irqs() one day.
> 
> Patch created mechanically using spatch with this script
> inspired from commit d6ef883d9d7:
> 
>   @@
>   typedef qemu_irq;
>   identifier irqs, handler;
>   expression opaque, count, i;
>   @@
>   -   qemu_irq *irqs;
>       ...
>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>       <+...
>   -   irqs[i]
>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>       ...+>
>   ?-  g_free(irqs);
> 
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/openrisc/pic_cpu.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/openrisc/pic_cpu.c b/hw/openrisc/pic_cpu.c
> index 36f9350830..4b0c92f842 100644
> --- a/hw/openrisc/pic_cpu.c
> +++ b/hw/openrisc/pic_cpu.c
> @@ -52,10 +52,9 @@ static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
>  void cpu_openrisc_pic_init(OpenRISCCPU *cpu)
>  {
>      int i;
> -    qemu_irq *qi;
> -    qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, cpu, NR_IRQS);
> +    qdev_init_gpio_in(DEVICE(cpu), openrisc_pic_cpu_handler, NR_IRQS);
>  
>      for (i = 0; i < NR_IRQS; i++) {
> -        cpu->env.irq[i] = qi[i];
> +        cpu->env.irq[i] = qdev_get_gpio_in(DEVICE(cpu), i);
>      }
>  }

This looks fine to me.

Why do you have the '5.0?' in the subject?

-Stafford


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-04-12 21:29 ` [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: " Philippe Mathieu-Daudé
@ 2020-04-12 23:39 ` no-reply
  2020-04-12 23:55 ` no-reply
  4 siblings, 0 replies; 13+ messages in thread
From: no-reply @ 2020-04-12 23:39 UTC (permalink / raw)
  To: f4bug
  Cc: qemu-block, qemu-devel, f4bug, aleksandar.qemu.devel, shorne,
	jsnow, aleksandar.rikalo, aurelien

Patchew URL: https://patchew.org/QEMU/20200412212943.4117-1-f4bug@amsat.org/



Hi,

This series failed the asan build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===

PASS 1 fdc-test /x86_64/fdc/cmos
PASS 2 fdc-test /x86_64/fdc/no_media_on_start
PASS 3 fdc-test /x86_64/fdc/read_without_media
==6173==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 fdc-test /x86_64/fdc/media_change
PASS 5 fdc-test /x86_64/fdc/sense_interrupt
PASS 6 fdc-test /x86_64/fdc/relative_seek
---
PASS 32 test-opts-visitor /visitor/opts/range/beyond
PASS 33 test-opts-visitor /visitor/opts/dict/unvisited
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-coroutine -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-coroutine" 
==6204==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==6204==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffd6d438000; bottom 0x7f10a9909000; size: 0x00ecc3b2f000 (1016895565824)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 1 test-coroutine /basic/no-dangling-access
---
PASS 12 test-aio /aio/event/flush
PASS 13 test-aio /aio/event/wait/no-flush-cb
PASS 11 fdc-test /x86_64/fdc/read_no_dma_18
==6219==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 14 test-aio /aio/timer/schedule
PASS 15 test-aio /aio/coroutine/queue-chaining
PASS 16 test-aio /aio-gsource/flush
---
PASS 27 test-aio /aio-gsource/event/wait/no-flush-cb
PASS 28 test-aio /aio-gsource/timer/schedule
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-aio-multithread -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-aio-multithread" 
==6224==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-aio-multithread /aio/multi/lifecycle
PASS 12 fdc-test /x86_64/fdc/read_no_dma_19
PASS 13 fdc-test /x86_64/fdc/fuzz-registers
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/qtest/ide-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="ide-test" 
PASS 2 test-aio-multithread /aio/multi/schedule
==6241==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 ide-test /x86_64/ide/identify
==6252==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-aio-multithread /aio/multi/mutex/contended
PASS 2 ide-test /x86_64/ide/flush
==6263==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 ide-test /x86_64/ide/bmdma/simple_rw
==6269==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 ide-test /x86_64/ide/bmdma/trim
==6275==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 test-aio-multithread /aio/multi/mutex/handoff
PASS 5 test-aio-multithread /aio/multi/mutex/mcs
PASS 6 test-aio-multithread /aio/multi/mutex/pthread
---
PASS 6 test-throttle /throttle/detach_attach
PASS 7 test-throttle /throttle/config_functions
PASS 8 test-throttle /throttle/accounting
==6292==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 9 test-throttle /throttle/groups
PASS 10 test-throttle /throttle/config/enabled
PASS 11 test-throttle /throttle/config/conflicting
---
PASS 14 test-throttle /throttle/config/max
PASS 15 test-throttle /throttle/config/iops_size
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-thread-pool -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-thread-pool" 
==6296==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-thread-pool /thread-pool/submit
PASS 2 test-thread-pool /thread-pool/submit-aio
PASS 3 test-thread-pool /thread-pool/submit-co
PASS 4 test-thread-pool /thread-pool/submit-many
PASS 5 test-thread-pool /thread-pool/cancel
==6363==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 test-thread-pool /thread-pool/cancel-async
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-hbitmap -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-hbitmap" 
PASS 1 test-hbitmap /hbitmap/granularity
---
PASS 28 test-hbitmap /hbitmap/truncate/shrink/medium
PASS 29 test-hbitmap /hbitmap/truncate/shrink/large
PASS 30 test-hbitmap /hbitmap/serialize/align
==6373==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 31 test-hbitmap /hbitmap/serialize/basic
PASS 32 test-hbitmap /hbitmap/serialize/part
PASS 33 test-hbitmap /hbitmap/serialize/zeroes
---
PASS 39 test-hbitmap /hbitmap/next_dirty_area/next_dirty_area_4
PASS 40 test-hbitmap /hbitmap/next_dirty_area/next_dirty_area_after_truncate
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bdrv-drain -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bdrv-drain" 
==6380==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-bdrv-drain /bdrv-drain/nested
PASS 2 test-bdrv-drain /bdrv-drain/multiparent
PASS 3 test-bdrv-drain /bdrv-drain/set_aio_context
---
PASS 41 test-bdrv-drain /bdrv-drain/bdrv_drop_intermediate/poll
PASS 42 test-bdrv-drain /bdrv-drain/replace_child/mid-drain
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bdrv-graph-mod -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bdrv-graph-mod" 
==6419==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-bdrv-graph-mod /bdrv-graph-mod/update-perm-tree
PASS 2 test-bdrv-graph-mod /bdrv-graph-mod/should-update-child
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-blockjob -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-blockjob" 
==6423==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-blockjob /blockjob/ids
PASS 2 test-blockjob /blockjob/cancel/created
PASS 3 test-blockjob /blockjob/cancel/running
---
PASS 7 test-blockjob /blockjob/cancel/pending
PASS 8 test-blockjob /blockjob/cancel/concluded
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-blockjob-txn -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-blockjob-txn" 
==6427==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-blockjob-txn /single/success
PASS 2 test-blockjob-txn /single/failure
PASS 3 test-blockjob-txn /single/cancel
---
PASS 6 test-blockjob-txn /pair/cancel
PASS 7 test-blockjob-txn /pair/fail-cancel-race
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-block-backend -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-block-backend" 
==6431==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-block-backend /block-backend/drain_aio_error
PASS 2 test-block-backend /block-backend/drain_all_aio_error
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-block-iothread -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-block-iothread" 
==6435==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-block-iothread /sync-op/pread
PASS 2 test-block-iothread /sync-op/pwrite
PASS 3 test-block-iothread /sync-op/load_vmstate
---
PASS 15 test-block-iothread /propagate/diamond
PASS 16 test-block-iothread /propagate/mirror
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-image-locking -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-image-locking" 
==6455==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-image-locking /image-locking/basic
PASS 2 test-image-locking /image-locking/set-perm-abort
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-x86-cpuid -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-x86-cpuid" 
---
PASS 10 test-int128 /int128/int128_rshift
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/rcutorture -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="rcutorture" 
PASS 1 rcutorture /rcu/torture/1reader
==6491==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 rcutorture /rcu/torture/10readers
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-list -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-list" 
PASS 1 test-rcu-list /rcu/qlist/single-threaded
---
PASS 3 test-rcu-list /rcu/qlist/long-many
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-simpleq -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-simpleq" 
PASS 1 test-rcu-simpleq /rcu/qsimpleq/single-threaded
==6552==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 test-rcu-simpleq /rcu/qsimpleq/short-few
PASS 3 test-rcu-simpleq /rcu/qsimpleq/long-many
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-tailq -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-tailq" 
PASS 1 test-rcu-tailq /rcu/qtailq/single-threaded
PASS 2 test-rcu-tailq /rcu/qtailq/short-few
==6618==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-rcu-tailq /rcu/qtailq/long-many
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-slist -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-slist" 
PASS 1 test-rcu-slist /rcu/qslist/single-threaded
---
PASS 7 test-qdist /qdist/binning/expand
PASS 8 test-qdist /qdist/binning/shrink
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qht -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qht" 
==6664==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==6670==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==6676==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-qht /qht/mode/default
PASS 2 test-qht /qht/mode/resize
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qht-par -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qht-par" 
---
PASS 9 test-keyval /keyval/visit/alternate
PASS 10 test-keyval /keyval/visit/any
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-write-threshold -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-write-threshold" 
==6725==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==6725==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fff667d4000; bottom 0x7f3afcd98000; size: 0x00c469a3c000 (843585929216)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 1 test-write-threshold /write-threshold/not-set-on-init
---
PASS 15 test-crypto-secret /crypto/secret/crypt/missingiv
PASS 16 test-crypto-secret /crypto/secret/crypt/badiv
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-crypto-tlscredsx509 -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-crypto-tlscredsx509" 
==6764==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 8 ide-test /x86_64/ide/flush/empty_drive
PASS 1 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/perfectserver
PASS 2 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/perfectclient
PASS 3 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca1
==6773==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 9 ide-test /x86_64/ide/flush/retry_pci
PASS 4 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca2
==6779==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 10 ide-test /x86_64/ide/flush/retry_isa
PASS 5 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca3
PASS 6 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca1
PASS 7 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca2
PASS 8 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca3
==6785==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 11 ide-test /x86_64/ide/cdrom/pio
PASS 9 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver1
PASS 10 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver2
==6791==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 11 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver3
PASS 12 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver4
PASS 12 ide-test /x86_64/ide/cdrom/pio_large
---
PASS 32 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive1
PASS 33 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive2
PASS 34 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive3
==6797==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 13 ide-test /x86_64/ide/cdrom/dma
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/qtest/ahci-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="ahci-test" 
PASS 35 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/chain1
---
PASS 39 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/missingclient
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-crypto-tlssession -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-crypto-tlssession" 
PASS 1 test-crypto-tlssession /qcrypto/tlssession/psk
==6815==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
/tmp/qemu-test/src/qom/object.c:885:22: runtime error: member access within misaligned address 0x000000000004 for type 'ObjectClass' (aka 'struct ObjectClass'), which requires 8 byte alignment
0x000000000004: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/qemu-test/src/qom/object.c:885:22 in 
/tmp/qemu-test/src/qom/object.c:885:22: runtime error: load of misaligned address 0x00000000000c for type 'GSList *' (aka 'struct _GSList *'), which requires 8 byte alignment
0x00000000000c: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /tmp/qemu-test/src/qom/object.c:885:22 in 
AddressSanitizer:DEADLYSIGNAL
=================================================================
==6815==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000000c (pc 0x55cd78833993 bp 0x7ffe7d442520 sp 0x7ffe7d442470 T0)
==6815==The signal is caused by a READ memory access.
==6815==Hint: address points to the zero page.
PASS 2 test-crypto-tlssession /qcrypto/tlssession/basicca
---
==6815==ABORTING
Broken pipe
/tmp/qemu-test/src/tests/qtest/libqtest.c:166: kill_qemu() tried to terminate QEMU process but encountered exit status 1 (expected 0)
ERROR - too few tests run (expected 74, got 0)
make: *** [/tmp/qemu-test/src/tests/Makefile.include:636: check-qtest-x86_64] Error 1
make: *** Waiting for unfinished jobs....
PASS 4 test-crypto-tlssession /qcrypto/tlssession/altname1
PASS 5 test-crypto-tlssession /qcrypto/tlssession/altname2
---
PASS 3 test-logging /logging/logfile_write_path
PASS 4 test-logging /logging/logfile_lock_path
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-replication -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-replication" 
==6969==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-replication /replication/primary/read
PASS 2 test-replication /replication/primary/write
PASS 3 test-replication /replication/primary/start
---
PASS 6 test-replication /replication/primary/get_error_all
PASS 7 test-replication /replication/secondary/read
PASS 8 test-replication /replication/secondary/write
==6969==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fff438af000; bottom 0x7f31ffd1b000; size: 0x00cd43b94000 (881604509696)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 9 test-replication /replication/secondary/start
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=39a2410ab0b94120bfbb5a5cb02412ab', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=x86_64-softmmu', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-4gxbar0e/src/docker-src.2020-04-12-19.08.53.31680:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-debug']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=39a2410ab0b94120bfbb5a5cb02412ab
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-4gxbar0e/src'
make: *** [docker-run-test-debug@fedora] Error 2

real    30m24.620s
user    0m8.221s


The full log is available at
http://patchew.org/logs/20200412212943.4117-1-f4bug@amsat.org/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2020-04-12 23:39 ` [PATCH 0/3] hw: " no-reply
@ 2020-04-12 23:55 ` no-reply
  4 siblings, 0 replies; 13+ messages in thread
From: no-reply @ 2020-04-12 23:55 UTC (permalink / raw)
  To: f4bug
  Cc: qemu-block, qemu-devel, f4bug, aleksandar.qemu.devel, shorne,
	jsnow, aleksandar.rikalo, aurelien

Patchew URL: https://patchew.org/QEMU/20200412212943.4117-1-f4bug@amsat.org/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

qemu-system-aarch64: falling back to tcg
Broken pipe
/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 11 (Segmentation fault) (core dumped)
ERROR - too few tests run (expected 74, got 0)
  TEST    iotest-qcow2: 019
make: *** [check-qtest-x86_64] Error 1
make: *** Waiting for unfinished jobs....
  TEST    check-unit: tests/test-rcu-tailq
  TEST    iotest-qcow2: 020
---
  TEST    iotest-qcow2: 158
Broken pipe
/tmp/qemu-test/src/tests/qtest/libqtest.c:175: kill_qemu() detected QEMU death from signal 11 (Segmentation fault) (core dumped)
ERROR - too few tests run (expected 65, got 6)
make: *** [check-qtest-aarch64] Error 1
  TEST    iotest-qcow2: 159
  TEST    iotest-qcow2: 161
  TEST    iotest-qcow2: 170
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=103d91ee281d41b2bb4bc629fd7bbc12', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-jjkljh84/src/docker-src.2020-04-12-19.40.50.10347:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=103d91ee281d41b2bb4bc629fd7bbc12
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-jjkljh84/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    14m30.358s
user    0m8.895s


The full log is available at
http://patchew.org/logs/20200412212943.4117-1-f4bug@amsat.org/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.1 1/3] hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
@ 2020-04-13 21:10   ` Philippe Mathieu-Daudé
  2020-04-13 22:13   ` Alistair Francis
  2020-04-17 19:42   ` John Snow
  2 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-13 21:10 UTC (permalink / raw)
  To: qemu-devel, John Snow, Alistair Francis
  Cc: Peter Maydell, qemu-block, Aleksandar Markovic, Stafford Horne,
	Aleksandar Rikalo, Aurelien Jarno

[sending again as my previous mail was rejected, sorry if you get this
twice]

On 4/12/20 11:29 PM, Philippe Mathieu-Daudé wrote:
> Switch to using the qdev gpio API which is preferred over
> qemu_allocate_irqs(). One step to eventually deprecate and
> remove qemu_allocate_irqs() one day.
> 
> Patch created mechanically using spatch with this script
> inspired from commit d6ef883d9d7:
> 
>   @@
>   typedef qemu_irq;
>   identifier irqs, handler;
>   expression opaque, count, i;
>   @@
>   -   qemu_irq *irqs;
>       ...
>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>       <+...
>   -   irqs[i]
>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>       ...+>
>   ?-  g_free(irqs);
> 
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/ide/ahci.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index 13d91e109a..ef0a0a22ee 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -1534,19 +1534,18 @@ void ahci_init(AHCIState *s, DeviceState *qdev)
>  
>  void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>  {
> -    qemu_irq *irqs;
>      int i;
>  
>      s->as = as;
>      s->ports = ports;
>      s->dev = g_new0(AHCIDevice, ports);
>      ahci_reg_init(s);
> -    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
> +    qdev_init_gpio_in(DEVICE(s), ahci_irq_set, s->ports);

This is wrong as AHCIState is not a QOM DEVICE... see commit bb639f829f1:

---
diff --git a/hw/ide/ahci.h b/hw/ide/ahci.h
index c055d6ba6b..c9b3805415 100644
--- a/hw/ide/ahci.h
+++ b/hw/ide/ahci.h
@@ -287,6 +287,8 @@ struct AHCIDevice {
 };

 typedef struct AHCIState {
+    DeviceState *container;
+
     AHCIDevice *dev;
     AHCIControlRegs control_regs;
     MemoryRegion mem;
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 02d85fa0e9..d83efa47a4 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -121,9 +121,9 @@ static uint32_t  ahci_port_read(AHCIState *s, int
port, int offset)

 static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev)
 {
-    AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
-    PCIDevice *pci_dev =
-        (PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
+    DeviceState *dev_state = s->container;
+    PCIDevice *pci_dev = (PCIDevice *)
object_dynamic_cast(OBJECT(dev_state),
+
TYPE_PCI_DEVICE);

     DPRINTF(0, "raise irq\n");

@@ -136,9 +136,9 @@ static void ahci_irq_raise(AHCIState *s, AHCIDevice
*dev)

 static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev)
 {
-    AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
-    PCIDevice *pci_dev =
-        (PCIDevice *)object_dynamic_cast(OBJECT(d), TYPE_PCI_DEVICE);
+    DeviceState *dev_state = s->container;
+    PCIDevice *pci_dev = (PCIDevice *)
object_dynamic_cast(OBJECT(dev_state),
+
TYPE_PCI_DEVICE);

     DPRINTF(0, "lower irq\n");

@@ -1436,6 +1436,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev,
AddressSpace *as, int ports)
     s->as = as;
     s->ports = ports;
     s->dev = g_new0(AHCIDevice, ports);
+    s->container = qdev;
     ahci_reg_init(s);
     /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for
now */
     memory_region_init_io(&s->mem, OBJECT(qdev), &ahci_mem_ops, s,
---

Using s/DEVICE(s)/qdev/ works although.

>      for (i = 0; i < s->ports; i++) {
>          AHCIDevice *ad = &s->dev[i];
>  
>          ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);
> -        ide_init2(&ad->port, irqs[i]);
> +        ide_init2(&ad->port, qdev_get_gpio_in(DEVICE(s), i));
>  
>          ad->hba = s;
>          ad->port_no = i;
> @@ -1554,7 +1553,6 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>          ad->port.dma->ops = &ahci_dma_ops;
>          ide_register_restart_cb(&ad->port);
>      }
> -    g_free(irqs);
>  }
>  
>  void ahci_uninit(AHCIState *s)
> 


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 23:33   ` Stafford Horne
@ 2020-04-13 21:15     ` Philippe Mathieu-Daudé
  2020-04-14 12:24       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-13 21:15 UTC (permalink / raw)
  To: Stafford Horne
  Cc: Peter Maydell, qemu-block, qemu-devel, Aleksandar Markovic,
	Aleksandar Rikalo, John Snow, Aurelien Jarno

Hi Stafford,

On 4/13/20 1:33 AM, Stafford Horne wrote:
> On Sun, Apr 12, 2020 at 11:29:43PM +0200, Philippe Mathieu-Daudé wrote:
>> Switch to using the qdev gpio API which is preferred over
>> qemu_allocate_irqs(). Doing so we also stop leaking the
>> allocated memory. One step to eventually deprecate and
>> remove qemu_allocate_irqs() one day.
>>
>> Patch created mechanically using spatch with this script
>> inspired from commit d6ef883d9d7:
>>
>>   @@
>>   typedef qemu_irq;
>>   identifier irqs, handler;
>>   expression opaque, count, i;
>>   @@
>>   -   qemu_irq *irqs;
>>       ...
>>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>>       <+...
>>   -   irqs[i]
>>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>>       ...+>
>>   ?-  g_free(irqs);
>>
>> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  hw/openrisc/pic_cpu.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/openrisc/pic_cpu.c b/hw/openrisc/pic_cpu.c
>> index 36f9350830..4b0c92f842 100644
>> --- a/hw/openrisc/pic_cpu.c
>> +++ b/hw/openrisc/pic_cpu.c
>> @@ -52,10 +52,9 @@ static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
>>  void cpu_openrisc_pic_init(OpenRISCCPU *cpu)
>>  {
>>      int i;
>> -    qemu_irq *qi;
>> -    qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, cpu, NR_IRQS);
>> +    qdev_init_gpio_in(DEVICE(cpu), openrisc_pic_cpu_handler, NR_IRQS);
>>  
>>      for (i = 0; i < NR_IRQS; i++) {
>> -        cpu->env.irq[i] = qi[i];
>> +        cpu->env.irq[i] = qdev_get_gpio_in(DEVICE(cpu), i);
>>      }
>>  }
> 
> This looks fine to me.
> 
> Why do you have the '5.0?' in the subject?

Simply because similar commit d6ef883d9d7 was merged in 5.0-rc1 (and it
fixes a bug reported by Coverity, I'm not sure why Coverity didn't
reported this too).

> 
> -Stafford
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.1 1/3] hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
  2020-04-13 21:10   ` Philippe Mathieu-Daudé
@ 2020-04-13 22:13   ` Alistair Francis
  2020-04-14  9:26     ` BALATON Zoltan
  2020-04-17 19:42   ` John Snow
  2 siblings, 1 reply; 13+ messages in thread
From: Alistair Francis @ 2020-04-13 22:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Qemu-block, qemu-devel@nongnu.org Developers,
	Aleksandar Markovic, Stafford Horne, John Snow,
	Aleksandar Rikalo, Aurelien Jarno

On Sun, Apr 12, 2020 at 2:29 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Switch to using the qdev gpio API which is preferred over
> qemu_allocate_irqs(). One step to eventually deprecate and
> remove qemu_allocate_irqs() one day.
>
> Patch created mechanically using spatch with this script
> inspired from commit d6ef883d9d7:
>
>   @@
>   typedef qemu_irq;
>   identifier irqs, handler;
>   expression opaque, count, i;
>   @@
>   -   qemu_irq *irqs;
>       ...
>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>       <+...
>   -   irqs[i]
>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>       ...+>
>   ?-  g_free(irqs);
>
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/ide/ahci.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index 13d91e109a..ef0a0a22ee 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -1534,19 +1534,18 @@ void ahci_init(AHCIState *s, DeviceState *qdev)
>
>  void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>  {
> -    qemu_irq *irqs;
>      int i;
>
>      s->as = as;
>      s->ports = ports;
>      s->dev = g_new0(AHCIDevice, ports);
>      ahci_reg_init(s);
> -    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
> +    qdev_init_gpio_in(DEVICE(s), ahci_irq_set, s->ports);
>      for (i = 0; i < s->ports; i++) {
>          AHCIDevice *ad = &s->dev[i];
>
>          ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);
> -        ide_init2(&ad->port, irqs[i]);
> +        ide_init2(&ad->port, qdev_get_gpio_in(DEVICE(s), i));
>
>          ad->hba = s;
>          ad->port_no = i;
> @@ -1554,7 +1553,6 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>          ad->port.dma->ops = &ahci_dma_ops;
>          ide_register_restart_cb(&ad->port);
>      }
> -    g_free(irqs);
>  }
>
>  void ahci_uninit(AHCIState *s)
> --
> 2.21.1
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.1 1/3] hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-13 22:13   ` Alistair Francis
@ 2020-04-14  9:26     ` BALATON Zoltan
  0 siblings, 0 replies; 13+ messages in thread
From: BALATON Zoltan @ 2020-04-14  9:26 UTC (permalink / raw)
  To: Alistair Francis
  Cc: Peter Maydell, Qemu-block, Philippe Mathieu-Daudé,
	qemu-devel@nongnu.org Developers, Aleksandar Markovic,
	Stafford Horne, John Snow, Aleksandar Rikalo, Aurelien Jarno

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2500 bytes --]

On Mon, 13 Apr 2020, Alistair Francis wrote:
> On Sun, Apr 12, 2020 at 2:29 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> Switch to using the qdev gpio API which is preferred over
>> qemu_allocate_irqs(). One step to eventually deprecate and
>> remove qemu_allocate_irqs() one day.

Not only that, it also fixes leaking allocated irqs if ahci can be 
plugged. (That was the reason for the original patch to fix the leak.)

Regards,
BALATON Zoltan

>> Patch created mechanically using spatch with this script
>> inspired from commit d6ef883d9d7:
>>
>>   @@
>>   typedef qemu_irq;
>>   identifier irqs, handler;
>>   expression opaque, count, i;
>>   @@
>>   -   qemu_irq *irqs;
>>       ...
>>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>>       <+...
>>   -   irqs[i]
>>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>>       ...+>
>>   ?-  g_free(irqs);
>>
>> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
>
> Alistair
>
>> ---
>>  hw/ide/ahci.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
>> index 13d91e109a..ef0a0a22ee 100644
>> --- a/hw/ide/ahci.c
>> +++ b/hw/ide/ahci.c
>> @@ -1534,19 +1534,18 @@ void ahci_init(AHCIState *s, DeviceState *qdev)
>>
>>  void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>>  {
>> -    qemu_irq *irqs;
>>      int i;
>>
>>      s->as = as;
>>      s->ports = ports;
>>      s->dev = g_new0(AHCIDevice, ports);
>>      ahci_reg_init(s);
>> -    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
>> +    qdev_init_gpio_in(DEVICE(s), ahci_irq_set, s->ports);
>>      for (i = 0; i < s->ports; i++) {
>>          AHCIDevice *ad = &s->dev[i];
>>
>>          ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);
>> -        ide_init2(&ad->port, irqs[i]);
>> +        ide_init2(&ad->port, qdev_get_gpio_in(DEVICE(s), i));
>>
>>          ad->hba = s;
>>          ad->port_no = i;
>> @@ -1554,7 +1553,6 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
>>          ad->port.dma->ops = &ahci_dma_ops;
>>          ide_register_restart_cb(&ad->port);
>>      }
>> -    g_free(irqs);
>>  }
>>
>>  void ahci_uninit(AHCIState *s)
>> --
>> 2.21.1
>>
>>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-13 21:15     ` Philippe Mathieu-Daudé
@ 2020-04-14 12:24       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-14 12:24 UTC (permalink / raw)
  To: Stafford Horne
  Cc: Peter Maydell, open list:Block layer core,
	qemu-devel@nongnu.org Developers, Aleksandar Markovic,
	Aleksandar Rikalo, John Snow, Aurelien Jarno

On Mon, Apr 13, 2020 at 11:15 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Hi Stafford,
>
> On 4/13/20 1:33 AM, Stafford Horne wrote:
> > On Sun, Apr 12, 2020 at 11:29:43PM +0200, Philippe Mathieu-Daudé wrote:
> >> Switch to using the qdev gpio API which is preferred over
> >> qemu_allocate_irqs(). Doing so we also stop leaking the
> >> allocated memory. One step to eventually deprecate and
> >> remove qemu_allocate_irqs() one day.
> >>
> >> Patch created mechanically using spatch with this script
> >> inspired from commit d6ef883d9d7:
> >>
> >>   @@
> >>   typedef qemu_irq;
> >>   identifier irqs, handler;
> >>   expression opaque, count, i;
> >>   @@
> >>   -   qemu_irq *irqs;
> >>       ...
> >>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
> >>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
> >>       <+...
> >>   -   irqs[i]
> >>   +   qdev_get_gpio_in(DEVICE(opaque), i)
> >>       ...+>
> >>   ?-  g_free(irqs);
> >>
> >> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> >> ---
> >>  hw/openrisc/pic_cpu.c | 5 ++---
> >>  1 file changed, 2 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/hw/openrisc/pic_cpu.c b/hw/openrisc/pic_cpu.c
> >> index 36f9350830..4b0c92f842 100644
> >> --- a/hw/openrisc/pic_cpu.c
> >> +++ b/hw/openrisc/pic_cpu.c
> >> @@ -52,10 +52,9 @@ static void openrisc_pic_cpu_handler(void *opaque, int irq, int level)
> >>  void cpu_openrisc_pic_init(OpenRISCCPU *cpu)
> >>  {
> >>      int i;
> >> -    qemu_irq *qi;
> >> -    qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, cpu, NR_IRQS);
> >> +    qdev_init_gpio_in(DEVICE(cpu), openrisc_pic_cpu_handler, NR_IRQS);
> >>
> >>      for (i = 0; i < NR_IRQS; i++) {
> >> -        cpu->env.irq[i] = qi[i];
> >> +        cpu->env.irq[i] = qdev_get_gpio_in(DEVICE(cpu), i);
> >>      }
> >>  }
> >
> > This looks fine to me.
> >
> > Why do you have the '5.0?' in the subject?
>
> Simply because similar commit d6ef883d9d7 was merged in 5.0-rc1 (and it
> fixes a bug reported by Coverity, I'm not sure why Coverity didn't
> reported this too).

Actually Coverity reported this issue as CID1421934 "Resource leak" on
2020-03-19 18:52:20.

  The system resource will not be reclaimed and reused, reducing the
future availability of the resource.
  In cpu_openrisc_pic_init: Leak of memory or pointers to system
resources (CWE-404)

>
> >
> > -Stafford
> >


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH-for-5.1 1/3] hw/ide/ahci: Use qdev gpio rather than qemu_allocate_irqs()
  2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
  2020-04-13 21:10   ` Philippe Mathieu-Daudé
  2020-04-13 22:13   ` Alistair Francis
@ 2020-04-17 19:42   ` John Snow
  2 siblings, 0 replies; 13+ messages in thread
From: John Snow @ 2020-04-17 19:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Peter Maydell, qemu-block, Aleksandar Markovic, Stafford Horne,
	Aleksandar Rikalo, Aurelien Jarno



On 4/12/20 5:29 PM, Philippe Mathieu-Daudé wrote:
> Switch to using the qdev gpio API which is preferred over
> qemu_allocate_irqs(). One step to eventually deprecate and
> remove qemu_allocate_irqs() one day.
> 
> Patch created mechanically using spatch with this script
> inspired from commit d6ef883d9d7:
> 
>   @@
>   typedef qemu_irq;
>   identifier irqs, handler;
>   expression opaque, count, i;
>   @@
>   -   qemu_irq *irqs;
>       ...
>   -   irqs = qemu_allocate_irqs(handler, opaque, count);
>   +   qdev_init_gpio_in(DEVICE(opaque), handler, count);
>       <+...
>   -   irqs[i]
>   +   qdev_get_gpio_in(DEVICE(opaque), i)
>       ...+>
>   ?-  g_free(irqs);
> 
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: John Snow <jsnow@redhat.com>

Acked-by: John Snow <jsnow@redhat.com>



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-04-17 19:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 21:29 [PATCH 0/3] hw: Use qdev gpio rather than qemu_allocate_irqs() Philippe Mathieu-Daudé
2020-04-12 21:29 ` [PATCH-for-5.1 1/3] hw/ide/ahci: " Philippe Mathieu-Daudé
2020-04-13 21:10   ` Philippe Mathieu-Daudé
2020-04-13 22:13   ` Alistair Francis
2020-04-14  9:26     ` BALATON Zoltan
2020-04-17 19:42   ` John Snow
2020-04-12 21:29 ` [PATCH-for-5.1 2/3] hw/mips/mips_int: " Philippe Mathieu-Daudé
2020-04-12 21:29 ` [PATCH-for-5.0? 3/3] hw/openrisc/pic_cpu: " Philippe Mathieu-Daudé
2020-04-12 23:33   ` Stafford Horne
2020-04-13 21:15     ` Philippe Mathieu-Daudé
2020-04-14 12:24       ` Philippe Mathieu-Daudé
2020-04-12 23:39 ` [PATCH 0/3] hw: " no-reply
2020-04-12 23:55 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.