Commit 19732df2 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add virDomainInterfaceAddress function & constants

Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
parent 26110602
......@@ -7,6 +7,7 @@ Revision history for perl module Sys::Virt
- Add virDomainGetIOThreads and virDomainPinIOThread API bindings
- Update the vcpuinfo.pl example to use unpack
- Add VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN constant
- Add virDomainInterfaceAddress function & constants
1.2.13 2015-03-05
......
......@@ -5243,6 +5243,43 @@ get_fs_info(dom, flags=0)
}
free(info);
void
get_interface_addresses(dom, src, flags=0)
virDomainPtr dom;
unsigned int src;
unsigned int flags;
PREINIT:
virDomainInterfacePtr *info;
int ninfo;
size_t i, j;
PPCODE:
if ((ninfo = virDomainInterfaceAddresses(dom, &info, src, flags)) < 0)
_croak_error();
EXTEND(SP, ninfo);
for (i = 0; i < ninfo; i++) {
HV *hv = newHV();
AV *av = newAV();
(void)hv_store(hv, "name", 4, newSVpv(info[i]->name, 0), 0);
(void)hv_store(hv, "hwaddr", 6, newSVpv(info[i]->hwaddr, 0), 0);
for (j = 0; j < info[i]->naddrs; j++) {
HV *subhv = newHV();
(void)hv_store(subhv, "type", 4, newSViv(info[i]->addrs[j].type), 0);
(void)hv_store(subhv, "addr", 4, newSVpv(info[i]->addrs[j].addr, 0), 0);
(void)hv_store(subhv, "prefix", 6, newSViv(info[i]->addrs[j].prefix), 0);
av_push(av, newRV_noinc((SV*)subhv));
}
(void)hv_store(hv, "addrs", 5, newRV_noinc((SV*)av), 0);
virDomainInterfaceFree(info[i]);
PUSHs(newRV_noinc((SV*)hv));
}
free(info);
void
send_process_signal(dom, pidsv, signum, flags=0)
virDomainPtr dom;
......@@ -7804,6 +7841,11 @@ BOOT:
REGISTER_CONSTANT_STR(VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC, TUNABLE_BLKDEV_SIZE_IOPS_SEC);
REGISTER_CONSTANT_STR(VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, TUNABLE_IOTHREADSPIN);
REGISTER_CONSTANT(VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT, INTERFACE_ADDRESSES_SRC_AGENT);
REGISTER_CONSTANT(VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE, INTERFACE_ADDRESSES_SRC_LEASE);
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);
......
#!/usr/bin/perl
use strict;
use warnings;
use Sys::Virt;
use Sys::Virt::Domain;
my $uri = @ARGV ? shift @ARGV : undef;
my $c = Sys::Virt->new(uri => $uri);
my $dom = $c->get_domain_by_name(shift @ARGV);
my @fs = $dom->get_interface_addresses(
Sys::Virt::Domain::INTERFACE_ADDRESSES_SRC_LEASE);
use Data::Dumper;
print Dumper(@fs);
......@@ -1674,6 +1674,61 @@ configuration
=back
=item @nics = $dom->get_interface_addresses($src, $flags=0);
Obtain a list of all guest network interfaces. The C<$src>
parameter is one of the constants
=over 4
=item Sys::Virt::Domain::INTERFACE_ADDRESSES_SRC_LEASE
Extract the DHCP server lease information
=item Sys::Virt::Domain::INTERFACE_ADDRESSES_SRC_AGENT
Query the guest OS via an agent
=back
The returned list will contain one element for each interface.
The values in the list will be a hash reference with the
following keys
=over 4
=item name
The name of the guest interface that is mounted
=item hwaddr
The hardware address, aka MAC.
=item addrs
An array reference containing list of IP addresses
associated with the guest NIC. Each element in the
array is a further hash containing
=over 4
=item addr
The IP address string
=item prefix
The IP address network prefix
=item type
The IP address type (IPv4 vs IPv6)
=back
=back
=item $dom->send_process_signal($pid, $signum, $flags=0);
Send the process C<$pid> the signal C<$signum>. The
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment