mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lib: Introduce event for tracking disk backing file write threshold
When using thin provisioning, management tools need to resize the disk in certain cases. To avoid having them to poll disk usage introduce an event which will be fired when a given offset of the storage is written by the hypervisor. Together with the API which will be added later, it will allow registering thresholds for given storage backing volumes and this event will then notify management if the threshold is exceeded.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
|
||||
#define STREQ(a, b) (strcmp(a, b) == 0)
|
||||
#define NULLSTR(s) ((s) ? (s) : "<null>")
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||
@@ -924,6 +925,23 @@ myDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
myDomainEventBlockThresholdCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainPtr dom,
|
||||
const char *dev,
|
||||
const char *path,
|
||||
unsigned long long threshold,
|
||||
unsigned long long excess,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
printf("%s EVENT: Domain %s(%d) block threshold callback dev '%s'(%s), "
|
||||
"threshold: '%llu', excess: '%llu'",
|
||||
__func__, virDomainGetName(dom), virDomainGetID(dom),
|
||||
dev, NULLSTR(path), threshold, excess);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
myDomainEventMigrationIterationCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainPtr dom,
|
||||
@@ -1053,6 +1071,7 @@ struct domainEventData domainEvents[] = {
|
||||
DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, myDomainEventJobCompletedCallback),
|
||||
DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, myDomainEventDeviceRemovalFailedCallback),
|
||||
DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, myDomainEventMetadataChangeCallback),
|
||||
DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, myDomainEventBlockThresholdCallback),
|
||||
};
|
||||
|
||||
struct storagePoolEventData {
|
||||
|
||||
Reference in New Issue
Block a user