--- src/conf/node_device_conf.h | 4 ++++ src/node_device/node_device_driver.c | 42 ++++++++++++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 10 +++++++++ 3 files changed, 56 insertions(+) diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 9e3e6fe..8f23a98 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -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; }; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 500caeb..91bb142 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -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 diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 0f4ea57..56f89ab 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -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__ */ -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list