• Subject: [libvirt] [PATCH] daemonStreamHandleWriteData: Preserve error when aborting stream
  • Author: Michal Privoznik
  • Date: March 12, 2018, 9:32 a.m.
  • Patches: 1 / 1
Changeset
src/remote/remote_daemon_stream.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Git apply log
Switched to a new branch '7dc43499f0e15bf977acf2f3670d0d4470048dd9.1520847112.git.mprivozn@redhat.com'
Applying: daemonStreamHandleWriteData: Preserve error when aborting stream
Using index info to reconstruct a base tree...
M	src/remote/remote_daemon_stream.c
Falling back to patching base and 3-way merge...
Auto-merging src/remote/remote_daemon_stream.c
CONFLICT (content): Merge conflict in src/remote/remote_daemon_stream.c
error: Failed to merge in the changes.
Patch failed at 0001 daemonStreamHandleWriteData: Preserve error when aborting stream
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Failed to apply patch:
[libvirt] [PATCH] daemonStreamHandleWriteData: Preserve error when aborting stream
Test passed: syntax-check

loading

[libvirt] [PATCH] daemonStreamHandleWriteData: Preserve error when aborting stream
Posted by Michal Privoznik, 14 weeks ago
The daemonStreamHandleWriteData() function is called whenever
server side of stream is able to receive some data. Nevertheless,
it calls virStreamSend() (to pass data down to virFDStream) and
depending on its return value it may abort the stream. However,
the functions it called when doing so are public APIs and as such
reset any error set previously. Therefore, if there was any error
in writing data to stream (i.e. repored in virStreamSend) it is
reset before virNetServerProgramSendReplyError() can get to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/remote/remote_daemon_stream.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 4dd3af9e0..532afd856 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -549,8 +549,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
     } else if (ret == -2) {
         /* Blocking, so indicate we have more todo later */
         return 1;
-    } else {
+    } else if (ret < 0) {
         virNetMessageError rerr;
+        virErrorPtr err = virSaveLastError();
 
         memset(&rerr, 0, sizeof(rerr));
 
@@ -558,7 +559,10 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
         stream->closed = true;
         virStreamEventRemoveCallback(stream->st);
         virStreamAbort(stream->st);
-
+        if (err) {
+            virSetError(err);
+            virFreeError(err);
+        }
         return virNetServerProgramSendReplyError(stream->prog,
                                                  client,
                                                  msg,
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] daemonStreamHandleWriteData: Preserve error when aborting stream
Posted by Andrea Bolognani, 14 weeks ago
On Mon, 2018-03-12 at 10:32 +0100, Michal Privoznik wrote:
> The daemonStreamHandleWriteData() function is called whenever
> server side of stream is able to receive some data. Nevertheless,
> it calls virStreamSend() (to pass data down to virFDStream) and
> depending on its return value it may abort the stream. However,
> the functions it called when doing so are public APIs and as such
> reset any error set previously. Therefore, if there was any error
> in writing data to stream (i.e. repored in virStreamSend) it is
> reset before virNetServerProgramSendReplyError() can get to it.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/remote/remote_daemon_stream.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
> index 4dd3af9e0..532afd856 100644
> --- a/src/remote/remote_daemon_stream.c
> +++ b/src/remote/remote_daemon_stream.c
> @@ -549,8 +549,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
>      } else if (ret == -2) {
>          /* Blocking, so indicate we have more todo later */
>          return 1;
> -    } else {
> +    } else if (ret < 0) {
>          virNetMessageError rerr;
> +        virErrorPtr err = virSaveLastError();
>  
>          memset(&rerr, 0, sizeof(rerr));
>  
> @@ -558,7 +559,10 @@ daemonStreamHandleWriteData(virNetServerClientPtr client,
>          stream->closed = true;
>          virStreamEventRemoveCallback(stream->st);
>          virStreamAbort(stream->st);
> -

Don't drop the empty line here...

> +        if (err) {
> +            virSetError(err);
> +            virFreeError(err);
> +        }

... and feel free to add one here :)

>          return virNetServerProgramSendReplyError(stream->prog,
>                                                   client,
>                                                   msg,

Reviewed-by: Andrea Bolognani <abologna@redhat.com>


-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list