All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Ladi Prosek <lprosek@redhat.com>
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Fernando Casas Schössow" <casasfernando@hotmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Jason Wang" <jasowang@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Greg Kurz" <groug@kaod.org>,
	arei.gonglei@huawei.com, aneesh.kumar@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2 1/8] qemu-error: introduce error_report_nolf
Date: Mon, 17 Jul 2017 09:58:04 +0100	[thread overview]
Message-ID: <20170717085804.GC3640@redhat.com> (raw)
In-Reply-To: <CABdb7341GwdRQA1B54zcZTrVNaZt57OWSwCY098spF-bJom=fw@mail.gmail.com>

On Mon, Jul 17, 2017 at 08:54:18AM +0200, Ladi Prosek wrote:
> On Fri, Jul 14, 2017 at 12:41 PM, Daniel P. Berrange
> <berrange@redhat.com> wrote:
> > On Thu, Jul 13, 2017 at 02:32:06PM +0100, Stefan Hajnoczi wrote:
> >> On Thu, Jul 13, 2017 at 01:02:30PM +0200, Ladi Prosek wrote:
> >> > +/*
> >> > + * Print an error message to current monitor if we have one, else to stderr.
> >> > + * Format arguments like sprintf().  The resulting message should be a
> >> > + * single phrase, with no trailing punctuation.  The no-LF version allows
> >> > + * additional text to be appended with error_printf() or error_vprintf().
> >> > + * Make sure to always close with a newline after all text is printed.
> >> > + * Prepends the current location.
> >> > + * It's wrong to call this in a QMP monitor.  Use error_setg() there.
> >> > + */
> >> > +void error_report_nolf(const char *fmt, ...)
> >> > +{
> >> > +    va_list ap;
> >> > +
> >> > +    va_start(ap, fmt);
> >> > +    error_vreport_nolf(fmt, ap);
> >> > +    va_end(ap);
> >> >  }
> >>
> >> Each call to this function prepends the timestamp, so it cannot really
> >> be used for a sequence of prints in a single line.
> >>
> >> It's a little ugly but I expected something along the lines of
> >> g_strdup_vprintf() in virtio_error():
> >>
> >>   char *msg;
> >>
> >>   va_start(ap, fmt);
> >>   msg = g_strdup_vprintf(fmt, ap);
> >>   va_end(ap);
> >>
> >>   error_report("%s: %s", DEVICE(vdev)->id, msg);
> >>
> >>   g_free(msg);
> >
> > You could get the same thing by turning virtio_Error into a macro with
> > a few games. Rename the current method to virtio_error_impl() and then
> > define:
> >
> >   #define virtio_error(dev, fmt, ...) \
> >      virtio_error_impl(dev, "%s: " fmt, DEVICE(dev)->id, __VA_ARGS__)
> 
> Neat! I think I'll stick with a function though. This doesn't allocate
> but it adds a little bit of code to each call site which has the
> potential of slowing down the fast no-error path (I have no data, just
> the general keeping-the-code-compact-is-good principle). Holler if you
> disagree!

IMHO that would be uneccessary optimization, particular since this is in
the error scenario and so is not performance critical to normal operation.

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:[~2017-07-17  8:58 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 11:02 [Qemu-devel] [PATCH v2 0/8] virtio: enhance virtio_error messages Ladi Prosek
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 1/8] qemu-error: introduce error_report_nolf Ladi Prosek
2017-07-13 13:32   ` Stefan Hajnoczi
2017-07-13 13:48     ` Ladi Prosek
2017-07-14 10:25       ` Stefan Hajnoczi
2017-07-15  5:50         ` Markus Armbruster
2017-07-17  6:43           ` Ladi Prosek
2017-07-14 10:41     ` Daniel P. Berrange
2017-07-17  6:54       ` Ladi Prosek
2017-07-17  8:58         ` Daniel P. Berrange [this message]
2017-07-17  9:30           ` Ladi Prosek
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 2/8] virtio: enhance virtio_error messages Ladi Prosek
2017-07-13 13:40   ` Stefan Hajnoczi
2017-07-13 13:58     ` Ladi Prosek
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 3/8] virtio: introduce virtqueue_error Ladi Prosek
2017-07-13 14:42   ` Cornelia Huck
2017-07-13 15:02     ` Ladi Prosek
2017-07-14 10:28   ` Stefan Hajnoczi
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 4/8] virtio-9p: use virtqueue_error for errors with queue context Ladi Prosek
2017-07-13 14:21   ` Greg Kurz
2017-07-13 14:49   ` Cornelia Huck
2017-07-14 10:29   ` Stefan Hajnoczi
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 5/8] virtio-blk: " Ladi Prosek
2017-07-13 14:54   ` Cornelia Huck
2017-07-14 10:29   ` Stefan Hajnoczi
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 6/8] virtio-net: " Ladi Prosek
2017-07-13 15:00   ` Cornelia Huck
2017-07-14 10:30   ` Stefan Hajnoczi
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 7/8] virtio-scsi: " Ladi Prosek
2017-07-13 15:03   ` Cornelia Huck
2017-07-14 10:30   ` Stefan Hajnoczi
2017-07-13 11:02 ` [Qemu-devel] [PATCH v2 8/8] virtio-crypto: " Ladi Prosek
2017-07-13 15:20   ` Cornelia Huck
2017-07-13 15:31     ` Ladi Prosek
2017-07-13 15:36       ` Cornelia Huck
2017-07-14  0:51         ` Gonglei (Arei)
2017-07-14 10:31   ` Stefan Hajnoczi
2017-07-13 14:36 ` [Qemu-devel] [PATCH v2 0/8] virtio: enhance virtio_error messages Greg Kurz
2017-07-13 15:00   ` Ladi Prosek

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=20170717085804.GC3640@redhat.com \
    --to=berrange@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=casasfernando@hotmail.com \
    --cc=groug@kaod.org \
    --cc=jasowang@redhat.com \
    --cc=lprosek@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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.