qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
@ 2014-11-13  2:39 arei.gonglei
  2014-11-13 11:23 ` Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: arei.gonglei @ 2014-11-13  2:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Gonglei, peter.huangpeng, mst

From: Gonglei <arei.gonglei@huawei.com>

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/virtio/virtio-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index eb77019..dfd2d8c 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus)
 {
     VirtIODevice *vdev = virtio_bus_get_device(bus);
 
-    DPRINTF("%s: reset device.\n", qbus->name);
+    DPRINTF("%s: reset device.\n", BUS(bus)->name);
     if (vdev != NULL) {
         virtio_reset(vdev);
     }
-- 
1.7.12.4

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

* Re: [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
  2014-11-13  2:39 [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch arei.gonglei
@ 2014-11-13 11:23 ` Stefan Hajnoczi
  2014-11-13 11:27 ` Stefan Hajnoczi
  2014-12-10  8:20 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-11-13 11:23 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, mst, qemu-devel, peter.huangpeng

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

On Thu, Nov 13, 2014 at 10:39:32AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/virtio/virtio-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
  2014-11-13  2:39 [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch arei.gonglei
  2014-11-13 11:23 ` Stefan Hajnoczi
@ 2014-11-13 11:27 ` Stefan Hajnoczi
  2014-11-13 11:49   ` Gonglei
  2014-12-10  8:20 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  2 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2014-11-13 11:27 UTC (permalink / raw)
  To: arei.gonglei; +Cc: qemu-trivial, mst, qemu-devel, peter.huangpeng

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

On Thu, Nov 13, 2014 at 10:39:32AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/virtio/virtio-bus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
> index eb77019..dfd2d8c 100644
> --- a/hw/virtio/virtio-bus.c
> +++ b/hw/virtio/virtio-bus.c
> @@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus)
>  {
>      VirtIODevice *vdev = virtio_bus_get_device(bus);
>  
> -    DPRINTF("%s: reset device.\n", qbus->name);
> +    DPRINTF("%s: reset device.\n", BUS(bus)->name);

In general the problem with existing DPRINTF() macros is that they use
#ifdef.  This leads to bitrot, such as this instance.

A better approach is:

#define DEBUG_FOO 0
#define DPRINTF(...) \
do { \
    if (DEBUG_FOO) { \
        fprintf(stderr, ...); \
    } \
} while (0)

Now the compiler always checks the DPRINTF() code.

Trace events can be a good solution too.  If you like stderr output,
build QEMU with ./configure --enable-trace-backend=stderr and all
trace_*() calls are turned into fprintf(stderr).

The cool thing about trace events is that they are available in
production too.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
  2014-11-13 11:27 ` Stefan Hajnoczi
@ 2014-11-13 11:49   ` Gonglei
  0 siblings, 0 replies; 5+ messages in thread
From: Gonglei @ 2014-11-13 11:49 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: qemu-trivial@nongnu.org, mst@redhat.com, qemu-devel@nongnu.org,
	Huangpeng (Peter)

On 2014/11/13 19:27, Stefan Hajnoczi wrote:

> On Thu, Nov 13, 2014 at 10:39:32AM +0800, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>  hw/virtio/virtio-bus.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
>> index eb77019..dfd2d8c 100644
>> --- a/hw/virtio/virtio-bus.c
>> +++ b/hw/virtio/virtio-bus.c
>> @@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus)
>>  {
>>      VirtIODevice *vdev = virtio_bus_get_device(bus);
>>  
>> -    DPRINTF("%s: reset device.\n", qbus->name);
>> +    DPRINTF("%s: reset device.\n", BUS(bus)->name);
> 
> In general the problem with existing DPRINTF() macros is that they use
> #ifdef.  This leads to bitrot, such as this instance.
> 

Yes.

> A better approach is:
> 
> #define DEBUG_FOO 0
> #define DPRINTF(...) \
> do { \
>     if (DEBUG_FOO) { \
>         fprintf(stderr, ...); \
>     } \
> } while (0)
> 
> Now the compiler always checks the DPRINTF() code.
> 
> Trace events can be a good solution too.  If you like stderr output,
> build QEMU with ./configure --enable-trace-backend=stderr and all
> trace_*() calls are turned into fprintf(stderr).
> 
> The cool thing about trace events is that they are available in
> production too.
> 

Hum, trace events is great! :)

Best regards,
-Gonglei

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch
  2014-11-13  2:39 [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch arei.gonglei
  2014-11-13 11:23 ` Stefan Hajnoczi
  2014-11-13 11:27 ` Stefan Hajnoczi
@ 2014-12-10  8:20 ` Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Tokarev @ 2014-12-10  8:20 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel; +Cc: qemu-trivial, peter.huangpeng, mst

Applied to -trivial as is, for now, since
the fixes are necessary anyway.  Good suggestion
by Stefan, to turn it into constant-depending
always-compilable code stands, but it is not
a show-stopper for the actual fix.

Thanks,

/mnt

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

end of thread, other threads:[~2014-12-10  8:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13  2:39 [Qemu-devel] [PATCH] virtio-bus: avoid breaking build when open DEBUG switch arei.gonglei
2014-11-13 11:23 ` Stefan Hajnoczi
2014-11-13 11:27 ` Stefan Hajnoczi
2014-11-13 11:49   ` Gonglei
2014-12-10  8:20 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).