[libvirt] [PATCH 0/4] Prepare remote driver client for data streams

This patch series does a small amount of refactoring to the remote driver client to aid in supporting data streams Daniel P. Berrange (4): Refactor incoming message handling to prepare for data stream support Refactor message sending to allow code reuse for data streams Simplify remote driver error reporting Rename a bunch of internal methods to clarify their meaning src/remote_internal.c | 366 ++++++++++++++++++++++++------------------------- 1 files changed, 181 insertions(+), 185 deletions(-) -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

* src/remote_internal.c: Rename processCallRecvMsg to processCallDispatch, and move code specific to method replies into processCallDispatchReply, and rename processCallAsyncEvent to processCallDispatchMessage Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/remote_internal.c | 136 +++++++++++++++++++++++++++++-------------------- 1 files changed, 80 insertions(+), 56 deletions(-) diff --git a/src/remote_internal.c b/src/remote_internal.c index e661daa..4362521 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -6564,29 +6564,6 @@ processCallRecvSome(virConnectPtr conn, struct private_data *priv, } -static void -processCallAsyncEvent(virConnectPtr conn, struct private_data *priv, - int in_open, - remote_message_header *hdr, - XDR *xdr) { - /* An async message has come in while we were waiting for the - * response. Process it to pull it off the wire, and try again - */ - DEBUG0("Encountered an event while waiting for a response"); - - if (in_open) { - DEBUG("Ignoring bogus event %d received while in open", hdr->proc); - return; - } - - if (hdr->proc == REMOTE_PROC_DOMAIN_EVENT) { - remoteDomainQueueEvent(conn, xdr); - virEventUpdateTimeout(priv->eventFlushTimer, 0); - } else { - DEBUG("Unexpected event proc %d", hdr->proc); - } -} - static int processCallRecvLen(virConnectPtr conn, struct private_data *priv, int in_open) { @@ -6625,12 +6602,25 @@ processCallRecvLen(virConnectPtr conn, struct private_data *priv, static int -processCallRecvMsg(virConnectPtr conn, struct private_data *priv, - int in_open) { +processCallDispatchReply(virConnectPtr conn, struct private_data *priv, + int in_open, + remote_message_header *hdr, + XDR *xdr); + +static int +processCallDispatchMessage(virConnectPtr conn, struct private_data *priv, + int in_open, + remote_message_header *hdr, + XDR *xdr); + + +static int +processCallDispatch(virConnectPtr conn, struct private_data *priv, + int in_open) { XDR xdr; struct remote_message_header hdr; int len = priv->bufferLength - 4; - struct remote_thread_call *thecall; + int rv = -1; /* Deserialise reply header. */ xdrmem_create (&xdr, priv->buffer + 4, len, XDR_DECODE); @@ -6658,30 +6648,44 @@ processCallRecvMsg(virConnectPtr conn, struct private_data *priv, return -1; } - /* Async events from server need special handling */ - if (hdr.type == REMOTE_MESSAGE) { - processCallAsyncEvent(conn, priv, in_open, - &hdr, &xdr); - xdr_destroy(&xdr); - return 0; - } + switch (hdr.type) { + case REMOTE_REPLY: /* Normal RPC replies */ + rv = processCallDispatchReply(conn, priv, in_open, + &hdr, &xdr); + break; - if (hdr.type != REMOTE_REPLY) { - virRaiseError (in_open ? NULL : conn, - NULL, NULL, VIR_FROM_REMOTE, - VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, - _("got unexpected RPC call %d from server"), - hdr.proc); - xdr_destroy(&xdr); - return -1; + case REMOTE_MESSAGE: /* Async notifications */ + rv = processCallDispatchMessage(conn, priv, in_open, + &hdr, &xdr); + break; + + default: + virRaiseError (in_open ? NULL : conn, + NULL, NULL, VIR_FROM_REMOTE, + VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, + _("got unexpected RPC call %d from server"), + hdr.proc); + rv = -1; + break; } + xdr_destroy(&xdr); + return rv; +} + + +static int +processCallDispatchReply(virConnectPtr conn, struct private_data *priv, + int in_open, + remote_message_header *hdr, + XDR *xdr) { + struct remote_thread_call *thecall; + /* Ok, definitely got an RPC reply now find out who's been waiting for it */ - thecall = priv->waitDispatch; while (thecall && - thecall->serial != hdr.serial) + thecall->serial != hdr->serial) thecall = thecall->next; if (!thecall) { @@ -6689,18 +6693,16 @@ processCallRecvMsg(virConnectPtr conn, struct private_data *priv, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("no call waiting for reply with serial %d"), - hdr.serial); - xdr_destroy(&xdr); + hdr->serial); return -1; } - if (hdr.proc != thecall->proc_nr) { + if (hdr->proc != thecall->proc_nr) { virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown procedure (received %x, expected %x)"), - hdr.proc, thecall->proc_nr); - xdr_destroy (&xdr); + hdr->proc, thecall->proc_nr); return -1; } @@ -6708,25 +6710,23 @@ processCallRecvMsg(virConnectPtr conn, struct private_data *priv, * structure), or REMOTE_ERROR (and what follows is a remote_error * structure). */ - switch (hdr.status) { + switch (hdr->status) { case REMOTE_OK: - if (!(*thecall->ret_filter) (&xdr, thecall->ret)) { + if (!(*thecall->ret_filter) (xdr, thecall->ret)) { error (in_open ? NULL : conn, VIR_ERR_RPC, _("unmarshalling ret")); return -1; } thecall->mode = REMOTE_MODE_COMPLETE; - xdr_destroy (&xdr); return 0; case REMOTE_ERROR: memset (&thecall->err, 0, sizeof thecall->err); - if (!xdr_remote_error (&xdr, &thecall->err)) { + if (!xdr_remote_error (xdr, &thecall->err)) { error (in_open ? NULL : conn, VIR_ERR_RPC, _("unmarshalling remote_error")); return -1; } - xdr_destroy (&xdr); thecall->mode = REMOTE_MODE_ERROR; return 0; @@ -6734,10 +6734,34 @@ processCallRecvMsg(virConnectPtr conn, struct private_data *priv, virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown status (received %x)"), - hdr.status); - xdr_destroy (&xdr); + hdr->status); + return -1; + } +} + +static int +processCallDispatchMessage(virConnectPtr conn, struct private_data *priv, + int in_open, + remote_message_header *hdr, + XDR *xdr) { + /* An async message has come in while we were waiting for the + * response. Process it to pull it off the wire, and try again + */ + DEBUG0("Encountered an event while waiting for a response"); + + if (in_open) { + DEBUG("Ignoring bogus event %d received while in open", hdr->proc); return -1; } + + if (hdr->proc == REMOTE_PROC_DOMAIN_EVENT) { + remoteDomainQueueEvent(conn, xdr); + virEventUpdateTimeout(priv->eventFlushTimer, 0); + } else { + return -1; + DEBUG("Unexpected event proc %d", hdr->proc); + } + return 0; } @@ -6770,7 +6794,7 @@ processCallRecv(virConnectPtr conn, struct private_data *priv, * next iteration. */ } else { - ret = processCallRecvMsg(conn, priv, in_open); + ret = processCallDispatch(conn, priv, in_open); priv->bufferOffset = priv->bufferLength = 0; /* * We've completed one call, so return even -- 1.6.2.5 -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Jul 14, 2009 at 11:49:15AM +0100, Daniel P. Berrange wrote:
* src/remote_internal.c: Rename processCallRecvMsg to processCallDispatch, and move code specific to method replies into processCallDispatchReply, and rename processCallAsyncEvent to processCallDispatchMessage
diff output doesn't make renaming obvious, but looks fine ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Splits up the 'call' method moving generic IO code out into separate method to allow it to be easily reused for sending data streams * src/remote_internal.c: Split 'call' into two methods, the first with same name serializes a set of method arguments into a message, the second 'remoteIO' takes a pre-serialized messages, sends it and awaits a reply Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/remote_internal.c | 60 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/remote_internal.c b/src/remote_internal.c index 4362521..eefead0 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -6943,7 +6943,7 @@ error: } /* - * This function performs a remote procedure call to procedure PROC_NR. + * This function sends a message to remote server and awaits a reply * * NB. This does not free the args structure (not desirable, since you * often want this allocated on the stack or else it contains strings @@ -6976,24 +6976,16 @@ error: * NB(5) Don't Panic! */ static int -call (virConnectPtr conn, struct private_data *priv, - int flags /* if we are in virConnectOpen */, - int proc_nr, - xdrproc_t args_filter, char *args, - xdrproc_t ret_filter, char *ret) +remoteIO(virConnectPtr conn, + struct private_data *priv, + int flags, + struct remote_thread_call *thiscall) { int rv; - struct remote_thread_call *thiscall; - - DEBUG("Doing call %d %p", proc_nr, priv->waitDispatch); - thiscall = prepareCall(conn, priv, flags, proc_nr, - args_filter, args, - ret_filter, ret); - if (!thiscall) { - virReportOOMError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn); - return -1; - } + DEBUG("Do proc=%d serial=%d length=%d wait=%p", + thiscall->proc_nr, thiscall->serial, + thiscall->bufferLength, priv->waitDispatch); /* Check to see if another thread is dispatching */ if (priv->waitDispatch) { @@ -7010,7 +7002,7 @@ call (virConnectPtr conn, struct private_data *priv, /* Force other thread to wakup from poll */ safewrite(priv->wakeupSendFD, &ignore, sizeof(ignore)); - DEBUG("Going to sleep %d %p %p", proc_nr, priv->waitDispatch, thiscall); + DEBUG("Going to sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall); /* Go to sleep while other thread is working... */ if (virCondWait(&thiscall->cond, &priv->lock) < 0) { if (priv->waitDispatch == thiscall) { @@ -7031,7 +7023,7 @@ call (virConnectPtr conn, struct private_data *priv, return -1; } - DEBUG("Wokeup from sleep %d %p %p", proc_nr, priv->waitDispatch, thiscall); + DEBUG("Wokeup from sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall); /* Two reasons we can be woken up * 1. Other thread has got our reply ready for us * 2. Other thread is all done, and it is our turn to @@ -7055,7 +7047,7 @@ call (virConnectPtr conn, struct private_data *priv, priv->waitDispatch = thiscall; } - DEBUG("We have the buck %d %p %p", proc_nr, priv->waitDispatch, thiscall); + DEBUG("We have the buck %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall); /* * The buck stops here! * @@ -7086,7 +7078,7 @@ call (virConnectPtr conn, struct private_data *priv, } cleanup: - DEBUG("All done with our call %d %p %p", proc_nr, priv->waitDispatch, thiscall); + DEBUG("All done with our call %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall); if (thiscall->mode == REMOTE_MODE_ERROR) { /* See if caller asked us to keep quiet about missing RPCs * eg for interop with older servers */ @@ -7110,6 +7102,34 @@ cleanup: return rv; } + +/* + * Serial a set of arguments into a method call message, + * send that to the server and wait for reply + */ +static int +call (virConnectPtr conn, struct private_data *priv, + int flags /* if we are in virConnectOpen */, + int proc_nr, + xdrproc_t args_filter, char *args, + xdrproc_t ret_filter, char *ret) +{ + struct remote_thread_call *thiscall; + + thiscall = prepareCall(conn, priv, flags, proc_nr, + args_filter, args, + ret_filter, ret); + + if (!thiscall) { + virReportOOMError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn); + return -1; + } + + return remoteIO(conn, priv, flags, thiscall); +} + + + /** * remoteDomainReadEvent * -- 1.6.2.5 -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Jul 14, 2009 at 11:49:39AM +0100, Daniel P. Berrange wrote:
Splits up the 'call' method moving generic IO code out into separate method to allow it to be easily reused for sending data streams
* src/remote_internal.c: Split 'call' into two methods, the first with same name serializes a set of method arguments into a message, the second 'remoteIO' takes a pre-serialized messages, sends it and awaits a reply
Okay, this is a simple split, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Remove redundant error reporting functions which obscured the filename/line number reporting. Removed code which created a virDomain/virNetwork object, since those are silently dropped in error reporting functions now * src/remote_internal.c: Remove error() and errorf() in favour of macros, and remove server_error in favour of direct call Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/remote_internal.c | 84 ++++++++++-------------------------------------- 1 files changed, 18 insertions(+), 66 deletions(-) diff --git a/src/remote_internal.c b/src/remote_internal.c index eefead0..76032ae 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -206,10 +206,13 @@ static int remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in static int remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open, virConnectAuthPtr auth); #endif /* HAVE_POLKIT */ -static void error (virConnectPtr conn, virErrorNumber code, const char *info); -static void errorf (virConnectPtr conn, virErrorNumber code, - const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 3, 4); -static void server_error (virConnectPtr conn, remote_error *err); +#define error(conn, code, info) \ + virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ + __FUNCTION__, __LINE__, "%s", info) +#define errorf(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ + __FUNCTION__, __LINE__, fmt) + static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain); static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network); static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface); @@ -7090,8 +7093,17 @@ cleanup: STRPREFIX(*thiscall->err.message, "unknown procedure")) { rv = -2; } else { - server_error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, - &thiscall->err); + virRaiseErrorFull(flags & REMOTE_CALL_IN_OPEN ? NULL : conn, + __FILE__, __FUNCTION__, __LINE__, + thiscall->err.domain, + thiscall->err.code, + thiscall->err.level, + thiscall->err.str1 ? *thiscall->err.str1 : NULL, + thiscall->err.str2 ? *thiscall->err.str2 : NULL, + thiscall->err.str3 ? *thiscall->err.str3 : NULL, + thiscall->err.int1, + thiscall->err.int2, + "%s", thiscall->err.message ? *thiscall->err.message : NULL); rv = -1; } xdr_free((xdrproc_t)xdr_remote_error, (char *)&thiscall->err); @@ -7236,66 +7248,6 @@ remoteDomainEventQueueFlush(int timer ATTRIBUTE_UNUSED, void *opaque) } -/* For errors internal to this library. */ -static void -error (virConnectPtr conn, virErrorNumber code, const char *info) -{ - const char *errmsg; - - errmsg = virErrorMsg (code, info); - virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, - code, VIR_ERR_ERROR, errmsg, info, NULL, 0, 0, - errmsg, info); -} - -/* For errors internal to this library. - Identical to the above, but with a format string and optional params. */ -static void -errorf (virConnectPtr conn, virErrorNumber code, const char *fmt, ...) -{ - const char *errmsg; - va_list args; - char errorMessage[256]; - - if (fmt) { - va_start(args, fmt); - vsnprintf(errorMessage, sizeof errorMessage - 1, fmt, args); - va_end(args); - } else { - errorMessage[0] = '\0'; - } - - errmsg = virErrorMsg (code, errorMessage); - virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, - code, VIR_ERR_ERROR, - errmsg, errorMessage, NULL, -1, -1, - errmsg, errorMessage); -} - -/* For errors generated on the server side and sent back to us. */ -static void -server_error (virConnectPtr conn, remote_error *err) -{ - virDomainPtr dom; - virNetworkPtr net; - - /* Get the domain and network, if set. */ - dom = err->dom ? get_nonnull_domain (conn, *err->dom) : NULL; - net = err->net ? get_nonnull_network (conn, *err->net) : NULL; - - virRaiseError (conn, dom, net, - err->domain, err->code, err->level, - err->str1 ? *err->str1 : NULL, - err->str2 ? *err->str2 : NULL, - err->str3 ? *err->str3 : NULL, - err->int1, err->int2, - "%s", err->message ? *err->message : NULL); - if (dom) - virDomainFree(dom); - if (net) - virNetworkFree(net); -} - /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. * These can return NULL if underlying memory allocations fail, -- 1.6.2.5 -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Jul 14, 2009 at 11:50:04AM +0100, Daniel P. Berrange wrote:
Remove redundant error reporting functions which obscured the filename/line number reporting. Removed code which created a virDomain/virNetwork object, since those are silently dropped in error reporting functions now
* src/remote_internal.c: Remove error() and errorf() in favour of macros, and remove server_error in favour of direct call
Cleanups, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

This renames a lot of the methods in the remote driver client to more accurately reflect their responsibility of IO handling vs message handling. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/remote_internal.c | 86 ++++++++++++++++++++++++------------------------ 1 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/remote_internal.c b/src/remote_internal.c index 76032ae..389a595 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -6314,10 +6314,10 @@ error: static int -processCallWrite(virConnectPtr conn, - struct private_data *priv, - int in_open /* if we are in virConnectOpen */, - const char *bytes, int len) +remoteIOWriteBuffer(virConnectPtr conn, + struct private_data *priv, + int in_open /* if we are in virConnectOpen */, + const char *bytes, int len) { int ret; @@ -6355,10 +6355,10 @@ processCallWrite(virConnectPtr conn, static int -processCallRead(virConnectPtr conn, - struct private_data *priv, - int in_open /* if we are in virConnectOpen */, - char *bytes, int len) +remoteIOReadBuffer(virConnectPtr conn, + struct private_data *priv, + int in_open /* if we are in virConnectOpen */, + char *bytes, int len) { int ret; @@ -6409,10 +6409,10 @@ processCallRead(virConnectPtr conn, static int -processCallSendOne(virConnectPtr conn, - struct private_data *priv, - int in_open, - struct remote_thread_call *thecall) +remoteIOWriteMessage(virConnectPtr conn, + struct private_data *priv, + int in_open, + struct remote_thread_call *thecall) { #if HAVE_SASL if (priv->saslconn) { @@ -6438,9 +6438,9 @@ processCallSendOne(virConnectPtr conn, thecall->bufferOffset = thecall->bufferLength; } - ret = processCallWrite(conn, priv, in_open, - priv->saslEncoded + priv->saslEncodedOffset, - priv->saslEncodedLength - priv->saslEncodedOffset); + ret = remoteIOWriteBuffer(conn, priv, in_open, + priv->saslEncoded + priv->saslEncodedOffset, + priv->saslEncodedLength - priv->saslEncodedOffset); if (ret < 0) return ret; priv->saslEncodedOffset += ret; @@ -6453,9 +6453,9 @@ processCallSendOne(virConnectPtr conn, } else { #endif int ret; - ret = processCallWrite(conn, priv, in_open, - thecall->buffer + thecall->bufferOffset, - thecall->bufferLength - thecall->bufferOffset); + ret = remoteIOWriteBuffer(conn, priv, in_open, + thecall->buffer + thecall->bufferOffset, + thecall->bufferLength - thecall->bufferOffset); if (ret < 0) return ret; thecall->bufferOffset += ret; @@ -6472,8 +6472,8 @@ processCallSendOne(virConnectPtr conn, static int -processCallSend(virConnectPtr conn, struct private_data *priv, - int in_open) { +remoteIOHandleOutput(virConnectPtr conn, struct private_data *priv, + int in_open) { struct remote_thread_call *thecall = priv->waitDispatch; while (thecall && @@ -6484,7 +6484,7 @@ processCallSend(virConnectPtr conn, struct private_data *priv, return -1; /* Shouldn't happen, but you never know... */ while (thecall) { - int ret = processCallSendOne(conn, priv, in_open, thecall); + int ret = remoteIOWriteMessage(conn, priv, in_open, thecall); if (ret < 0) return ret; @@ -6498,7 +6498,7 @@ processCallSend(virConnectPtr conn, struct private_data *priv, } static int -processCallRecvSome(virConnectPtr conn, struct private_data *priv, +remoteIOReadMessage(virConnectPtr conn, struct private_data *priv, int in_open) { unsigned int wantData; @@ -6514,8 +6514,8 @@ processCallRecvSome(virConnectPtr conn, struct private_data *priv, char encoded[8192]; unsigned int encodedLen = sizeof(encoded); int ret, err; - ret = processCallRead(conn, priv, in_open, - encoded, encodedLen); + ret = remoteIOReadBuffer(conn, priv, in_open, + encoded, encodedLen); if (ret < 0) return -1; if (ret == 0) @@ -6550,9 +6550,9 @@ processCallRecvSome(virConnectPtr conn, struct private_data *priv, #endif int ret; - ret = processCallRead(conn, priv, in_open, - priv->buffer + priv->bufferOffset, - wantData); + ret = remoteIOReadBuffer(conn, priv, in_open, + priv->buffer + priv->bufferOffset, + wantData); if (ret < 0) return -1; if (ret == 0) @@ -6568,8 +6568,8 @@ processCallRecvSome(virConnectPtr conn, struct private_data *priv, static int -processCallRecvLen(virConnectPtr conn, struct private_data *priv, - int in_open) { +remoteIODecodeMessageLength(virConnectPtr conn, struct private_data *priv, + int in_open) { XDR xdr; unsigned int len; @@ -6769,14 +6769,14 @@ processCallDispatchMessage(virConnectPtr conn, struct private_data *priv, static int -processCallRecv(virConnectPtr conn, struct private_data *priv, - int in_open) +remoteIOHandleInput(virConnectPtr conn, struct private_data *priv, + int in_open) { /* Read as much data as is available, until we get * EAGAIN */ for (;;) { - int ret = processCallRecvSome(conn, priv, in_open); + int ret = remoteIOReadMessage(conn, priv, in_open); if (ret < 0) return -1; @@ -6786,7 +6786,7 @@ processCallRecv(virConnectPtr conn, struct private_data *priv, /* Check for completion of our goal */ if (priv->bufferOffset == priv->bufferLength) { if (priv->bufferOffset == 4) { - ret = processCallRecvLen(conn, priv, in_open); + ret = remoteIODecodeMessageLength(conn, priv, in_open); if (ret < 0) return -1; @@ -6818,10 +6818,10 @@ processCallRecv(virConnectPtr conn, struct private_data *priv, * to someone else. */ static int -processCalls(virConnectPtr conn, - struct private_data *priv, - int in_open, - struct remote_thread_call *thiscall) +remoteIOEventLoop(virConnectPtr conn, + struct private_data *priv, + int in_open, + struct remote_thread_call *thiscall) { struct pollfd fds[2]; int ret; @@ -6871,12 +6871,12 @@ processCalls(virConnectPtr conn, } if (fds[0].revents & POLLOUT) { - if (processCallSend(conn, priv, in_open) < 0) + if (remoteIOHandleOutput(conn, priv, in_open) < 0) goto error; } if (fds[0].revents & POLLIN) { - if (processCallRecv(conn, priv, in_open) < 0) + if (remoteIOHandleInput(conn, priv, in_open) < 0) goto error; } @@ -7068,9 +7068,9 @@ remoteIO(virConnectPtr conn, if (priv->watch >= 0) virEventUpdateHandle(priv->watch, 0); - rv = processCalls(conn, priv, - flags & REMOTE_CALL_IN_OPEN ? 1 : 0, - thiscall); + rv = remoteIOEventLoop(conn, priv, + flags & REMOTE_CALL_IN_OPEN ? 1 : 0, + thiscall); if (priv->watch >= 0) virEventUpdateHandle(priv->watch, VIR_EVENT_HANDLE_READABLE); @@ -7225,7 +7225,7 @@ remoteDomainEventFired(int watch, goto done; } - if (processCallRecv(conn, priv, 0) < 0) + if (remoteIOHandleInput(conn, priv, 0) < 0) DEBUG0("Something went wrong during async message processing"); done: -- 1.6.2.5 -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Jul 14, 2009 at 11:50:24AM +0100, Daniel P. Berrange wrote:
This renames a lot of the methods in the remote driver client to more accurately reflect their responsibility of IO handling vs message handling.
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard