]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStream*All: Preserve reported error
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 1 Jun 2017 06:40:10 +0000 (08:40 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 11 Jul 2017 06:59:04 +0000 (08:59 +0200)
If one these four functions fail (virStreamRecvAll,
virStreamSendAll, virStreamSparseRecvAll, virStreamSparseSendAll)
the stream is aborted by calling virStreamAbort(). This is  a
public API; therefore, the first thing it does is error reset. At
that point any error that caused us to abort stream in the first
place is gone.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/libvirt-stream.c

index b9125b66497e7e2f1f949ab00d09cedbce9e73e7..56e701de8ce1eaa9f9585265d8ecd8c2a2ffbd3d 100644 (file)
@@ -616,7 +616,12 @@ virStreamSendAll(virStreamPtr stream,
     VIR_FREE(bytes);
 
     if (ret != 0) {
+        virErrorPtr orig_err = virSaveLastError();
         virStreamAbort(stream);
+        if (orig_err) {
+            virSetError(orig_err);
+            virFreeError(orig_err);
+        }
         virDispatchError(stream->conn);
     }
 
@@ -771,7 +776,12 @@ int virStreamSparseSendAll(virStreamPtr stream,
     VIR_FREE(bytes);
 
     if (ret != 0) {
+        virErrorPtr orig_err = virSaveLastError();
         virStreamAbort(stream);
+        if (orig_err) {
+            virSetError(orig_err);
+            virFreeError(orig_err);
+        }
         virDispatchError(stream->conn);
     }
 
@@ -865,7 +875,12 @@ virStreamRecvAll(virStreamPtr stream,
     VIR_FREE(bytes);
 
     if (ret != 0) {
+        virErrorPtr orig_err = virSaveLastError();
         virStreamAbort(stream);
+        if (orig_err) {
+            virSetError(orig_err);
+            virFreeError(orig_err);
+        }
         virDispatchError(stream->conn);
     }
 
@@ -985,7 +1000,12 @@ virStreamSparseRecvAll(virStreamPtr stream,
     VIR_FREE(bytes);
 
     if (ret != 0) {
+        virErrorPtr orig_err = virSaveLastError();
         virStreamAbort(stream);
+        if (orig_err) {
+            virSetError(orig_err);
+            virFreeError(orig_err);
+        }
         virDispatchError(stream->conn);
     }