mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
node_device: implement node device lifecycle event APIs
This commit is contained in:
parent
9b13df379c
commit
bb7513eae2
@ -31,6 +31,7 @@
|
|||||||
# include "virthread.h"
|
# include "virthread.h"
|
||||||
# include "virpci.h"
|
# include "virpci.h"
|
||||||
# include "device_conf.h"
|
# include "device_conf.h"
|
||||||
|
# include "object_event.h"
|
||||||
|
|
||||||
# include <libxml/tree.h>
|
# include <libxml/tree.h>
|
||||||
|
|
||||||
@ -229,6 +230,9 @@ struct _virNodeDeviceDriverState {
|
|||||||
|
|
||||||
virNodeDeviceObjList devs; /* currently-known devices */
|
virNodeDeviceObjList devs; /* currently-known devices */
|
||||||
void *privateData; /* driver-specific private data */
|
void *privateData; /* driver-specific private data */
|
||||||
|
|
||||||
|
/* Immutable pointer, self-locking APIs */
|
||||||
|
virObjectEventStatePtr nodeDeviceEventState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
#include "node_device_conf.h"
|
#include "node_device_conf.h"
|
||||||
|
#include "node_device_event.h"
|
||||||
#include "node_device_driver.h"
|
#include "node_device_driver.h"
|
||||||
#include "node_device_hal.h"
|
#include "node_device_hal.h"
|
||||||
#include "node_device_linux_sysfs.h"
|
#include "node_device_linux_sysfs.h"
|
||||||
@ -677,6 +678,47 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
|
|||||||
return ret;
|
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)
|
int nodedevRegister(void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_UDEV
|
#ifdef WITH_UDEV
|
||||||
|
@ -63,4 +63,14 @@ virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn,
|
|||||||
const char *xmlDesc, unsigned int flags);
|
const char *xmlDesc, unsigned int flags);
|
||||||
int nodeDeviceDestroy(virNodeDevicePtr dev);
|
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__ */
|
#endif /* __VIR_NODE_DEVICE_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user