[libvirt] [PATCH v2 3/3] iohelper: Don't include newlines in error messages

Andrea Bolognani abologna at redhat.com
Tue Feb 19 13:44:25 UTC 2019


On Mon, 2019-02-18 at 11:05 -0500, John Ferlan wrote:
> On 2/13/19 7:04 AM, Andrea Bolognani wrote:
> > The newline was pretty arbitrary, and we're better off
> > without it.
> 
> I'm mostly ambivalent about this one; however, since
> virGetLastErrorMessage could return a string without a "\n", then
> perhaps it's best to keep the \n since it really doesn't hurt.

Without this patch, the user will end up seeing

  $ sudo virsh dump guest /small/guest.dump --memory-only
  error: Failed to core dump domain guest to /small/guest.dump
  error: operation failed: /usr/libexec/libvirt_iohelper: failure with /small/guest.dump
  : Unable to write /small/guest.dump: No space left on device

instead of the more reasonable

  $ sudo virsh dump guest /small/guest.dump --memory-only
  error: Failed to core dump domain guest to /small/guest.dump
  error: operation failed: /usr/libexec/libvirt_iohelper: failure with /small/guest.dump: Unable to write /small/guest.dump: No space left on device

Now, neither is optimal and the way libvirt_iohelper formats its
error messages should be tweaked further, but at least in the latter
case the error is not split randomly with the second line starting
with a colon, which is an improvement in my book.

I was also unable to find other examples of messages passed to
virReportError(), which is what will ultimately happen to this
output, containing newlines. To be fair, I have not really spent a
lot of time looking for them either :)

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list