Skip to contentSkip to conversation

VNC server for KVM VM

DISCUSSION Daniel Bareiro 3 participants 5 messages Aug 14, 2009 – Aug 15, 2009 KVM

lore
Share & tools
lore
#0 lore raw

Hi all!

I'm using the following syntax to launch a VM:

$KVM -hda ${DISK_PATH}/aprender00-raiz -hdb ${DISK_PATH}/aprender00-space \
-m 3584 -boot c -smp 4 -net nic,vlan=0,macaddr=00:16:3e:00:00:61,model=virtio \
-net tap -daemonize -vnc :3 -k es -localtime -monitor \
telnet:localhost:4003,server,nowait -serial telnet:localhost:4043,server,nowait

But when I doing a shutdown logged on the VM, apparently the port associated to VNC server remains active when trying boot it again:

inet_listen: bind(ipv4,0.0.0.0,5903): Address already in use
inet_listen: FAILED

I'm using KVM-88 compiled by myself. It can be a bug?

Thanks in advance.

Regards,
Daniel

Signature · 2 lines
Fingerprint: BFB3 08D6 B4D1 31B2 72B9  29CE 6696 BF1B 14E6 1D37
Powered by Debian GNU/Linux Squeeze - Linux user #188.598
#1 lore raw
Quoted 2 lines · Daniel Bareiro

inet_listen: bind(ipv4,0.0.0.0,5903): Address already in use
inet_listen: FAILED

If you check with netstat, I expect you'll see the port in TIME_WAIT state; if so, this will eventually clean itself up if you just wait a little bit before restarting.

One option to avoid it is to make sure all connections are closed properly on shutdown; another is to set the SO_REUSEADDR flag on the socket before the bind() call.

#2 lore raw
Quoted 7 lines · Charles Duffy
Quoted 2 lines · Daniel Bareiro

inet_listen: bind(ipv4,0.0.0.0,5903): Address already in use
inet_listen: FAILED

If you check with netstat, I expect you'll see the port in TIME_WAIT state; if so, this will eventually clean itself up if you just wait a little bit before restarting.

One option to avoid it is to make sure all connections are closed properly on shutdown; another is to set the SO_REUSEADDR flag on the socket before the bind() call.

We set SO_REUSEADDR.

Regards,

Anthony Liguori

#3 lore raw
In reply to Charles Duffy
Quoted 10 lines · Charles Duffy
Quoted 2 lines

inet_listen: bind(ipv4,0.0.0.0,5903): Address already in use
inet_listen: FAILED

If you check with netstat, I expect you'll see the port in TIME_WAIT state; if so, this will eventually clean itself up if you just wait a little bit before restarting.

One option to avoid it is to make sure all connections are closed properly on shutdown; another is to set the SO_REUSEADDR flag on the socket before the bind() call.

Two were the VM to which I did shutdown and later I boot again. These VM had VNC servers running in 5902 and 5903. Approximately three hours of boot, I see the following thing with netstat:

root@ss03:~# netstat -puta | grep 590
tcp        0      0 localhost:5900          *:*                     LISTEN      7332/qemu-system-x8
tcp        0      0 *:5901                  *:*                     LISTEN      17528/qemu-system-x
tcp        0      0 localhost:5902          *:*                     LISTEN      30889/qemu-system-x
tcp        0      0 localhost:5903          *:*                     LISTEN      30900/qemu-system-x

Now 5900 and 5901 are the ports that these two machines have assigned. It are up and running.

Also I have other two VM without shutdown/boot it with associated VNC ports 5904 and 5905, but that don't appear in the listing of netstat, as you can see. Testing of connection I see that I cannot be connected to any of them using VNC client, although I don't remember to have observed some error when launching the KVM processes of each of them, which draws attention to me.

Thanks for your reply.

Regards,
Daniel

Signature · 2 lines
Fingerprint: BFB3 08D6 B4D1 31B2 72B9  29CE 6696 BF1B 14E6 1D37
Powered by Debian GNU/Linux Squeeze - Linux user #188.598
#4 lore raw
In reply to Daniel Bareiro
Quoted 10 lines · Daniel Bareiro

Hi all!

I'm using the following syntax to launch a VM:

$KVM -hda ${DISK_PATH}/aprender00-raiz -hdb ${DISK_PATH}/aprender00-space \
-m 3584 -boot c -smp 4 -net nic,vlan=0,macaddr=00:16:3e:00:00:61,model=virtio \
-net tap -daemonize -vnc :3 -k es -localtime -monitor \
telnet:localhost:4003,server,nowait -serial telnet:localhost:4043,server,nowait

Quoted 6 lines

But when I doing a shutdown logged on the VM, apparently the port associated to VNC server remains active when trying boot it again:

inet_listen: bind(ipv4,0.0.0.0,5903): Address already in use
inet_listen: FAILED

I expect the qemu process enver expected.

Regards,

Anthony Liguori