Re: [PATCH 0/2] Show IP address in virt-manager

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

 





On 03/03/2018 05:03 PM, Cole Robinson wrote:
On 03/02/2018 01:27 AM, Dylan Stephano-Shachter wrote:
I have added a feature to show a VM's first IP address next to the VM state (Running, etc.). This feature can be toggled in the preferences menu and is disabled by default. It uses the qemu-guest agent to query the IP address.

Dylan Stephano-Shachter (2):
  show the first ip address of running vms
  add preferences option to enable 'show first ip'

Thanks for the patches. Interesting idea. We are definitely overdue for
exposing VM IP address somewhere in the UI

It's kind of difficult to get the implementation right though. We try
really hard to avoid repeated libvirt API calls in the code, because
often we connect to libvirt over slow remote connections and too many
API calls make the app sluggish. Ideally what we would do is cache this
type of info at domain startup time, or first access, similarish to how
we handle vmmDomain.get_domain_capabilities or
vmmDomain.managedsave_supported.

But this case is different since it's runtime state that can change,
maybe the VM network goes down, or more likely we try to request info
before the domain is fully up and network has been initialized. So I
dunno, do we need a way to let the user request refreshing this info?
I'd need to play with it.

I think UI wise a simpler place to start to hash out some of these
issues is to add an IP Address field to the VM details page for each
particular network device. Possibly adding a small refresh button next
to that field for the user to request fetching latest data. Those pages
have less performance constraints than the manager window. I can help
work out the details for this too if you come up with a first pass

As for implementing this in the manager, one suggestion is that rather
than extending Preferences, map the gsettings field to Manager->View->IP
Address, following how the Graph options work. It could even add a new
IP Address column, not sure offhand if that's better though

Thanks,
Cole

I had to leave this be for a while as I was very busy but I would like to revisit it. I like your idea of a refresh button as the api call certainly can get expensive. In terms of putting it in the VM details page, I don't really think that makes sense. The main point of this is you don't have to open anything. If you are going to open the VM details and find the IP info, you might as well just open the VM and type ifconfig.

I'll take a look at the graph code and see what I can come up with. I like the idea of a new column. I'd also like to show all the addresses if possible. I'm a bit of a noob when it comes to anything with a gui but I should be able to get something going.


On 03/02/2018 03:58 PM, Dylan Stephano-Shachter wrote:
That is interesting. Could you possibly run virt-manager with --debug and
send me any stacktraces you see?
[Please don't top post on technical lists.]

On Mar 2, 2018 7:55 AM, "Michal Privoznik" <mprivozn@xxxxxxxxxx> wrote:

On 03/02/2018 07:27 AM, Dylan Stephano-Shachter wrote:
I have added a feature to show a VM's first IP address next to the VM
state (Running, etc.). This feature can be toggled in the preferences menu
and is disabled by default. It uses the qemu-guest agent to query the IP
address.
Dylan Stephano-Shachter (2):
  show the first ip address of running vms
  add preferences option to enable 'show first ip'

 data/org.virt-manager.virt-manager.gschema.xml |  6 ++++++
 ui/preferences.ui                              | 15 +++++++++++++++
 virtManager/config.py                          |  8 ++++++++
 virtManager/domain.py                          | 16 ++++++++++++++++
 virtManager/engine.py                          |  7 +++++++
 virtManager/manager.py                         | 19 +++++++++++++++----
 virtManager/preferences.py                     |  9 +++++++++
 7 files changed, 76 insertions(+), 4 deletions(-)

Interestingly, this made a machine I have not to be displayed in the
list of domains. The domain is running, qemu-ga is installed and running
and domain has an IP address:


virsh # domifaddr fedora --source agent
 Name       MAC address          Protocol     Address
------------------------------------------------------------
-------------------
 lo         00:00:00:00:00:00    ipv4         127.0.0.1/8
 -          -                    ipv6         ::1/128
 ens3       52:54:00:a4:6f:91    ipv4         192.168.122.37/24
 -          -                    ipv6         fe80::ee48:d373:fc65:fce0/64
 virbr0     52:54:00:1f:be:17    ipv4         192.168.124.1/24
 virbr0-nic 52:54:00:1f:be:17    N/A          N/A
I've managed to reproduce and here's the interesting part of the debug output:

[Mon, 05 Mar 2018 10:50:43 virt-manager 12584] DEBUG (connection:1197) domain=fedora status=Running added
[Mon, 05 Mar 2018 10:50:43 virt-manager 12584] DEBUG (cli:258) Uncaught exception:
Traceback (most recent call last):
  File "/home/zippy/work/virt-manager.git/virtManager/manager.py", line 600, in vm_added
    row = self._build_row(None, vm)
  File "/home/zippy/work/virt-manager.git/virtManager/manager.py", line 671, in _build_row
    ipaddr = vm.get_first_ip_addr()
  File "/home/zippy/work/virt-manager.git/virtManager/domain.py", line 1093, in get_first_ip_addr
    if iface != 'lo' and IP_REGEX.match(ifaces[iface]['addrs'][0]['addr']):
TypeError: 'NoneType' object is not subscriptable

Traceback (most recent call last):
  File "/home/zippy/work/virt-manager.git/virtManager/manager.py", line 600, in vm_added
    row = self._build_row(None, vm)
  File "/home/zippy/work/virt-manager.git/virtManager/manager.py", line 671, in _build_row
    ipaddr = vm.get_first_ip_addr()
  File "/home/zippy/work/virt-manager.git/virtManager/domain.py", line 1093, in get_first_ip_addr
    if iface != 'lo' and IP_REGEX.match(ifaces[iface]['addrs'][0]['addr']):
TypeError: 'NoneType' object is not subscriptable

Michal

Not sure if you can still test this, but I attached a script to dump the interfaces object. If you could run it with "./get-interfaces.py <vm-name>" that would be super helpful.

#!/usr/bin/python3

import libvirt
from pprint import pprint
import sys

def main():
    vm_name = sys.argv[1]

    conn = libvirt.open('qemu:///system')
    dom = conn.lookupByName(vm_name)
    pprint(dom.interfaceAddresses(source=1))


if __name__ == '__main__':
    main()
_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux