[libvirt] [libvirt-perl PATCHv2 1/2] Add virDomainGetIOThreads and virDomainPinIOThread bindings

Daniel P. Berrange berrange at redhat.com
Mon Mar 16 12:15:26 UTC 2015


On Tue, Mar 10, 2015 at 11:04:00AM -0400, John Ferlan wrote:
> Test results in the following output:
> 
> $ perl examples/iothreadsinfo.pl
> Addr
> VMM type: QEMU
> ...
> Domain: {
>   ID: 2 'f18iothr'
>   UUID: fb9f7826-b5d7-4f74-b962-7181ef3fc9ec
>   IOThread: {
>     affinity: 0010
>     number: 1
>   }
>   IOThread: {
>     affinity: 0001
>     number: 2
>   }
>   IOThread: {
>     affinity: 1100
>     number: 3
>   }
> }
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  Changes                   |  2 +-
>  Virt.xs                   | 42 ++++++++++++++++++++++++++++++++++++++++++
>  examples/iothreadsinfo.pl | 33 +++++++++++++++++++++++++++++++++
>  lib/Sys/Virt/Domain.pm    | 17 +++++++++++++++++
>  4 files changed, 93 insertions(+), 1 deletion(-)
>  create mode 100644 examples/iothreadsinfo.pl
> 
> diff --git a/Changes b/Changes
> index b62ee24..88f648c 100644
> --- a/Changes
> +++ b/Changes
> @@ -2,7 +2,7 @@ Revision history for perl module Sys::Virt
>  
>  1.2.14 2015-00-00
>  
> - - XXX
> + - Add virDomainGetIOThreads and virDomainPinIOThread API bindings
>  
>  1.2.13 2015-03-05
>  
> diff --git a/Virt.xs b/Virt.xs
> index f9ec7a4..56e143d 100644
> --- a/Virt.xs
> +++ b/Virt.xs
> @@ -5014,6 +5014,48 @@ get_emulator_pin_info(dom, flags=0)
>        RETVAL
>  
>  
> +void
> +get_iothread_info(dom, flags=0)
> +      virDomainPtr dom;
> +      unsigned int flags;
> + PREINIT:
> +      virDomainIOThreadInfoPtr *iothrinfo;
> +      int niothreads;
> +      int i;
> +   PPCODE:
> +      if ((niothreads = virDomainGetIOThreadsInfo(dom, &iothrinfo,
> +                                                  flags)) < 0)
> +          _croak_error();
> +
> +      EXTEND(SP, niothreads);
> +      for (i = 0 ; i < niothreads ; i++) {
> +          HV *rec = newHV();
> +          (void)hv_store(rec, "number", 6,
> +                         newSViv(iothrinfo[i]->iothread_id), 0);
> +          (void)hv_store(rec, "affinity", 8,
> +                         newSVpvn((char*)iothrinfo[i]->cpumap,
> +                                  iothrinfo[i]->cpumaplen), 0);
> +          PUSHs(newRV_noinc((SV *)rec));
> +      }
> +
> +      Safefree(iothrinfo);

Opps, we should have been calling  virDomainIOThreadsInfoFree on
each element of iothrinfo, and then using free() rather than
Safefree(), since the memory was allocated by Libvirt rather
than by Perl.

> +void
> +pin_iothread(dom, iothread_id, mask, flags=0)
> +     virDomainPtr dom;
> +     unsigned int iothread_id;
> +     SV *mask;
> +     unsigned int flags;
> +PREINIT:
> +     STRLEN masklen;
> +     unsigned char *maps;
> + PPCODE:
> +     maps = (unsigned char *)SvPV(mask, masklen);
> +     if (virDomainPinVcpuFlags(dom, iothread_id, maps, masklen, flags) < 0)
> +         _croak_error();

And s/VcpuFlags/IOThreads/ here.

BTW, I noticed these mistakes by running the API coverage test suite

  make test TEST_MAINTAINER=1

which reports anything in libvirt*.h that is not used from the Perl
code. I've pushed the obvious fixes.

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 :|




More information about the libvir-list mailing list