Logging the error is fine and all, but getting the information
to the user directly is even better.
https://bugzilla.redhat.com/show_bug.cgi?id=1578741
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
src/util/virfile.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 271bf5e796..30cad87df9 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -351,8 +351,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd)
if (!wfd)
return;
+ /* If the command used to process IO has produced errors, it's fair
+ * to assume those will be more relevant to the user than whatever
+ * eg. QEMU can figure out on its own, so it's okay if we end up
+ * discarding an existing error */
if (wfd->err_msg && *wfd->err_msg)
- VIR_WARN("iohelper reports: %s", wfd->err_msg);
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg);
virCommandAbort(wfd->cmd);
--
2.20.1
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 2/13/19 7:04 AM, Andrea Bolognani wrote: > Logging the error is fine and all, but getting the information > to the user directly is even better. > > https://bugzilla.redhat.com/show_bug.cgi?id=1578741 > Signed-off-by: Andrea Bolognani <abologna@redhat.com> > --- > src/util/virfile.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > Shall I assume this works because qemuProcessHandleDumpCompleted will move this message now as opposed to some other message related to EPIPE as noted in the bz response? I think it's good to fill in pieces of the commit message at least so if someone else ends up in this same code they have a few hints where to start. My other throughts would be to note commit 1f25194ad and 34e8f63a3 as the genesis of at least printing the message "somewhere"... Then commit b0c3e931 at least made sure the message got printed in the event that the *FdClose never occurred. Just saying "is fine and all" hand waves a bit too much for me compared to what you got to figure out here ;-). Reviewed-by: John Ferlan <jferlan@redhat.com> John > diff --git a/src/util/virfile.c b/src/util/virfile.c > index 271bf5e796..30cad87df9 100644 > --- a/src/util/virfile.c > +++ b/src/util/virfile.c > @@ -351,8 +351,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd) > if (!wfd) > return; > > + /* If the command used to process IO has produced errors, it's fair > + * to assume those will be more relevant to the user than whatever > + * eg. QEMU can figure out on its own, so it's okay if we end up > + * discarding an existing error */ > if (wfd->err_msg && *wfd->err_msg) > - VIR_WARN("iohelper reports: %s", wfd->err_msg); > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg); > > virCommandAbort(wfd->cmd); > > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Mon, 2019-02-18 at 11:04 -0500, John Ferlan wrote: > > On 2/13/19 7:04 AM, Andrea Bolognani wrote: > > Logging the error is fine and all, but getting the information > > to the user directly is even better. > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1578741 > > Signed-off-by: Andrea Bolognani <abologna@redhat.com> > > --- > > src/util/virfile.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > Shall I assume this works because qemuProcessHandleDumpCompleted will > move this message now as opposed to some other message related to EPIPE > as noted in the bz response? libvirt_iohelper is used internally by the virFileWrapperFd APIs; more specifically, in the QEMU driver we have the doCoreDump() and qemuDomainSaveMemory() helper functions as users, and those in turn end up being called by the implementation of several driver APIs. By calling virReportError() if libvirt_iohelper has failed, we overwrite whatever generic error message QEMU might have raised with the more useful one generated by the helper program. I'm not sure how qemuProcessHandleDumpCompleted() fits into the picture. > I think it's good to fill in pieces of the commit message at least so if > someone else ends up in this same code they have a few hints where to start. Yeah, I guess the commit message is a bit terse. Would adding something along the lines of the first two paragraphs above work, in your opinion? > My other throughts would be to note commit 1f25194ad and 34e8f63a3 as > the genesis of at least printing the message "somewhere"... Then commit > b0c3e931 at least made sure the message got printed in the event that > the *FdClose never occurred. Just saying "is fine and all" hand waves a > bit too much for me compared to what you got to figure out here ;-). Honestly, I didn't bother digging into the history of the functionality and simply fixed what was broken without really wondering how it ended up like that in the first place :) -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 2/19/19 8:27 AM, Andrea Bolognani wrote: > On Mon, 2019-02-18 at 11:04 -0500, John Ferlan wrote: >> >> On 2/13/19 7:04 AM, Andrea Bolognani wrote: >>> Logging the error is fine and all, but getting the information >>> to the user directly is even better. >>> >>> https://bugzilla.redhat.com/show_bug.cgi?id=1578741 >>> Signed-off-by: Andrea Bolognani <abologna@redhat.com> >>> --- >>> src/util/virfile.c | 6 +++++- >>> 1 file changed, 5 insertions(+), 1 deletion(-) >>> >> >> Shall I assume this works because qemuProcessHandleDumpCompleted will >> move this message now as opposed to some other message related to EPIPE >> as noted in the bz response? > > libvirt_iohelper is used internally by the virFileWrapperFd APIs; > more specifically, in the QEMU driver we have the doCoreDump() and > qemuDomainSaveMemory() helper functions as users, and those in turn > end up being called by the implementation of several driver APIs. > > By calling virReportError() if libvirt_iohelper has failed, we > overwrite whatever generic error message QEMU might have raised > with the more useful one generated by the helper program. > > I'm not sure how qemuProcessHandleDumpCompleted() fits into the > picture. > My recollection is/was event based mechanism and the HandleDumpCompleted was what ended up being where the message came through whether success or failure. Could be wrong - I perhaps had more in short term recall when I added some processing for memory dump event processing. >> I think it's good to fill in pieces of the commit message at least so if >> someone else ends up in this same code they have a few hints where to start. > > Yeah, I guess the commit message is a bit terse. Would adding > something along the lines of the first two paragraphs above work, > in your opinion? > Sure that's fine. I understand it doesn't mean someone will look at the commit message, but for those that do it can help. >> My other throughts would be to note commit 1f25194ad and 34e8f63a3 as >> the genesis of at least printing the message "somewhere"... Then commit >> b0c3e931 at least made sure the message got printed in the event that >> the *FdClose never occurred. Just saying "is fine and all" hand waves a >> bit too much for me compared to what you got to figure out here ;-). > > Honestly, I didn't bother digging into the history of the > functionality and simply fixed what was broken without really > wondering how it ended up like that in the first place :) > Thankfully gitk makes it easy for me to trace through the history. I know everyone has their favorite blame tools. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Wed, Feb 13, 2019 at 01:04:07PM +0100, Andrea Bolognani wrote: > Logging the error is fine and all, but getting the information > to the user directly is even better. > > https://bugzilla.redhat.com/show_bug.cgi?id=1578741 > Signed-off-by: Andrea Bolognani <abologna@redhat.com> > --- > src/util/virfile.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/util/virfile.c b/src/util/virfile.c > index 271bf5e796..30cad87df9 100644 > --- a/src/util/virfile.c > +++ b/src/util/virfile.c > @@ -351,8 +351,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd) > if (!wfd) > return; > > + /* If the command used to process IO has produced errors, it's fair > + * to assume those will be more relevant to the user than whatever > + * eg. QEMU can figure out on its own, so it's okay if we end up > + * discarding an existing error */ > if (wfd->err_msg && *wfd->err_msg) > - VIR_WARN("iohelper reports: %s", wfd->err_msg); > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg); I don't think this is a good place to report errors. We normally write xxxxFree() functions such that they always succeed & don't report errors. Essentially they should just be cleaning up memory and other allocated resources. This is especially true now that we rely on GCC cleanup functions which automagically call virFileWrapperFdFree when the variable goes out of scope. IOW, if we need to report an error from the io helper, then it needs to be done earlier, pehrpas in virFileWrapperFdClose ? 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 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, 2019-02-19 at 13:58 +0000, Daniel P. Berrangé wrote: > On Wed, Feb 13, 2019 at 01:04:07PM +0100, Andrea Bolognani wrote: [...] > > @@ -351,8 +351,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd) > > if (!wfd) > > return; > > > > + /* If the command used to process IO has produced errors, it's fair > > + * to assume those will be more relevant to the user than whatever > > + * eg. QEMU can figure out on its own, so it's okay if we end up > > + * discarding an existing error */ > > if (wfd->err_msg && *wfd->err_msg) > > - VIR_WARN("iohelper reports: %s", wfd->err_msg); > > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg); > > I don't think this is a good place to report errors. We normally > write xxxxFree() functions such that they always succeed & don't > report errors. Essentially they should just be cleaning up memory > and other allocated resources. This is especially true now that > we rely on GCC cleanup functions which automagically call > virFileWrapperFdFree when the variable goes out of scope. > > IOW, if we need to report an error from the io helper, then it > needs to be done earlier, pehrpas in virFileWrapperFdClose ? As John noted, that's what the original implementation looked like but commit b0c3e931 moved the VIR_WARN() call from Close() to Free() to avoid the situation where jumping out from a function early results in the former not being called. That said, I agree with you that in general we don't want our Free() function to do anything more than release the allocated memory. To get there, though, it looks like some reworking is needed... I'll try to make it work. -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, Feb 19, 2019 at 04:42:51PM +0100, Andrea Bolognani wrote: > On Tue, 2019-02-19 at 13:58 +0000, Daniel P. Berrangé wrote: > > On Wed, Feb 13, 2019 at 01:04:07PM +0100, Andrea Bolognani wrote: > [...] > > > @@ -351,8 +351,12 @@ virFileWrapperFdFree(virFileWrapperFdPtr wfd) > > > if (!wfd) > > > return; > > > > > > + /* If the command used to process IO has produced errors, it's fair > > > + * to assume those will be more relevant to the user than whatever > > > + * eg. QEMU can figure out on its own, so it's okay if we end up > > > + * discarding an existing error */ > > > if (wfd->err_msg && *wfd->err_msg) > > > - VIR_WARN("iohelper reports: %s", wfd->err_msg); > > > + virReportError(VIR_ERR_OPERATION_FAILED, "%s", wfd->err_msg); > > > > I don't think this is a good place to report errors. We normally > > write xxxxFree() functions such that they always succeed & don't > > report errors. Essentially they should just be cleaning up memory > > and other allocated resources. This is especially true now that > > we rely on GCC cleanup functions which automagically call > > virFileWrapperFdFree when the variable goes out of scope. > > > > IOW, if we need to report an error from the io helper, then it > > needs to be done earlier, pehrpas in virFileWrapperFdClose ? > > As John noted, that's what the original implementation looked like > but commit b0c3e931 moved the VIR_WARN() call from Close() to Free() > to avoid the situation where jumping out from a function early > results in the former not being called. I think we should really just revert that commit and make sure the callers will invoke Close() in all paths & then make Close use virReportError instead of WARN. 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 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Tue, 2019-02-19 at 15:49 +0000, Daniel P. Berrangé wrote: > On Tue, Feb 19, 2019 at 04:42:51PM +0100, Andrea Bolognani wrote: > > On Tue, 2019-02-19 at 13:58 +0000, Daniel P. Berrangé wrote: > > > IOW, if we need to report an error from the io helper, then it > > > needs to be done earlier, pehrpas in virFileWrapperFdClose ? > > > > As John noted, that's what the original implementation looked like > > but commit b0c3e931 moved the VIR_WARN() call from Close() to Free() > > to avoid the situation where jumping out from a function early > > results in the former not being called. > > I think we should really just revert that commit and make sure > the callers will invoke Close() in all paths & then make Close > use virReportError instead of WARN. Yeah, that's basically what I'm gonna try to do in v3 :) -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2024 Red Hat, Inc.