From 5b77f1d5dc1808490e0e797256dca9bed4ee1445 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Sat, 14 May 2011 17:46:00 +0200 Subject: [PATCH] Fix error reporting in stream creation code 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 ea36bf5dd7..7b38a1953f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -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, diff --git a/daemon/stream.c b/daemon/stream.c index cada0a1fb7..48085da18f 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 787908e86d..62da46b38a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -11654,6 +11654,8 @@ virStreamNew(virConnectPtr conn, st = virGetStream(conn); if (st) st->flags = flags; + else + virDispatchError(conn); return st; }