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.
This commit is contained in:
Matthias Bolte 2011-05-14 17:46:00 +02:00
parent 55cb8f5baa
commit 5b77f1d5dc
3 changed files with 10 additions and 7 deletions

View 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,

View 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;

View File

@ -11654,6 +11654,8 @@ virStreamNew(virConnectPtr conn,
st = virGetStream(conn);
if (st)
st->flags = flags;
else
virDispatchError(conn);
return st;
}