[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt-users] Network interface name of guest via python API

On 03/19/2018 11:46 AM, Dennis Jacobfeuerborn wrote:
> Hi,
> I'm trying to get some basic data from running guests on a libvirt HV
> but one thing I'm missing is the name of the network interfaces of the
> guests. I can get the MAC address from the XML but there seems to be no
> function to actually get the name of the interface.
> The only function that comes close is this one:
> https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceAddresses
> This function requires a parameter that I don't really have enough
> information about.

Which parameter is that? flags? That seems fairly thoroughly explained
in the documentation you pointed at.

> What is the best way to enumerate a guests interfaces including the name?

Assuming you mean the name of the interface *as it appears to the
guest*... Since the host can't directly know the names of devices on the
guest, the only way you can learn this is with cooperation from the OS
running on the guest. One way of getting that cooperation is to make
sure the guest is running the qemu guest agent (and that libvirt's
domain config has the proper serial channel configured), then
virDomainInterfaceAddresses() with the
VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT flag will return entries that
contain the interface name as it appears to the guest (the other modes
of virDomainInterfaceAddresses will show the names of the tap devices on
the *host*, not of the interfaces in the guest).

You can check if your guests are running the qemu guest agent (and try
out the virDomainInterfaceAddresses() API at the same time) with this
shell command (run as root on the host):

   virsh domifaddr $guestname --source agent

Here is info in the libvirt wiki about installing / configuring the qemu
guest agent:


(I just checked on a Fedora 27 guest that I previously defined with
virt-manager to use spice for video, I found that virt-manager had
automatically added the necessary serial channel device
("org.qemu.guest_agent.0"), and that the Linux kernel in the guest
automatically noticed that and setup a guest agent in the guest. It may
(will) take more work to get the guest agent working for other guest
OSes, e.g. Windows.)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]