2

I'm trying to setup a KVM based VMs on a local server, and following this doc: https://wiki.debian.org/KVM

In this documentation it states that you'll get virbr0 for bridge connection, but unfortunately it wasn't created automatically. Doc suggest to use virt-manager to fix that, but I'm having just a standard debian server installation w/o GUI. So how can I create that from command line?

I have created br0, all looks good:

$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000 link/ether 00:1f:c6:9c:0f:0d brd ff:ff:ff:ff:ff:ff 3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:1f:c6:9c:0f:0d brd ff:ff:ff:ff:ff:ff inet 192.168.1.200/24 brd 192.168.1.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::21f:c6ff:fe9c:f0d/64 scope link valid_lft forever preferred_lft forever $ sudo ip route default via 192.168.1.1 dev br0 $ brctl show bridge name bridge id STP enabled interfaces br0 8000.001fc69c0f0d no eth0 

notice, there're no virbr0.

If I try to create ifage-bridge I get error:

$ virsh iface-bridge eth0 br0 error: failed to get interface 'eth0' error: internal error: couldn't find interface named 'eth0': required entry missing 

I also have bridge configured for qemu, which I did manually and added to qemu autostart:

$ cat /etc/libvirt/qemu/networks/bridge.xml <network> <name>bridge</name> <bridge name="br0"/> <forward mode="bridge"/> </network> 

And I can't create/start a VM because of bridge:

$ virt-install --virt-type kvm --name testvm --network bridge Starting install... Retrieving file MANIFEST... | 3.3 kB 00:00 ... Retrieving file linux... | 6.0 MB 00:08 ... Retrieving file initrd.gz... | 29 MB 00:56 ... Allocating 'testvm.qcow2' | 8.0 GB 00:00 ERROR failed to retrieve file descriptor for interface: Transport endpoint is not connected 

It works if I omit --network configuration. This VM wouldn't have network, so useless basically. If I add a bridge config by virsh edit testvm:

<interface type='bridge'> <source bridge='br0'/> <model type='virtio'/> </interface> 

and run, it will fail anyway:

$ virsh start testvm error: Failed to start domain testvm error: failed to retrieve file descriptor for interface: Transport endpoint is not connected 

What I did incorrectly? How I should add virbr0 and hot to setup network for VMs?

I have a fresh Debian Jessie installation, nothing was installed except core components, ssh and kvm/qemu/libvirt

3 Answers 3

2

The reason was insufficient rights to use bridge from non-root user.

Documentation states that:

libvirt defaults to qemu:///session for non-root. So from <youruser> you'll need to do:

$ virsh --connect qemu:///system list --all

It wasn't clear that you have to specify it for installation, and when you would do that. It turns out it's a required command line option for non-root user.

Correct command to install a new VM with networking should include following:

virt-install --connect qemu:///system ....... 

Or it's also possible to install it directly from root user

1

This is how it should work:

# cat /tmp/virt-net-example.xml <network connections='9'> <name>some-virt-net</name> <uuid>530f11c4-617b-447c-bdba-704f34374277</uuid> <bridge name='virbr42' stp='on' delay='0'/> <mac address='42:13:37:23:21:87'/> <ip address='172.20.42.254' netmask='255.255.255.0'> <dhcp> <range start='172.20.42.1' end='172.20.42.42'/> </dhcp> </ip> </network> # virsh net-define /tmp/virt-net-example.xml # virsh net-start some-virt-net Network some-virt-net started # brctl show virbr42 bridge name bridge id STP enabled interfaces virbr42 8000.421337232187 yes virbr42-nic # link show virbr42-nic 99: virbr42-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr42 state DOWN mode DEFAULT group default qlen 1000 link/ether 42:13:37:23:21:87 brd ff:ff:ff:ff:ff:ff 

Tested just now on FC22 against libvirt 1.2.13

2
  • thanks. could you elaborate it a little more? what so you think should be modified in my config to make it working? because it doesn't look like adding mac address will help. so there should be something important in your example, but I don't understand what exactly Commented Feb 1, 2017 at 13:47
  • “what so you think should be modified in my config” -- not the config, but let libvirt create the bridge. It will do that on its own. In your VM definition you then reference the bridge as <target dev='vnet42'/> in the interface section. Commented Feb 2, 2017 at 8:43
0

You already have br0 configured, it's good enough. The proper virt-install option is --network bridge=br0

EDIT: and example of an interface attached to a bridge, as promised in comments:

</interface> <mac address='00:1a:4a:01:00:04'/> <source bridge='br0'/> <target dev='vnet2'/> <model type='virtio'/> <link state='up'/> <alias name='net0'/> </interface> 

target dev and alias name are optional afaik

6
  • Tried, same result, same error. So maybe it's not because of non-existing virbr0, but something else related to that bridge? because it works without specifying --network option. Something is wrong there, but Transport endpoint is not connected doesn't make it clear Commented Jan 27, 2017 at 17:36
  • I use this all the time on RHEL, you might be running into a Debian specific bug. Commented Jan 27, 2017 at 19:05
  • Do you know any way to debug it? virsh logs/output are non-informative, and Transport endpoint is not connected doesn't give any clue. -d 0 doesn't provide additional log to that error message Commented Jan 28, 2017 at 5:56
  • try to simply create a VM with virt-manager and attach it to br0, see if that works. If it does, I'd simply stick to the manual creation way, or if you really need automation, use virt-builder instead of virt-install. It's way less buggy, especially and that's important on non-RH distros that don't really do any quality testing like Debian Commented Jan 28, 2017 at 15:46
  • not sure what you mean by attach it to br0. I've tried to create simple VM without networking, but if I edit its xml and add bridge network (there's example in the question) it failed to run. I don't know about other way to attach it to br0. I'll try virt-builder, thanks Commented Jan 29, 2017 at 8:24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.