The callbacks for VIR_DOMAIN_EVENT_ID_DEVICE_ADDED and _REMOVED
are identical. Reuse them as _domain_event_device_generic_callback.
---
Changes | 2 +-
Virt.xs | 44 +++-----------------------------------------
2 files changed, 4 insertions(+), 42 deletions(-)
diff --git a/Changes b/Changes
index 4548d5d..3a73bc8 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,7 @@ Revision history for perl module Sys::Virt
1.3.4 2016-00-00
- - XXX
+ - Reuse VIR_DOMAIN_EVENT_ID_DEVICE callbacks
1.3.3 2016-04-07
diff --git a/Virt.xs b/Virt.xs
index 50ed6cd..6da8f64 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -894,45 +894,7 @@ _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,
+_domain_event_device_generic_callback(virConnectPtr con,
virDomainPtr dom,
const char *devAlias,
void *opaque)
@@ -3098,10 +3060,10 @@ PREINIT:
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);
+ callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_generic_callback);
break;
case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
- callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_removed_callback);
+ callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_device_generic_callback);
break;
case VIR_DOMAIN_EVENT_ID_TUNABLE:
callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_tunable_callback);
--
2.7.3