提交 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, ...@@ -143,7 +143,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
virObjectEventStatePtr state, virObjectEventStatePtr state,
virNetworkPtr net, virNetworkPtr net,
int eventID, int eventID,
virConnectObjectEventGenericCallback cb, virConnectNetworkEventGenericCallback cb,
void *opaque, void *opaque,
virFreeCallback freecb, virFreeCallback freecb,
int *callbackID) int *callbackID)
...@@ -153,7 +153,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn, ...@@ -153,7 +153,8 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
return virObjectEventStateRegisterID(conn, state, net ? net->uuid : NULL, return virObjectEventStateRegisterID(conn, state, net ? net->uuid : NULL,
virNetworkEventClass, eventID, virNetworkEventClass, eventID,
cb, opaque, freecb, callbackID); VIR_OBJECT_EVENT_CALLBACK(cb),
opaque, freecb, callbackID);
} }
......
/* /*
* network_event.h: network event queue processing helpers * network_event.h: network event queue processing helpers
* *
* Copyright (C) 2014 Red Hat, Inc.
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. * Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -32,7 +33,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn, ...@@ -32,7 +33,7 @@ virNetworkEventStateRegisterID(virConnectPtr conn,
virObjectEventStatePtr state, virObjectEventStatePtr state,
virNetworkPtr net, virNetworkPtr net,
int eventID, int eventID,
virConnectObjectEventGenericCallback cb, virConnectNetworkEventGenericCallback cb,
void *opaque, void *opaque,
virFreeCallback freecb, virFreeCallback freecb,
int *callbackID); int *callbackID);
......
...@@ -2310,8 +2310,7 @@ networkConnectNetworkEventRegisterAny(virConnectPtr conn, ...@@ -2310,8 +2310,7 @@ networkConnectNetworkEventRegisterAny(virConnectPtr conn,
goto cleanup; goto cleanup;
if (virNetworkEventStateRegisterID(conn, driver->networkEventState, if (virNetworkEventStateRegisterID(conn, driver->networkEventState,
net, eventID, net, eventID, callback,
VIR_OBJECT_EVENT_CALLBACK(callback),
opaque, freecb, &ret) < 0) opaque, freecb, &ret) < 0)
ret = -1; ret = -1;
......
...@@ -2928,8 +2928,7 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn, ...@@ -2928,8 +2928,7 @@ remoteConnectNetworkEventRegisterAny(virConnectPtr conn,
remoteDriverLock(priv); remoteDriverLock(priv);
if ((count = virNetworkEventStateRegisterID(conn, priv->eventState, if ((count = virNetworkEventStateRegisterID(conn, priv->eventState,
net, eventID, net, eventID, callback,
VIR_OBJECT_EVENT_CALLBACK(callback),
opaque, freecb, opaque, freecb,
&callbackID)) < 0) &callbackID)) < 0)
goto done; goto done;
......
...@@ -6113,8 +6113,7 @@ testConnectNetworkEventRegisterAny(virConnectPtr conn, ...@@ -6113,8 +6113,7 @@ testConnectNetworkEventRegisterAny(virConnectPtr conn,
testDriverLock(driver); testDriverLock(driver);
if (virNetworkEventStateRegisterID(conn, driver->eventState, if (virNetworkEventStateRegisterID(conn, driver->eventState,
net, eventID, net, eventID, callback,
VIR_OBJECT_EVENT_CALLBACK(callback),
opaque, freecb, &ret) < 0) opaque, freecb, &ret) < 0)
ret = -1; ret = -1;
testDriverUnlock(driver); testDriverUnlock(driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册