提交 36dd0bd8 编写于 作者: E Eric Blake

event: make network events easier to use without casts

While comparing network and domain events, I noticed that the
test driver had to do a cast in one place and not the other.
For consistency, we should hide the necessary casting as low
as possible in the stack, with everything else using saner
types.

* src/conf/network_event.h (virNetworkEventStateRegisterID): Alter
type.
* src/conf/network_event.c (virNetworkEventStateRegisterID): Hoist
cast here.
* src/test/test_driver.c (testConnectNetworkEventRegisterAny):
Simplify callers.
* src/remote/remote_driver.c
(remoteConnectNetworkEventRegisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventRegisterAny): Likewise.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 e9568360
......@@ -143,7 +143,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
virObjectEventStatePtr state,
virNetworkPtr net,
int eventID,
virConnectObjectEventGenericCallback cb,
virConnectNetworkEventGenericCallback cb,
void *opaque,
virFreeCallback freecb,
int *callbackID)
......@@ -153,7 +153,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
return virObjectEventStateRegisterID(conn, state, net ? net->uuid : NULL,
virNetworkEventClass, eventID,
cb, opaque, freecb, callbackID);
VIR_OBJECT_EVENT_CALLBACK(cb),
opaque, freecb, callbackID);
}
......
/*
* network_event.h: network event queue processing helpers
*
* Copyright (C) 2014 Red Hat, Inc.
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
......@@ -32,7 +33,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
virObjectEventStatePtr state,
virNetworkPtr net,
int eventID,
virConnectObjectEventGenericCallback cb,
virConnectNetworkEventGenericCallback cb,
void *opaque,
virFreeCallback freecb,
int *callbackID);
......
......@@ -2310,8 +2310,7 @@ networkConnectNetworkEventRegisterAny(virConnectPtr conn,
goto cleanup;
if (virNetworkEventStateRegisterID(conn, driver->networkEventState,
net, eventID,
VIR_OBJECT_EVENT_CALLBACK(callback),
net, eventID, callback,
opaque, freecb, &ret) < 0)
ret = -1;
......
......@@ -2928,8 +2928,7 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn,
remoteDriverLock(priv);
if ((count = virNetworkEventStateRegisterID(conn, priv->eventState,
net, eventID,
VIR_OBJECT_EVENT_CALLBACK(callback),
net, eventID, callback,
opaque, freecb,
&callbackID)) < 0)
goto done;
......
......@@ -6113,8 +6113,7 @@ testConnectNetworkEventRegisterAny(virConnectPtr conn,
testDriverLock(driver);
if (virNetworkEventStateRegisterID(conn, driver->eventState,
net, eventID,
VIR_OBJECT_EVENT_CALLBACK(callback),
net, eventID, callback,
opaque, freecb, &ret) < 0)
ret = -1;
testDriverUnlock(driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册