Bug 1218958 - ValueError: 'host.domain' does not appear to be an IPv4 or IPv6 network
Summary: ValueError: 'host.domain' does not appear to be an IPv4 or IPv6 network
Alias: None
Product: Virtualization Tools
Classification: Community
Component: virt-manager
Version: unspecified
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
Depends On:
Blocks: 1219023 1219156
TreeView+ depends on / blocked
Reported: 2015-05-06 09:55 UTC by Jasper Lievisse Adriaanse
Modified: 2015-06-06 18:06 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1219023 1219156 (view as bug list)
Last Closed: 2015-06-06 18:06:06 UTC

Attachments (Terms of Use)

Description Jasper Lievisse Adriaanse 2015-05-06 09:55:29 UTC
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
  File "/usr/local/share/virt-manager/virtManager/details.py", line 626, in show
  File "/usr/local/share/virt-manager/virtManager/details.py", line 1358, in refresh_vm_state
  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
  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
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().

Comment 1 Giuseppe Scrivano 2015-05-06 11:05:35 UTC
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 ["", "::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

Comment 2 Giuseppe Scrivano 2015-05-06 11:06:18 UTC
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 = ""
     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):

Comment 3 Jasper Lievisse Adriaanse 2015-05-06 11:20:21 UTC
Indeed that works for me, but shouldn't _is_listen_any() get the same treatment?


Comment 4 Giuseppe Scrivano 2015-05-06 12:15:18 UTC
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

Comment 5 Giuseppe Scrivano 2015-05-06 12:30:42 UTC
patch proposed here:


Comment 6 Cole Robinson 2015-05-06 17:06:28 UTC
Sorry, I have a setup to test this before the release, but I forgot :/

Comment 7 Giuseppe Scrivano 2015-05-06 19:33:10 UTC

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
    bug introduced with commit a2d453f3e20d103a4767394300c5183fde9a6bb4
    Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1218958
    Signed-off-by: Giuseppe Scrivano <gscrivan>

Comment 8 Jasper Lievisse Adriaanse 2015-05-06 21:36:51 UTC
Thank you for fixing this so promptly.

Note You need to log in before you can comment on or make changes to this bug.