Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Changes | 3 ++-
Virt.xs | 42 ++++++++++++++++++++++++++++++++++++++++++
lib/Sys/Virt/Domain.pm | 4 ++++
t/030-api-coverage.t | 1 +
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/Changes b/Changes
index 35ec792..a299dc7 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,8 @@ Revision history for perl module Sys::Virt
1.2.15 2015-00-00
- - ...
+ - Add support for VIR_DOMAIN_EVENT_ID_DEVICE_ADDED
+ event callback & constants.
1.2.14 2015-04-09
diff --git a/Virt.xs b/Virt.xs
index 4b3ba9a..40a5ee8 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -858,6 +858,44 @@ _domain_event_balloonchange_callback(virConnectPtr con,
static int
+_domain_event_device_added_callback(virConnectPtr con,
+ virDomainPtr dom,
+ const char *devAlias,
+ 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(devAlias, 0)));
+ PUTBACK;
+
+ call_sv(*cb, G_DISCARD);
+
+ FREETMPS;
+ LEAVE;
+
+ return 0;
+}
+
+
+static int
_domain_event_device_removed_callback(virConnectPtr con,
virDomainPtr dom,
const char *devAlias,
@@ -2942,6 +2980,9 @@ PREINIT:
case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE:
callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_balloonchange_callback);
break;
+ case VIR_DOMAIN_EVENT_ID_DEVICE_ADDED:
+ callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_added_callback);
+ break;
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_removed_callback);
break;
@@ -7563,6 +7604,7 @@ BOOT:
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_PMWAKEUP, EVENT_ID_PMWAKEUP);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, EVENT_ID_TRAY_CHANGE);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, EVENT_ID_BALLOON_CHANGE);
+ REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DEVICE_ADDED, EVENT_ID_DEVICE_ADDED);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, EVENT_ID_DEVICE_REMOVED);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_TUNABLE, EVENT_ID_TUNABLE);
REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE, EVENT_ID_AGENT_LIFECYCLE);
diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index 7e2d0c0..2bf3f8b 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -2791,6 +2791,10 @@ Power management initiated wakeup
Balloon target changes
+=item Sys::Virt::Domain::EVENT_ID_DEVICE_ADDED
+
+Asynchronous guest device addition
+
=item Sys::Virt::Domain::EVENT_ID_DEVICE_REMOVED
Asynchronous guest device removal
diff --git a/t/030-api-coverage.t b/t/030-api-coverage.t
index 592f1d3..9ce6155 100644
--- a/t/030-api-coverage.t
+++ b/t/030-api-coverage.t
@@ -87,6 +87,7 @@ virConnectDomainEventPMSuspendDiskCallback
virConnectDomainEventPMWakeupCallback
virConnectDomainEventTrayChangeCallback
virConnectDomainEventBalloonChangeCallback
+virConnectDomainEventDeviceAddedCallback
virConnectDomainEventDeviceRemovedCallback
virConnectDomainEventTunableCallback
virConnectDomainEventAgentLifecycleCallback
--
2.0.5