[libvirt] [libvirt-perl][PATCH 0/3] Reflect upstream changes

Couple of new APIs and constants were added to libvirt. Reflect them in the perl bindings. Michal Privoznik (3): Add block threshold event Add virDomainSetBlockThreshold API Add VIR_MIGRATE_TLS constant Changes | 3 +++ Virt.xs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 22 ++++++++++++++++++ t/030-api-coverage.t | 1 + 4 files changed, 87 insertions(+) -- 2.10.2

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 6 ++++++ t/030-api-coverage.t | 1 + 4 files changed, 56 insertions(+) diff --git a/Changes b/Changes index aee699d..4d6136f 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,7 @@ Revision history for perl module Sys::Virt - Add PERF_PARAM_PAGE_FAULTS_MAJ constant - Add PERF_PARAM_ALIGNMENT_FAULTS constant - Add PERF_PARAM_EMULATION_FAULTS constant + - Add block threshold event 3.1.0 2017-03-03 diff --git a/Virt.xs b/Virt.xs index e80182f..e0588f0 100644 --- a/Virt.xs +++ b/Virt.xs @@ -1136,6 +1136,50 @@ _domain_event_metadata_change_callback(virConnectPtr con, static int +_domain_event_block_threshold_callback(virConnectPtr con, + virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long threshold, + unsigned long long excess, + 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(dev, 0))); + XPUSHs(sv_2mortal(newSVpv(path, 0))); + XPUSHs(sv_2mortal(newSViv(threshold))); + XPUSHs(sv_2mortal(newSViv(excess))); + PUTBACK; + + call_sv(*cb, G_DISCARD); + + FREETMPS; + LEAVE; + + return 0; +} + + +static int _network_event_lifecycle_callback(virConnectPtr con, virNetworkPtr net, int event, @@ -3375,6 +3419,9 @@ PREINIT: case VIR_DOMAIN_EVENT_ID_METADATA_CHANGE: callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_metadata_change_callback); break; + case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD: + callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_block_threshold_callback); + break; default: callback = VIR_DOMAIN_EVENT_CALLBACK(_domain_event_generic_callback); break; @@ -8384,6 +8431,7 @@ BOOT: REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, EVENT_ID_JOB_COMPLETED); REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, EVENT_ID_DEVICE_REMOVAL_FAILED); REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, EVENT_ID_METADATA_CHANGE); + REGISTER_CONSTANT(VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, EVENT_ID_BLOCK_THRESHOLD); REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_NONE, EVENT_WATCHDOG_NONE); REGISTER_CONSTANT(VIR_DOMAIN_EVENT_WATCHDOG_PAUSE, EVENT_WATCHDOG_PAUSE); diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm index eea8b26..b46eca1 100644 --- a/lib/Sys/Virt/Domain.pm +++ b/lib/Sys/Virt/Domain.pm @@ -3274,6 +3274,12 @@ Guest device removal has failed. The domain metadata has changed +=item Sys::Virt::Domain::EVENT_ID_BLOCK_THRESHOLD + +The event occurs when the hypervisor detects that the given +storage element was written beyond the point specified by +threshold. The event is useful for thin-provisioned storage. + =back =head2 IO ERROR EVENT CONSTANTS diff --git a/t/030-api-coverage.t b/t/030-api-coverage.t index 3a0d0c5..3049713 100644 --- a/t/030-api-coverage.t +++ b/t/030-api-coverage.t @@ -95,6 +95,7 @@ virConnectDomainEventMigrationIterationCallback virConnectDomainEventJobCompletedCallback virConnectDomainEventDeviceRemovalFailedCallback virConnectDomainEventMetadataChangeCallback +virConnectDomainEventBlockThresholdCallback virConnectNetworkEventLifecycleCallback -- 2.10.2

On Wed, Mar 29, 2017 at 03:56:27PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/Sys/Virt/Domain.pm | 6 ++++++ t/030-api-coverage.t | 1 + 4 files changed, 56 insertions(+)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 12 ++++++++++++ lib/Sys/Virt/Domain.pm | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/Changes b/Changes index 4d6136f..3faaf08 100644 --- a/Changes +++ b/Changes @@ -12,6 +12,7 @@ Revision history for perl module Sys::Virt - Add PERF_PARAM_ALIGNMENT_FAULTS constant - Add PERF_PARAM_EMULATION_FAULTS constant - Add block threshold event + - Add virDomainSetBlockThreshold API 3.1.0 2017-03-03 diff --git a/Virt.xs b/Virt.xs index e0588f0..a05cf4d 100644 --- a/Virt.xs +++ b/Virt.xs @@ -6120,6 +6120,18 @@ send_process_signal(dom, pidsv, signum, flags=0) if (virDomainSendProcessSignal(dom, pid, signum, flags) < 0) _croak_error(); +void +set_block_threshold(dom, dev, thresholdsv, flags=0) + virDomainPtr dom; + const char *dev; + SV *thresholdsv; + unsigned int flags; + PREINIT: + unsigned long long threshold; + PPCODE: + threshold = virt_SvIVull(thresholdsv); + if (virDomainSetBlockThreshold(dom, dev, threshold, flags) < 0) + _croak_error(); void destroy(dom_rv, flags=0) diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm index b46eca1..a192ad5 100644 --- a/lib/Sys/Virt/Domain.pm +++ b/lib/Sys/Virt/Domain.pm @@ -1924,6 +1924,15 @@ 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 $dom->set_block_threshold($dev, $threshold, $flags=0); + +Set the threshold level for delivering the +EVENT_ID_BLOCK_THRESHOLD if the device or backing chain element +described by C<$dev> is written beyond the set C<$threshold> +level. The threshold level is unset once the event fires. The +event might not be delivered at all if libvirtd was not running +at the moment when the threshold was reached. + =back =head1 CONSTANTS -- 2.10.2

On Wed, Mar 29, 2017 at 03:56:28PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 12 ++++++++++++ lib/Sys/Virt/Domain.pm | 9 +++++++++ 3 files changed, 22 insertions(+)
diff --git a/Changes b/Changes index 4d6136f..3faaf08 100644 --- a/Changes +++ b/Changes @@ -12,6 +12,7 @@ Revision history for perl module Sys::Virt - Add PERF_PARAM_ALIGNMENT_FAULTS constant - Add PERF_PARAM_EMULATION_FAULTS constant - Add block threshold event + - Add virDomainSetBlockThreshold API
3.1.0 2017-03-03
diff --git a/Virt.xs b/Virt.xs index e0588f0..a05cf4d 100644 --- a/Virt.xs +++ b/Virt.xs @@ -6120,6 +6120,18 @@ send_process_signal(dom, pidsv, signum, flags=0) if (virDomainSendProcessSignal(dom, pid, signum, flags) < 0) _croak_error();
+void +set_block_threshold(dom, dev, thresholdsv, flags=0) + virDomainPtr dom; + const char *dev; + SV *thresholdsv; + unsigned int flags; + PREINIT: + unsigned long long threshold; + PPCODE: + threshold = virt_SvIVull(thresholdsv); + if (virDomainSetBlockThreshold(dom, dev, threshold, flags) < 0) + _croak_error();
nit-pick - the stuff below PPCODE shoudl be indented to the same level as variable declarations. Yes, some pre-existing methods are inconsistent, as editors get very confused by perl XS format indenting. ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

On 04/03/2017 12:17 PM, Daniel P. Berrange wrote:
On Wed, Mar 29, 2017 at 03:56:28PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 12 ++++++++++++ lib/Sys/Virt/Domain.pm | 9 +++++++++ 3 files changed, 22 insertions(+)
diff --git a/Changes b/Changes index 4d6136f..3faaf08 100644 --- a/Changes +++ b/Changes @@ -12,6 +12,7 @@ Revision history for perl module Sys::Virt - Add PERF_PARAM_ALIGNMENT_FAULTS constant - Add PERF_PARAM_EMULATION_FAULTS constant - Add block threshold event + - Add virDomainSetBlockThreshold API
3.1.0 2017-03-03
diff --git a/Virt.xs b/Virt.xs index e0588f0..a05cf4d 100644 --- a/Virt.xs +++ b/Virt.xs @@ -6120,6 +6120,18 @@ send_process_signal(dom, pidsv, signum, flags=0) if (virDomainSendProcessSignal(dom, pid, signum, flags) < 0) _croak_error();
+void +set_block_threshold(dom, dev, thresholdsv, flags=0) + virDomainPtr dom; + const char *dev; + SV *thresholdsv; + unsigned int flags; + PREINIT: + unsigned long long threshold; + PPCODE: + threshold = virt_SvIVull(thresholdsv); + if (virDomainSetBlockThreshold(dom, dev, threshold, flags) < 0) + _croak_error();
nit-pick - the stuff below PPCODE shoudl be indented to the same level as variable declarations. Yes, some pre-existing methods are inconsistent, as editors get very confused by perl XS format indenting.
Ah, yeah. My vim did that. Thank you, I've fixed this and pushed all the patches. Michal

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 1 + lib/Sys/Virt/Domain.pm | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/Changes b/Changes index 3faaf08..f28523a 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,7 @@ Revision history for perl module Sys::Virt - Add PERF_PARAM_EMULATION_FAULTS constant - Add block threshold event - Add virDomainSetBlockThreshold API + - Add VIR_MIGRATE_TLS constant 3.1.0 2017-03-03 diff --git a/Virt.xs b/Virt.xs index a05cf4d..039f62d 100644 --- a/Virt.xs +++ b/Virt.xs @@ -8219,6 +8219,7 @@ BOOT: REGISTER_CONSTANT(VIR_MIGRATE_AUTO_CONVERGE, MIGRATE_AUTO_CONVERGE); REGISTER_CONSTANT(VIR_MIGRATE_RDMA_PIN_ALL, MIGRATE_RDMA_PIN_ALL); REGISTER_CONSTANT(VIR_MIGRATE_POSTCOPY, MIGRATE_POSTCOPY); + REGISTER_CONSTANT(VIR_MIGRATE_TLS, MIGRATE_TLS); REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_BANDWIDTH, MIGRATE_PARAM_BANDWIDTH); REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_DEST_NAME, MIGRATE_PARAM_DEST_NAME); diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm index a192ad5..d69bb8d 100644 --- a/lib/Sys/Virt/Domain.pm +++ b/lib/Sys/Virt/Domain.pm @@ -2393,6 +2393,13 @@ Pin memory for RDMA transfer Enable support for post-copy migration +=item Sys::Virt::Domain::MIGRATE_TLS + +Setting this flag will cause the migration to attempt to use the +TLS environment configured by the hypervisor in order to perform +the migration. If incorrectly configured on either source or +destination, the migration will fail. + =back =head2 UNDEFINE CONSTANTS -- 2.10.2

On Wed, Mar 29, 2017 at 03:56:29PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Changes | 1 + Virt.xs | 1 + lib/Sys/Virt/Domain.pm | 7 +++++++ 3 files changed, 9 insertions(+)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
participants (2)
-
Daniel P. Berrange
-
Michal Privoznik