1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
Libvirt is a virtualization infrastracture
daemon: libvirtd
configuration: /etc/libvirt
control-app: virsh
UI client: virt-manager
/var/run/libvirt/libvirt-sock - should be accessible by user
Additional daemons:
vde: VDE network to connect with stand-alone qemu (not needed in simple config)
dnsmasq: DNS proxy (automatically launched)
Network
- Libvirt network manager (TAP based), creates two interfaces
virtbr0 - bridge used by the clients
vnet0 - virtual NAT device which masquerades packets from virtbr0
this configured using following directive in domain config (networks
are defined in /etc/libvirt/qemu/networks):
<interface type='network'>
<mac address='54:52:00:63:a8:88'/>
<source network='default'/>
</interface>
- Existing bridges can be used:
<interface type='bridge'>
<mac address='54:52:00:63:a8:88'/>
<source bridge='br0'/>
</interface>
The bridges are created in /etc/conf.d/net
bridge_br0="vlan0"
config_br0="ip/mask"
and can be checked using 'brctl' tool
brctl show
- If virtual machine with configured networking is executed using libvirt,
by 'ps | grep kvm' you can see network parameters, something like:
-net tap,fd=11,vlan=0
Running it directly will never work because libvirt normally sets up the
network connections and passes them as open files to kvm.
Sharing network with stanalone qemu
===================================
1. We are creating a VDE network
- Lets call it 'vlan0'
- It should be accessible by users
VDE_SOCK_CHMOD="770"
VDE_SOCK_CHOWN=":qemu"
- The actual IP in /etc/conf.d/vde is not important, it just should not
interfer with other networks
2. Creating a bridge to vlan0, and setting it's IP to the network where would
reside our virtual machines
bridge_br0="vlan0"
config_br0=("192.168.28.1/24")
brctl_br0=("stp on" )
3. Libvirt virtual machines should be configured to use bridge 'br0'
<interface type='bridge'>
<mac address='54:52:00:63:a8:88'/>
<source bridge='br0'/>
</interface>
4. Qemu is started as follows
kvm -net nic,model=rtl8139 -net vde,vlan=0,sock=/var/run/vde.ctl ...
Independ how the virtual machine is run, it could have an address from
192.168.28.xxx network.
The following daemons should be started:
- vde daemon
- dnsmasq (automatically executed by libvirt, but is needed if only a
standalone machines are used and libvirt is not started)
Problems
========
- There is multiple things which will prevent suspend: SATA/IDE controllers
(virtio works fine), passthrough PCI devices (USB is fine), ...
- By default libvirt tries to suspend machines on shutdown, if something
prevents machine from suspending, they will crash. So, it is better to
change behavior to shutdown
|