RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1219023 - 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
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: virt-manager
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Giuseppe Scrivano
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1218958 1219156
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-06 12:31 UTC by Giuseppe Scrivano
Modified: 2015-11-19 05:25 UTC (History)
9 users (show)

Fixed In Version: virt-manager-1.2.0-2-el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 1218958
Environment:
Last Closed: 2015-11-19 05:25:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2206 0 normal SHIPPED_LIVE virt-manager bug fix and enhancement update 2015-11-19 08:17:29 UTC

Description Giuseppe Scrivano 2015-05-06 12:31:46 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

Comment 3 Xiaodai Wang 2015-06-24 07:32:37 UTC
I tried with below packages, but can't reproduce it.
# rpm -q virt-manager
virt-manager-1.2.0-1.el7.noarch
# rpm -q libvirt
libvirt-1.2.15-2.el7.x86_64

Steps:
1. Modify localhost name to host.domain.
# hostname
host.domain
# cat /etc/hosts
127.0.0.1  host.domain 
::1       host.domain
2. launch virt-manager.
# virt-manager --debug
3. Click File->Add Connection, Check "Connect to remote host", type "host.domain" to Hostname and click "Connect"
4. Select the connection, right click the mouse and select Details.
5. After the Connection Details window pops up, check the debug info in terminal.

Result:
No Python traceback is shown.


Could you supply more details about how to reproduce it? Thanks.

Comment 4 Cole Robinson 2015-06-24 14:07:21 UTC
The bug is in the vnc/spice viewer console code. So set the VM <graphics listen="my.host.name"/>, then try to connect to the VM console and you should see the error

Comment 5 Xiaodai Wang 2015-06-25 02:44:27 UTC
I can reproduce this bug with package:
virt-manager-1.2.0-1.el7.noarch

Steps:
1. Prepare a guest and change the listen address to hostname in xml
# virsh edit $guest
...
<graphics type='spice' port='5901' autoport='yes' listen='xiaodwan2'>
      <listen type='address' address='xiaodwan2'/>
    </graphics>
...
2. Start the guest.
3. Double click the guest to show the detail info in virt-manager

Actual Result:
An Error message box pops up.

Error Launching details: 'xiaodwan2' does not appear to be an IPv4 or IPv6 network.


Then try to verify with latest build:
virt-manager-1.2.1-2.el7.noarch.rpm  


Result:
No error message box pops up and the detail window displays successfully.

According to the result above in the latest version of virt-manager, move this bug from ON_QA to VERIFIED.

Comment 7 errata-xmlrpc 2015-11-19 05:25:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2206.html


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