retspen / webvirtmgr

WebVirtMgr panel for manage virtual machine
http://retspen.github.io
2.05k stars 535 forks source link

Trouble with novnc after updating webvirtmgr #498

Open dennobaby opened 9 years ago

dennobaby commented 9 years ago

Hi,

today i updated webvirtmgr. All seems fine but vnc-access. I got these messages in log:

´´´ 24: handler exception: WSRequestHandler instance has no attribute 'last_code' 25: handler exception: WSRequestHandler instance has no attribute 'last_code' 26: 10.0.2.16: Normal web request received but disallowed 27: handler exception: WSRequestHandler instance has no attribute 'last_code' 28: 10.0.2.16: Normal web request received but disallowed 29: handler exception: WSRequestHandler instance has no attribute 'last_code' 30: handler exception: WSRequestHandler instance has no attribute 'last_code' 31: 10.0.2.16: Normal web request received but disallowed 32: handler exception: WSRequestHandler instance has no attribute 'last_code' 33: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 33: 10.0.2.16: Version hybi-13, base64: 'True' 33: handler exception: expected string or buffer 34: handler exception: WSRequestHandler instance has no attribute 'last_code' 35: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 35: 10.0.2.16: Version hybi-13, base64: 'True' 35: handler exception: expected string or buffer 36: handler exception: WSRequestHandler instance has no attribute 'last_code' 37: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 37: 10.0.2.16: Version hybi-13, base64: 'True' 37: handler exception: expected string or buffer 38: handler exception: WSRequestHandler instance has no attribute 'last_code' 39: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 39: 10.0.2.16: Version hybi-13, base64: 'True' 39: handler exception: expected string or buffer 40: handler exception: WSRequestHandler instance has no attribute 'last_code' 41: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 41: 10.0.2.16: Version hybi-13, base64: 'True' 41: handler exception: expected string or buffer 42: handler exception: WSRequestHandler instance has no attribute 'last_code' 43: 10.0.2.16: SSL/TLS (wss://) WebSocket connection 43: 10.0.2.16: Version hybi-13, base64: 'True' 43: handler exception: expected string or buffer ´´´

In webvirtmgr i got "Failed to connect to server (code: 1006)"

I'm running webvirtmgr over ssl/https

Any ideas?

chamambom commented 9 years ago

I have 2 machines running webvirtmgr and the other one is for testing new changes before i do it on the production server ....and after doing a git pull with the latest changes ,webvirtmgr is also giving me the same issue and surprisingly if i run this command below

websockify 6080 10.10.8.107:5900 where 10.10.8.107 is the ip of the KVM HOST

i can connect without problems ,can anyone tel me what i should change or what has been broken

chamambom commented 9 years ago

and try this on your webvirtmgr portal

netstat -lnp | grep 6080

chamambom commented 9 years ago

After putting my head to it ,i saw files that had changed after the update ....... this is what i did

i cd into cd /var/www/webvirtmgr/console/ and on the new webvirtmgr [after git pull] there is this file webvirtmgr-console

and when i cd into cd /var/www/webvirtmgr/console/ on the old webvirtmgr [before the update] there is this file webvirtmgr-novnc

so this is what i did

i opened vim /etc/supervisord.conf and there are these lines as below

[program:webvirtmgri-novnc] command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-novnc directory=/var/www/webvirtmgr autostart=true autorestart=true stdout_logfile=/var/log/supervisor/webvirtmgr-nonvc.log redirect_stderr=true user=nginx [root@webvirt console]#

i changed the line command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-novnc

to command=/usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console and restarted my webvirt and voila ,everything is now working as expected

chamambom commented 9 years ago

let me know if you get it working

theArch2 commented 9 years ago

No, thats not the issue. I have the same behavior on a new installation. Completely from scratch. No matters if https or not, i got everytime

 33: 10.0.2.16: Plain non-SSL (ws://) WebSocket connection
 33: 10.0.2.16: Version hybi-13, base64: 'False'
 33: handler exception: expected string or buffer
theArch2 commented 9 years ago

Some one else seeing this behavior?

I have a brand new installation with CentOS 7 exactly followed the wiki-procedure.

brenard commented 9 years ago

Hi, you could try to take my version of webvirtmgr-console script https://github.com/brenard/webvirtmgr/commit/6e57194b30bfd41f52c6f28058f38a96357b2676 that accept parameters. Try to run script with -d parameter to enable debug message.

theArch2 commented 9 years ago

Thanks for that! Now the script tells a little bit more:

WARNING:root:No local_settings file found.
WebSocket server settings:
  - Listen on 0.0.0.0:6080
  - Flash security policy server
  - SSL/TLS support
  - proxying from 0.0.0.0:6080 to ignore:ignore

  1: 10.0.2.16: new handler Process
  1: 10.0.2.16: Plain non-SSL (ws://) WebSocket connection
  1: 10.0.2.16: Version hybi-13, base64: 'False'
libvirt: XML-RPC error : End of file while reading data: Input/output error
  1: handler exception: expected string or buffer
  1: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/websockify/websocket.py", line 711, in top_new_client
    self.new_client()
  File "/var/www/webvirtmgr/console/webvirtmgr-console", line 226, in new_client
    self._new_client(daemon, socket_factory)
  File "/var/www/webvirtmgr/console/webvirtmgr-console", line 148, in _new_client
    elif console_socket or re.match('^127\.', console_host):
  File "/usr/lib64/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer
brenard commented 9 years ago

Yes, it is clearer now. I mean you have a particularity in your domain XML. Could you provide it ? I need to see the graphics XML balise content to understand your problem. You may be try this patch to debug connexion calculate before the exception :

diff --git a/console/webvirtmgr-console b/console/webvirtmgr-console
index f77dcc2..258818f 100755
--- a/console/webvirtmgr-console
+++ b/console/webvirtmgr-console
@@ -147,6 +147,9 @@ class CompatibilityMixIn(object):
         (connhost, connport, connuser, conntype, console_host, console_port,
          console_socket) = get_connection_infos(token)

+        self.msg("Connexion infos :\n- connhost : '%s'\n- connport : '%s'\n- connuser : '%s'\n- conntype : '%s'\n- console_host : '%s'\n- console_port : '%s'\n- console_socket : %s" % (connhost, connport, connuser, conntype, console_host, console_port,
+         console_socket))
+
         if console_socket and conntype == CONN_SOCKET:
             # Local socket on local host
             self.msg('Try to open local socket %s' % console_socket)
theArch2 commented 9 years ago

Hi,

got this:

1: Connexion infos :
- connhost : 'None'
- connport : 'None'
- connuser : 'None'
- conntype : 'None'
- console_host : 'None'
- console_port : 'None'
- console_socket : None
  1: handler exception: expected string or buffer
  1: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/websockify/websocket.py", line 711, in top_new_client
    self.new_client()
  File "webvirtmgr-console", line 228, in new_client
    self._new_client(daemon, socket_factory)
  File "webvirtmgr-console", line 150, in _new_client
    elif console_socket or re.match('^127\.', console_host):
  File "/usr/lib64/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer

edit: here an other:


  2: 10.0.2.16: new handler Process
  2: 10.0.2.16: Plain non-SSL (ws://) WebSocket connection
  2: 10.0.2.16: Version hybi-13, base64: 'False'
  2: Connexion infos :
- connhost : '10.0.1.10'
- connport : '22'
- connuser : 'root'
- conntype : '1'
- console_host : 'None'
- console_port : '5904'
- console_socket : None
  2: handler exception: expected string or buffer
  2: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/websockify/websocket.py", line 711, in top_new_client
    self.new_client()
  File "webvirtmgr-console", line 228, in new_client
    self._new_client(daemon, socket_factory)
  File "webvirtmgr-console", line 150, in _new_client
    elif console_socket or re.match('^127\.', console_host):
  File "/usr/lib64/python2.7/re.py", line 137, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer

edit2: at the libvirt-host i got this in the libvirtd.log:

2015-03-17 15:38:36.963+0000: 7107: error : virNetSocketReadWire:1194 : End of file while reading data: Eingabe-/Ausgabefehler
brenard commented 9 years ago

It's strange because on running virtual domain, console_host normally can't be None. Could you share the virtual domain XML ? Witch is your libvirt version ?

theArch2 commented 9 years ago

libvirt-version on the libvirt-host (not the host where webvirtmgr is running!): libvirtd (libvirt) 0.10.2

the xml:

<domain type='kvm' id='3' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>SomeSlave</name>
  <uuid>23913718-6961-422b-a9e3-18a69230396d</uuid>
  <description>some description</description>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='rhel6.5.0'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/workspace/libvirt/storagepools/somecompany/SomeSlave-system.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/workspace/libvirt/storagepools/somecompany/SomeSlave-workspace.qcow2'/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hdc' bus='ide' tray='open'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <interface type='network'>
      <mac address='ac:de:48:01:02:04'/>
      <source network='default'/>
      <target dev='vnet2'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5904' autoport='no'>
      <listen type='address'/>
    </graphics>
    <video>
      <model type='vga' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c219,c669</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c219,c669</imagelabel>
  </seclabel>
  <qemu:commandline>
    <qemu:arg value='-k'/>
    <qemu:arg value='de'/>
    <qemu:arg value='-enable-kvm'/>
  </qemu:commandline>
</domain>
theArch2 commented 9 years ago

I have it: in the graphics section there have to be an address-element like this:

<graphics type='vnc' port='5904'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

But i think this could be checked earlier. It is not optimal that he fails at the webvirtmgr-console. It should be checked for example in "vrtManager/instance.py" at

    def get_console_listen_addr(self):
        listen_addr = util.get_xml_path(self._XMLDesc(0),
                                        "/domain/devices/graphics/@listen")
        return listen_addr
tboulogne commented 9 years ago

Hello,

After debugging, i replace 112 connhost = host.split(':')[0] 113 connport = host.split(':')[1]

By

112 connhost = instance.compute.hostname.split(':')[0] 113 connport = instance.compute.hostname.split(':')[1]

into console/webvirtmgr-novnc

Now i need to solve the ssh asking password.

tboulogne commented 9 years ago

And to make the whole work, i add to force vnc to listen on 0.0.0.0 in /etc/libvirt/qemu.conf.

brenard commented 9 years ago

@tboulogne : you'r right on split() call, I commit your fix here : https://github.com/brenard/webvirtmgr/commit/a10a95ecc65af65ac39024e8a9175f550ac5cc83

@theArch2 : I properly fix the get_console_listen_addr() method here https://github.com/brenard/webvirtmgr/commit/32d20e73140a161f8e220d42be3ebb5a2f5eeca4

hgw77 commented 9 years ago

Hi there, I have updated the latest changes and when I run webvirtmgr-console by hand I get the same error:

sudo /usr/bin/python /var/www/webvirtmgr/console/webvirtmgr-console WARNING:root:No local_settings file found. WebSocket server settings:

I thought this problem was fixed?

My Setup: KVM and Webvirtmgrt is on the same host and I try to access the VNC from another host in my intranet.

Thank you for any help :-)

hgw77 commented 9 years ago

Hi, ok I think it's an issue with the configuration of the VM. I created my VMs bevore with virt-manager. Now I created a test VM with webvirt and the VNC is working!

Virt-Manager: <graphics type='vnc' port='-1' autoport='yes'/> Webvirtmgr: `

                    </graphics>`
DaSpawn commented 9 years ago

I just setup a fresh Ubuntu 14.04 install (the VM host is same Ubuntu version), and ran into this issue as well. I utilize SSH for my connections (non-standard port) , and all was working fine except for console with same errors as above. I had initially setup with virt-manager, so suspected the VNC options were the problem, they were not.

I finally edited the /var/www/webvirtmgr/console/webvirtmgr-console and changed the lines (67,68):

connhost = host.split(':')[0]
connport = host.split(':')[1]

to

connhost = instance.compute.hostname.split(':')[0]
connport = instance.compute.hostname.split(':')[1]

and all the consoles started working fine without any VM modification