1

Background info

On the host

I have a virtual bridge setup, and have two static IPs configured: 10.0.3.1/16 and 10.0.3.2/16.

The host is Ubuntu 18.04 LTS, and is up-to-date at the time of this post.

For the VMs

VM 1 is set up to listen on 10.0.3.1 port 5900. When I sudo virsh start vm1, it starts up correctly and I can connect to it.

It's libvirt config looks like this:

    <graphics type='spice' port='5900' autoport='no' listen='10.0.3.1'>
      <listen type='address' address='10.0.3.1'/>
      <image compression='auto_lz'/>
    </graphics>

VM 2 is set up to listen on 10.0.3.2 port 5900:

    <graphics type='spice' port='5900' autoport='no' listen='10.0.3.2'>
      <listen type='address' address='10.0.3.2'/>
      <image compression='auto_lz'/>
    </graphics>

When I sudo virsh start vm2 I get an error:

error: Failed to start domain vm2
error: internal error: Failed to reserve port 5900

sudo netstat -nltp shows the following:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 10.0.3.1:5900           0.0.0.0:*               LISTEN      32092/qemu-system-x

What do I need?

I would like to use different IPs for each VM, and use the same 5900 port, but I am getting these errors saying that the port is already bound (which it is, just on a different address).

How can I get it to use the same port but on a different address?

1

Looks like a libvirt bug. It checks for port conflicts using 0.0.0.0, without taking into account the listen address.

You can probably work around it by using qemu commandline passthrough to pass a valid -spice arg to qemu that libvirt won't look at. Not very friendly but it's an option if you just want to get something working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.