提交 bb7513ea 编写于 作者: J Jovanka Gulicoska 提交者: Cole Robinson

node_device: implement node device lifecycle event APIs

上级 9b13df37
......@@ -31,6 +31,7 @@
# include "virthread.h"
# include "virpci.h"
# include "device_conf.h"
# include "object_event.h"
# include <libxml/tree.h>
......@@ -229,6 +230,9 @@ struct _virNodeDeviceDriverState {
virNodeDeviceObjList devs; /* currently-known devices */
void *privateData; /* driver-specific private data */
/* Immutable pointer, self-locking APIs */
virObjectEventStatePtr nodeDeviceEventState;
};
......
......@@ -35,6 +35,7 @@
#include "virfile.h"
#include "virstring.h"
#include "node_device_conf.h"
#include "node_device_event.h"
#include "node_device_driver.h"
#include "node_device_hal.h"
#include "node_device_linux_sysfs.h"
......@@ -677,6 +678,47 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
return ret;
}
int
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
virNodeDevicePtr dev,
int eventID,
virConnectNodeDeviceEventGenericCallback callback,
void *opaque,
virFreeCallback freecb)
{
int callbackID = -1;
if (virConnectNodeDeviceEventRegisterAnyEnsureACL(conn) < 0)
goto cleanup;
if (virNodeDeviceEventStateRegisterID(conn, driver->nodeDeviceEventState,
dev, eventID, callback,
opaque, freecb, &callbackID) < 0)
callbackID = -1;
cleanup:
return callbackID;
}
int
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
int callbackID)
{
int ret = -1;
if (virConnectNodeDeviceEventDeregisterAnyEnsureACL(conn) < 0)
goto cleanup;
if (virObjectEventStateDeregisterID(conn,
driver->nodeDeviceEventState,
callbackID) < 0)
goto cleanup;
ret = 0;
cleanup:
return ret;
}
int nodedevRegister(void)
{
#ifdef WITH_UDEV
......
......@@ -63,4 +63,14 @@ virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn,
const char *xmlDesc, unsigned int flags);
int nodeDeviceDestroy(virNodeDevicePtr dev);
int
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
virNodeDevicePtr dev,
int eventID,
virConnectNodeDeviceEventGenericCallback callback,
void *opaque,
virFreeCallback freecb);
int
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
int callbackID);
#endif /* __VIR_NODE_DEVICE_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册