[libvirt] [libvirt-perl][PATCH 0/3] Adapt to new virDomain{Get, Set}PerfEvents API

It would be nice to have these in before the release. Michal Privoznik (3): Adapt to new virDomain{Get,Set}PerfEvents() gitignore: Add more files to ignore & reorder Add myself to AUTHORS .gitignore | 17 ++++++++++------- AUTHORS | 1 + Changes | 1 + Virt.xs | 38 ++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 32 ++++++++++++++++++++++++++++++++ lib/Sys/Virt/Error.pm | 4 ++++ 6 files changed, 86 insertions(+), 7 deletions(-) -- 2.7.3

Also, add support for new constants introduced with the APIs. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- 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, ¶ms, &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, ¶ms, &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@redhat.com> 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

For instance, on my system not just META.yml is produced by MYMETA.yml and MYMETA.json too. Also, if you happen to generate tags or use vim to edit the source code, you'll find some files useless to track in git. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index a10217c..dc0ba62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,17 @@ -blib/ -pm_to_blib +*.swp +*~ +MANIFEST +META.yml +MYMETA.* Makefile Makefile.old -*~ +Sys-Virt-*.tar.gz Virt.bs Virt.c Virt.o -perl-Sys-Virt.spec -Sys-Virt-*.tar.gz -MANIFEST +blib/ cover_db -META.yml +perl-Sys-Virt.spec +pm_to_blib results.log +tags -- 2.7.3

On Sat, Apr 02, 2016 at 04:45:23PM +0200, Michal Privoznik wrote:
For instance, on my system not just META.yml is produced by MYMETA.yml and MYMETA.json too. Also, if you happen to generate tags or use vim to edit the source code, you'll find some files useless to track in git.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index c2af49a..cb96cdc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,5 +13,6 @@ Patches contributed by: Ludwig Nussel <ludwig-dot-nussel-at-suse-dot-de> Zhe Peng <zpeng-at-redhat-dot-com> Osier Yang <jyang-at-redhat-dot-com> + Michal Privoznik <mprivozn-at-redhat-dot-com> -- End -- 2.7.3

On Sat, Apr 02, 2016 at 04:45:24PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- AUTHORS | 1 + 1 file changed, 1 insertion(+)
diff --git a/AUTHORS b/AUTHORS index c2af49a..cb96cdc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,5 +13,6 @@ Patches contributed by: Ludwig Nussel <ludwig-dot-nussel-at-suse-dot-de> Zhe Peng <zpeng-at-redhat-dot-com> Osier Yang <jyang-at-redhat-dot-com> + Michal Privoznik <mprivozn-at-redhat-dot-com>
ACK Guess we ought to make this auto-generated at some point. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Sat, Apr 02, 2016 at 04:45:21PM +0200, Michal Privoznik wrote:
It would be nice to have these in before the release.
Michal Privoznik (3): Adapt to new virDomain{Get,Set}PerfEvents() gitignore: Add more files to ignore & reorder Add myself to AUTHORS
.gitignore | 17 ++++++++++------- AUTHORS | 1 + Changes | 1 + Virt.xs | 38 ++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 32 ++++++++++++++++++++++++++++++++ lib/Sys/Virt/Error.pm | 4 ++++ 6 files changed, 86 insertions(+), 7 deletions(-)
FYI I already posted this fix on friday but forgot to push it Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04.04.2016 10:29, Daniel P. Berrange wrote:
On Sat, Apr 02, 2016 at 04:45:21PM +0200, Michal Privoznik wrote:
It would be nice to have these in before the release.
Michal Privoznik (3): Adapt to new virDomain{Get,Set}PerfEvents() gitignore: Add more files to ignore & reorder Add myself to AUTHORS
.gitignore | 17 ++++++++++------- AUTHORS | 1 + Changes | 1 + Virt.xs | 38 ++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 32 ++++++++++++++++++++++++++++++++ lib/Sys/Virt/Error.pm | 4 ++++ 6 files changed, 86 insertions(+), 7 deletions(-)
FYI I already posted this fix on friday but forgot to push it
Oh, should have checked the list before starting work on this. My bad. But what's good is that my code looks just the same as yours. Cool! I've pushed the other two patches then. Michal
participants (2)
-
Daniel P. Berrange
-
Michal Privoznik