Bug 1219156

Summary: ValueError: 'host.domain' does not appear to be an IPv4 or IPv6 network
Product: [Fedora] Fedora Reporter: Cole Robinson <crobinso>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 22CC: berrange, cfergeau, crobinso, gscrivan, jasper, mmello, rbalakri, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-1.2.1-1.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1218958 Environment:
Last Closed: 2015-06-11 18:32:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1218958    
Bug Blocks: 1219023    

Description Cole Robinson 2015-05-06 17:07:26 UTC
+++ This bug was initially created as a clone of Bug #1218958 +++

If you have a connection is configured as 'host.domain', and open the VM details the dialog opens but a Python traceback is shown:

Error launching details: 'host.domain' does not appear to be an IPv4 or IPv6 network

Traceback (most recent call last):
  File "/usr/local/share/virt-manager/virtManager/engine.py", line 791, in _show_vm_helper
    details.show()
  File "/usr/local/share/virt-manager/virtManager/details.py", line 626, in show
    self.refresh_vm_state()
  File "/usr/local/share/virt-manager/virtManager/details.py", line 1358, in refresh_vm_state
    self.console.details_update_widget_states()
  File "/usr/local/share/virt-manager/virtManager/console.py", line 961, in details_update_widget_states
    return self._update_vm_widget_states()
  File "/usr/local/share/virt-manager/virtManager/console.py", line 526, in _update_vm_widget_states
    self._init_viewer()
  File "/usr/local/share/virt-manager/virtManager/console.py", line 634, in _init_viewer
    if ginfo.is_bad_localhost():
  File "/usr/local/share/virt-manager/virtManager/sshtunnels.py", line 69, in is_bad_localhost
    return self.transport and self._is_listen_localhost(host)
  File "/usr/local/share/virt-manager/virtManager/sshtunnels.py", line 51, in _is_listen_localhost
    return ipaddr.IPNetwork(host or self.gaddr).is_loopback
  File "/usr/local/lib/python2.7/site-packages/ipaddr.py", line 119, in IPNetwork
    address)
ValueError: 'host.domain' does not appear to be an IPv4 or IPv6 network


The details can still be modified however.

This is with:
virt-manager 1.2.0
libvirt 1.2.15


This issue is 100% reproducible.

Reverting this commit worksaround the issue: https://git.fedorahosted.org/cgit/virt-manager.git/commit/virtManager/sshtunnels.py?id=a2d453f3e20d103a4767394300c5183fde9a6bb4

It seems the 'host' is not resolved before it's passed to ipaddr.IPNetwork().

--- Additional comment from Giuseppe Scrivano on 2015-05-06 07:05:35 EDT ---

could you verify if this works for you?

I am going to do more tests here and propose it upstream later today:

diff --git a/virtManager/sshtunnels.py b/virtManager/sshtunnels.py
index 25ed43a..263a6ed 100644
--- a/virtManager/sshtunnels.py
+++ b/virtManager/sshtunnels.py
@@ -49,8 +49,8 @@ class ConnectionInfo(object):
 
     def _is_listen_localhost(self, host=None):
         if host:
-            return host in ["127.0.0.1", "::1"]
-        return ipaddr.IPNetwork(self.gaddr).is_loopback
+            host = socket.gethostbyname(host)
+        return ipaddr.IPNetwork(host or self.gaddr).is_loopback
 
     def _is_listen_any(self):
         return ipaddr.IPNetwork(self.gaddr).is_unspecified

--- Additional comment from Giuseppe Scrivano on 2015-05-06 07:06:18 EDT ---

sorry, I meant..

diff --git a/virtManager/sshtunnels.py b/virtManager/sshtunnels.py
index 53f43be..263a6ed 100644
--- a/virtManager/sshtunnels.py
+++ b/virtManager/sshtunnels.py
@@ -48,6 +48,8 @@ class ConnectionInfo(object):
             self._connhost = "127.0.0.1"
 
     def _is_listen_localhost(self, host=None):
+        if host:
+            host = socket.gethostbyname(host)
         return ipaddr.IPNetwork(host or self.gaddr).is_loopback
 
     def _is_listen_any(self):

--- Additional comment from Jasper Lievisse Adriaanse on 2015-05-06 07:20:21 EDT ---

Indeed that works for me, but shouldn't _is_listen_any() get the same treatment?

Thanks.

--- Additional comment from Giuseppe Scrivano on 2015-05-06 08:15:18 EDT ---

is_listen_any() is accessing only self.gaddr, which is supposed to be already an IP address.

The same thing is done in _is_listen_localhost in case host=None

--- Additional comment from Giuseppe Scrivano on 2015-05-06 08:30:42 EDT ---

patch proposed here:

https://www.redhat.com/archives/virt-tools-list/2015-May/msg00016.html

--- Additional comment from Cole Robinson on 2015-05-06 13:06:28 EDT ---

Sorry, I have a setup to test this before the release, but I forgot :/

Comment 1 Cole Robinson 2015-05-06 20:28:09 UTC
Upstram commit

commit ebcb7c064ca5a3afd2ec3a0c8f59328a7f71b009
Author: Giuseppe Scrivano <gscrivan>
Date:   Wed May 6 12:52:40 2015 +0200

    sshtunnels: fix exception when the address is not an IP

Comment 2 Cole Robinson 2015-05-21 18:22:05 UTC
*** Bug 1223714 has been marked as a duplicate of this bug. ***

Comment 3 Fedora Update System 2015-06-06 22:30:38 UTC
virt-manager-1.2.1-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/virt-manager-1.2.1-1.fc22

Comment 4 Fedora Update System 2015-06-09 15:19:58 UTC
Package virt-manager-1.2.1-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing virt-manager-1.2.1-1.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-9686/virt-manager-1.2.1-1.fc22
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2015-06-11 18:32:47 UTC
virt-manager-1.2.1-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.