[libvirt-perl][PATCH 1/3] Adapt to new virDomain{Get, Set}PerfEvents()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also, add support for new constants introduced with the APIs.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 Changes                |  1 +
 Virt.xs                | 38 ++++++++++++++++++++++++++++++++++++++
 lib/Sys/Virt/Domain.pm | 32 ++++++++++++++++++++++++++++++++
 lib/Sys/Virt/Error.pm  |  4 ++++
 4 files changed, 75 insertions(+)

diff --git a/Changes b/Changes
index 2f86a3d..ad463c2 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
+ - Adapt to new virDomainGetPerfEvents() and virDomainSetPerfEvents() and corresponding constants
 
 1.3.2 2016-03-01
 
diff --git a/Virt.xs b/Virt.xs
index 3664521..1e82545 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -5551,6 +5551,40 @@ DESTROY(dom_rv)
 	sv_setiv((SV*)SvRV(dom_rv), 0);
       }
 
+HV *
+get_perf_events(dom, flags=0)
+      virDomainPtr dom;
+      unsigned int flags;
+  PREINIT:
+      virTypedParameter *params = NULL;
+      int nparams;
+     CODE:
+      if (virDomainGetPerfEvents(dom, &params, &nparams, flags) < 0)
+          _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;
+   PPCODE:
+      if (virDomainGetPerfEvents(dom, &params, &nparams, flags) < 0)
+          _croak_error();
+
+      nparams = vir_typed_param_from_hv(newparams, params, nparams);
+
+      if (virDomainSetPerfEvents(dom, params, nparams, flags) < 0)
+          _croak_error();
+      Safefree(params);
 
 MODULE = Sys::Virt::Network  PACKAGE = Sys::Virt::Network
 
@@ -7639,6 +7673,7 @@ BOOT:
       REGISTER_CONSTANT(VIR_DOMAIN_STATS_BLOCK, STATS_BLOCK);
       REGISTER_CONSTANT(VIR_DOMAIN_STATS_CPU_TOTAL, STATS_CPU_TOTAL);
       REGISTER_CONSTANT(VIR_DOMAIN_STATS_INTERFACE, STATS_INTERFACE);
+      REGISTER_CONSTANT(VIR_DOMAIN_STATS_PERF, STATS_PERF);
       REGISTER_CONSTANT(VIR_DOMAIN_STATS_STATE, STATS_STATE);
       REGISTER_CONSTANT(VIR_DOMAIN_STATS_VCPU, STATS_VCPU);
 
@@ -8102,6 +8137,8 @@ BOOT:
 
       REGISTER_CONSTANT(VIR_DOMAIN_PASSWORD_ENCRYPTED, PASSWORD_ENCRYPTED);
 
+      REGISTER_CONSTANT_STR(VIR_PERF_PARAM_CMT, PERF_CMT);
+
       stash = gv_stashpv( "Sys::Virt::DomainSnapshot", TRUE );
       REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, DELETE_CHILDREN);
       REGISTER_CONSTANT(VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, DELETE_METADATA_ONLY);
@@ -8368,6 +8405,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..519e681 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -1825,6 +1825,21 @@ C<$signum> value must be one of the constants listed
 later, not a POSIX or Linux signal value. C<$flags>
 is currently unused and defaults to zero.
 
+=item my @events = $dom->get_perf_events($flags=0);
+
+Returns a hash reference containing the set of performance events
+settings for the guest. The keys in the hash are one of the
+constants DOMAIN PERF 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 performance events settings for the guest. The C<$params>
+should be a hash reference whose keys are one of the DOMAIN PERF
+constants. The C<$flags> parameter accepts one or more the CONFIG
+OPTION constants documented later, and defaults to 0 if omitted.
+
 =back
 
 =head1 CONSTANTS
@@ -3617,6 +3632,10 @@ The total time in userspace
 
 The total vCPU time.
 
+=item Sys:Virt::Domain::STATS_PERF
+
+The domain perf info
+
 =back
 
 =head2 CPU STATS CONSTANTS
@@ -4093,6 +4112,19 @@ The I/O threads pinning
 
 =back
 
+=head2 DOMAIN PERF CONSTANTS
+
+The following constants are useful when accessing domain
+performance events settings.
+
+=over 4
+
+=item Sys::Virt::Domain::PERF_CMT
+
+The CMT perf event source
+
+=back
+
 =head1 AUTHORS
 
 Daniel P. Berrange <berrange@xxxxxxxxxx>
diff --git a/lib/Sys/Virt/Error.pm b/lib/Sys/Virt/Error.pm
index 3f6b058..0a722e6 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 perf setting subsystem
+
 =back
 
 =head2 ERROR CODE CONSTANTS
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]