All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael Roth" <michael.roth@amd.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Mads Ynddal" <mads@ynddal.dk>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	oleg.tolmatcev@gmail.com
Subject: Re: [PATCH v3 5/8] tracetool: support "-" as a shorthand for stdout
Date: Mon, 18 Aug 2025 16:07:28 +0100	[thread overview]
Message-ID: <aKNBsOekKkCSqgD7@redhat.com> (raw)
In-Reply-To: <20250807194608.GF51368@fedora>

On Thu, Aug 07, 2025 at 03:46:08PM -0400, Stefan Hajnoczi wrote:
> On Wed, Aug 06, 2025 at 05:48:29PM +0100, Daniel P. Berrangé wrote:
> > This avoids callers needing to use the UNIX-only /dev/stdout
> > workaround.
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  scripts/tracetool/__init__.py | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> > index 0f33758870..c8fd3a7ddc 100644
> > --- a/scripts/tracetool/__init__.py
> > +++ b/scripts/tracetool/__init__.py
> > @@ -38,8 +38,12 @@ def error(*lines):
> >  
> >  def out_open(filename):
> >      global out_filename, out_fobj
> > -    out_filename = posix_relpath(filename)
> > -    out_fobj = open(filename, 'wt')
> > +    if filename == "-":
> > +        out_filename = "[stdout]"
> 
> A few lines above:
> 
>   out_filename = '<none>'
>   out_fobj = sys.stdout
> 
> Stick to '<none>' here for consistency?

Curious - that suggests that it was intended to be able to write to
stdout by default, but tracetool.py unconditionally calls out_open()
so those default assignments are effectively dead code, unless this
internal code is called by something other than the tracetool.py main
entrypoint ?

I guess I'd be inclined to change the global initialization to just
be 'None' to make it explicit that out_open is expected to always be
called ?

> > +        out_fobj = sys.stdout
> > +    else:
> > +        out_filename = posix_relpath(filename)
> 
> I have CCed Oleg in case he spots any portability issues, but I think
> this should still work on Windows.

This use of posix_relpath() was pre-existing, so there shouldn't be
any new issues from this.

> 
> > +        out_fobj = open(filename, 'wt')
> >  
> >  def out(*lines, **kwargs):
> >      """Write a set of output lines.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-08-18 15:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 16:48 [PATCH v3 0/8] tracetool: add test suite to improve reviewability Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 1/8] checkpatch: cull trailing '*/' in SPDX check Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 2/8] tracetool: eliminate trailing whitespace in C format Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 3/8] tracetool: avoid space after "*" in arg types Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 4/8] tracetool: include SPDX-License-Identifier in generated files Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 5/8] tracetool: support "-" as a shorthand for stdout Daniel P. Berrangé
2025-08-07 19:46   ` Stefan Hajnoczi
2025-08-18 15:07     ` Daniel P. Berrangé [this message]
2025-08-18 17:55       ` Stefan Hajnoczi
2025-08-19 15:58         ` Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 6/8] tracetool: add test suite for tracetool with reference output Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 7/8] tracetool: drop the probe "__nocheck__" wrapping Daniel P. Berrangé
2025-08-06 16:48 ` [PATCH v3 8/8] qapi: switch to use QEMU_TEST_REGENERATE env var Daniel P. Berrangé
2025-08-08  6:46   ` Markus Armbruster
2025-08-18 15:09     ` Daniel P. Berrangé
2025-08-25 12:01       ` Markus Armbruster
2025-08-27 14:11         ` Daniel P. Berrangé
2025-08-07 20:06 ` [PATCH v3 0/8] tracetool: add test suite to improve reviewability Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aKNBsOekKkCSqgD7@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=mads@ynddal.dk \
    --cc=michael.roth@amd.com \
    --cc=oleg.tolmatcev@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.