[PATCH 3/5] Fix error reporting in stream creation code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virStreamNew needs to dispatch the error that virGetStream reports
on failure.

remoteCreateClientStream can fail due to virStreamNew or due to
VIR_ALLOC. Report OOM error for VIR_ALLOC failure to report errors
in all error cases.

Remove OOM error reporting from remoteCreateClientStream callers.
---
 daemon/remote.c |    8 ++------
 daemon/stream.c |    7 ++++++-
 src/libvirt.c   |    2 ++
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 6e13958..e3bd4a2 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1190,10 +1190,8 @@ remoteDispatchDomainMigratePrepareTunnel(struct qemud_server *server ATTRIBUTE_U
 
     dname = args->dname == NULL ? NULL : *args->dname;
 
-    if (!(stream = remoteCreateClientStream(conn, hdr))) {
-        virReportOOMError();
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
         goto cleanup;
-    }
 
     if (virDomainMigratePrepareTunnel(conn, stream->st,
                                       args->flags, dname, args->resource,
@@ -3014,10 +3012,8 @@ remoteDispatchDomainOpenConsole(struct qemud_server *server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(conn, args->dom)))
         goto cleanup;
 
-    if (!(stream = remoteCreateClientStream(conn, hdr))) {
-        virReportOOMError();
+    if (!(stream = remoteCreateClientStream(conn, hdr)))
         goto cleanup;
-    }
 
     if (virDomainOpenConsole(dom,
                              args->devname ? *args->devname : NULL,
diff --git a/daemon/stream.c b/daemon/stream.c
index cada0a1..48085da 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -27,6 +27,9 @@
 #include "memory.h"
 #include "dispatch.h"
 #include "logging.h"
+#include "virterror_internal.h"
+
+#define VIR_FROM_THIS VIR_FROM_STREAMS
 
 static int
 remoteStreamHandleWrite(struct qemud_client *client,
@@ -209,8 +212,10 @@ remoteCreateClientStream(virConnectPtr conn,
 
     VIR_DEBUG("proc=%d serial=%d", hdr->proc, hdr->serial);
 
-    if (VIR_ALLOC(stream) < 0)
+    if (VIR_ALLOC(stream) < 0) {
+        virReportOOMError();
         return NULL;
+    }
 
     stream->procedure = hdr->proc;
     stream->serial = hdr->serial;
diff --git a/src/libvirt.c b/src/libvirt.c
index 6325188..7dec5a6 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -11050,6 +11050,8 @@ virStreamNew(virConnectPtr conn,
     st = virGetStream(conn);
     if (st)
         st->flags = flags;
+    else
+        virDispatchError(conn);
 
     return st;
 }
-- 
1.7.0.4

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]