Add binding for virDomainGetPerfEvents,
virDomainSetPerfEvents, VIR_DOMAIN_STATS_PERF,
VIR_PERF_PARAM_CMT, and VIR_FROM_PERF
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
Changes | 1 +
Virt.xs | 43 +++++++++++++++++++++++++++++++++++++++++++
lib/Sys/Virt/Domain.pm | 34 ++++++++++++++++++++++++++++++++++
lib/Sys/Virt/Error.pm | 4 ++++
4 files changed, 82 insertions(+)
diff --git a/Changes b/Changes
index 2f86a3d..8e08e3e 100644
--- a/Changes
+++ b/Changes
@@ -12,6 +12,7 @@ Revision history for perl module Sys::Virt
- Add VIR_MIGRATE_PARAM_DISKS_PORT constant
- Add virDomainMigrateStartPostCopy API support
- Add constants related to post-copy migration
+ - Add APIS & constants for new perf event support
1.3.2 2016-03-01
diff --git a/Virt.xs b/Virt.xs
index 3664521..50ed6cd 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -4213,6 +4213,46 @@ set_blkio_parameters(dom, newparams, flags=0)
Safefree(params);
+HV *
+get_perf_events(dom, flags=0)
+ virDomainPtr dom;
+ unsigned int flags;
+ PREINIT:
+ virTypedParameter *params = NULL;
+ int nparams = 0;
+ CODE:
+ if (virDomainGetPerfEvents(dom, ¶ms, &nparams, flags) < 0) {
+ Safefree(params);
+ _croak_error();
+ }
+
+ RETVAL = vir_typed_param_to_hv(params, nparams);
+ Safefree(params);
+ OUTPUT:
+ RETVAL
+
+
+void
+set_perf_events(dom, newparams, flags=0)
+ virDomainPtr dom;
+ HV *newparams;
+ unsigned int flags;
+ PREINIT:
+ virTypedParameter *params = NULL;
+ int nparams = 0;
+ PPCODE:
+ if (virDomainGetPerfEvents(dom, ¶ms, &nparams, flags) < 0) {
+ Safefree(params);
+ _croak_error();
+ }
+
+ nparams = vir_typed_param_from_hv(newparams, params, nparams);
+
+ if (virDomainSetPerfEvents(dom, params, nparams, flags) < 0)
+ _croak_error();
+ Safefree(params);
+
+
unsigned long
get_max_memory(dom)
virDomainPtr dom;
@@ -7641,6 +7681,7 @@ BOOT:
REGISTER_CONSTANT(VIR_DOMAIN_STATS_INTERFACE, STATS_INTERFACE);
REGISTER_CONSTANT(VIR_DOMAIN_STATS_STATE, STATS_STATE);
REGISTER_CONSTANT(VIR_DOMAIN_STATS_VCPU, STATS_VCPU);
+ REGISTER_CONSTANT(VIR_DOMAIN_STATS_PERF, STATS_PERF);
REGISTER_CONSTANT(VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE, GET_ALL_STATS_ACTIVE);
REGISTER_CONSTANT(VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE,
GET_ALL_STATS_INACTIVE);
@@ -7905,6 +7946,7 @@ BOOT:
REGISTER_CONSTANT(VIR_DOMAIN_NUMATUNE_MEM_PREFERRED, NUMATUNE_MEM_PREFERRED);
REGISTER_CONSTANT(VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE, NUMATUNE_MEM_INTERLEAVE);
+ REGISTER_CONSTANT_STR(VIR_PERF_PARAM_CMT, PERF_PARAM_CMT);
REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_IN_AVERAGE, BANDWIDTH_IN_AVERAGE);
REGISTER_CONSTANT_STR(VIR_DOMAIN_BANDWIDTH_IN_PEAK, BANDWIDTH_IN_PEAK);
@@ -8368,6 +8410,7 @@ BOOT:
REGISTER_CONSTANT(VIR_FROM_ADMIN, FROM_ADMIN);
REGISTER_CONSTANT(VIR_FROM_LOGGING, FROM_LOGGING);
REGISTER_CONSTANT(VIR_FROM_XENXL, FROM_XENXL);
+ REGISTER_CONSTANT(VIR_FROM_PERF, FROM_PERF);
REGISTER_CONSTANT(VIR_ERR_OK, ERR_OK);
diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index 26ead9b..b095dbd 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -812,6 +812,23 @@ of the NUMA PARAMETERS constants. The C<$flags>
parameter accepts one or more the CONFIG OPTION constants
documented later, and defaults to 0 if omitted.
+=item my $params = $dom->get_perf_events($flags=0)
+
+Return a hash reference containing the set of performance
+events that are available for the guest. The keys in the
+hash are one of the constants PERF EVENTS described later.
+The C<$flags> parameter accepts one or more the CONFIG
+OPTION constants documented later, and defaults to 0 if
+omitted.
+
+=item $dom->set_perf_events($params, $flags=0)
+
+Update the enabled state for performance events for the
+guest. The C<$params> should be a hash reference whose
+keys are one of the PERF EVENTS constants. The C<$flags>
+parameter accepts one or more the CONFIG OPTION constants
+documented later, and defaults to 0 if omitted.
+
=item $dom->block_resize($disk, $newsize, $flags=0)
Resize the disk C<$disk> to have new size C<$newsize> KB. If the disk
@@ -2588,6 +2605,19 @@ The burstable outbound bandwidth
=back
+=head2 PERF EVENTS
+
+The following constants defined performance events
+which can be monitored for a guest
+
+=over 4
+
+=item Sys::Virt::Domain::PERF_PARAM_CMT
+
+The CMT event counter
+
+=back
+
=head2 VCPU FLAGS
The following constants are useful when getting/setting the
@@ -3716,6 +3746,10 @@ General lifecycle state
Virtual CPU info
+=item Sys::Virt::Domain::STATS_PERF
+
+Performance event counter values
+
=back
=head2 PROCESS SIGNALS
diff --git a/lib/Sys/Virt/Error.pm b/lib/Sys/Virt/Error.pm
index 3f6b058..b54f876 100644
--- a/lib/Sys/Virt/Error.pm
+++ b/lib/Sys/Virt/Error.pm
@@ -394,6 +394,10 @@ The logging service
The Xen XL driver
+=item Sys::Virt::Error::FROM_PERF
+
+The performance events subsystem
+
=back
=head2 ERROR CODE CONSTANTS
--
2.5.5