Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Changes | 1 +
Virt.xs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
lib/Sys/Virt/Domain.pm | 6 ++++++
t/030-api-coverage.t | 1 +
4 files changed, 56 insertions(+)
diff --git a/Changes b/Changes
index aee699d..4d6136f 100644
--- a/Changes
+++ b/Changes
@@ -11,6 +11,7 @@ Revision history for perl module Sys::Virt
- Add PERF_PARAM_PAGE_FAULTS_MAJ constant
- Add PERF_PARAM_ALIGNMENT_FAULTS constant
- Add PERF_PARAM_EMULATION_FAULTS constant
+ - Add block threshold event
3.1.0 2017-03-03
diff --git a/Virt.xs b/Virt.xs
index e80182f..e0588f0 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -1136,6 +1136,50 @@ _domain_event_metadata_change_callback(virConnectPtr con,
static int
+_domain_event_block_threshold_callback(virConnectPtr con,
+ virDomainPtr dom,
+ const char *dev,
+ const char *path,
+ unsigned long long threshold,
+ unsigned long long excess,
+ void *opaque)
+{
+ AV *data = opaque;
+ SV **self;
+ SV **cb;
+ SV *domref;
+ dSP;
+
+ self = av_fetch(data, 0, 0);
+ cb = av_fetch(data, 1, 0);
+
+ SvREFCNT_inc(*self);
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ XPUSHs(*self);
+ domref = sv_newmortal();
+ sv_setref_pv(domref, "Sys::Virt::Domain", (void *) dom);
+ virDomainRef(dom);
+ XPUSHs(domref);
+ XPUSHs(sv_2mortal(newSVpv(dev, 0)));
+ XPUSHs(sv_2mortal(newSVpv(path, 0)));
+ XPUSHs(sv_2mortal(newSViv(threshold)));
+ XPUSHs(sv_2mortal(newSViv(excess)));
+ PUTBACK;
+
+ call_sv(*cb, G_DISCARD);
+
+ FREETMPS;
+ LEAVE;
+
+ return 0;
+}
+
+
+static int
_network_event_lifecycle_callback(virConnectPtr con,
virNetworkPtr net,
int event,
@@ -3375,6 +3419,9 @@ PREINIT:
case VIR_DOMAIN_EVENT_ID_METADATA_CHANGE:
callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_metadata_change_callback);
break;
+ case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD:
+ callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_block_threshold_callback);
+ break;
default:
callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_generic_callback);
break;
@@ -8384,6 +8431,7 @@ BOOT:
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, EVENT_ID_JOB_COMPLETED);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED,
EVENT_ID_DEVICE_REMOVAL_FAILED);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, EVENT_ID_METADATA_CHANGE);
+ REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, EVENT_ID_BLOCK_THRESHOLD);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_NONE, EVENT_WATCHDOG_NONE);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_PAUSE, EVENT_WATCHDOG_PAUSE);
diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index eea8b26..b46eca1 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -3274,6 +3274,12 @@ Guest device removal has failed.
The domain metadata has changed
+=item Sys::Virt::Domain::EVENT_ID_BLOCK_THRESHOLD
+
+The event occurs when the hypervisor detects that the given
+storage element was written beyond the point specified by
+threshold. The event is useful for thin-provisioned storage.
+
=back
=head2 IO ERROR EVENT CONSTANTS
diff --git a/t/030-api-coverage.t b/t/030-api-coverage.t
index 3a0d0c5..3049713 100644
--- a/t/030-api-coverage.t
+++ b/t/030-api-coverage.t
@@ -95,6 +95,7 @@ virConnectDomainEventMigrationIterationCallback
virConnectDomainEventJobCompletedCallback
virConnectDomainEventDeviceRemovalFailedCallback
virConnectDomainEventMetadataChangeCallback
+virConnectDomainEventBlockThresholdCallback
virConnectNetworkEventLifecycleCallback
--
2.10.2