[libvirt] [libvirt-perl][PATCH 2/3] Add virDomainSetBlockThreshold API

Michal Privoznik posted 3 patches 8 years, 10 months ago
[libvirt] [libvirt-perl][PATCH 2/3] Add virDomainSetBlockThreshold API
Posted by Michal Privoznik 8 years, 10 months ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-perl][PATCH 2/3] Add virDomainSetBlockThreshold API
Posted by Daniel P. Berrange 8 years, 10 months ago
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/ :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-perl][PATCH 2/3] Add virDomainSetBlockThreshold API
Posted by Michal Privoznik 8 years, 10 months ago
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

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