This patch makes the remote driver behave properly in the face of:
(a) no registered EventImpl, or
(b) an EventImpl that returns failure from AddHandle/Timeout
In both cases, we now cleanup properly (rather than always passing bogus
values to virEventRemoveHandle/Timeout) and fail attempts to register
for domain events (w/VIR_ERR_NO_SUPPORT rather than blissfully continue
when we can't possibly deliver events).
Dave
remote_internal.c | 15 +++
1 file changed, 11 insertions(+), 4 deletions(-)
commit 02239f3e0fedf1c3860826f13efe356223b38e3c
Author: David Lively [EMAIL PROTECTED]
Date: Thu Nov 20 16:35:08 2008 -0500
vi-patch: remote-refuse-useless-event-registration
Made the remote driver's DomainEventRegister return an error if events
not supported (e.g., because there's no proper EventImpl registered).
Also, cleanup properly in this case, both in doRemoteOpen and
doRemoteClose.
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 7ca6ec1..7124d0a 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -773,6 +773,7 @@ doRemoteOpen (virConnectPtr conn,
conn, NULL)) 0) {
DEBUG0(virEventAddTimeout failed: No addTimeoutImpl defined.
continuing without events.);
+virEventRemoveHandle(priv-watch);
}
}
/* Successful. */
@@ -1209,10 +1210,12 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
(xdrproc_t) xdr_void, (char *) NULL) == -1)
return -1;
-/* Remove handle for remote events */
-virEventRemoveHandle(priv-sock);
-/* Remove timout */
-virEventRemoveTimeout(priv-eventFlushTimer);
+if (priv-eventFlushTimer = 0) {
+/* Remove timeout */
+virEventRemoveTimeout(priv-eventFlushTimer);
+/* Remove handle for remote events */
+virEventRemoveHandle(priv-watch);
+}
/* Close socket. */
if (priv-uses_tls priv-session) {
@@ -4481,6 +4484,10 @@ static int remoteDomainEventRegister (virConnectPtr conn,
{
struct private_data *priv = conn-privateData;
+if (priv-eventFlushTimer 0) {
+ error (conn, VIR_ERR_NO_SUPPORT, _(no event support));
+ return -1;
+}
if (virDomainEventCallbackListAdd(conn, priv-callbackList,
callback, opaque, freecb) 0) {
error (conn, VIR_ERR_RPC, _(adding cb to list));
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list