]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix error reporting in stream creation code
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 14 May 2011 15:46:00 +0000 (17:46 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 17 May 2011 12:54:54 +0000 (14:54 +0200)
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
daemon/stream.c
src/libvirt.c

index ea36bf5dd75b84ae37547c94d31a0f79b076a1f1..7b38a1953f848126b70c53e4f5cd46c050c032cd 100644 (file)
@@ -1191,10 +1191,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,
@@ -3054,10 +3052,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,
index cada0a1fb75c2c9c03a17c58101d8f775f9e79ea..48085da18fb3f746fac62f243ab98c81303e9e5a 100644 (file)
@@ -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;
index 787908e86db74bd70039ec2194948aad6a36865c..62da46b38a2752aba6d093e2620c43483227697e 100644 (file)
@@ -11654,6 +11654,8 @@ virStreamNew(virConnectPtr conn,
     st = virGetStream(conn);
     if (st)
         st->flags = flags;
+    else
+        virDispatchError(conn);
 
     return st;
 }