Browse Source

Add a script to install libvirt and enable KVM/Qemu VM live migration

Change-Id: I775c0873aefd78e0d25fb07357dd7ea587451dcf
Changbin Liu 5 years ago
parent
commit
cf46b6f9fc
1 changed files with 66 additions and 0 deletions
  1. 66
    0
      bin/pre_install_libvirt.sh

+ 66
- 0
bin/pre_install_libvirt.sh View File

@@ -0,0 +1,66 @@
1
+#!/bin/bash
2
+
3
+## Install libvirt (1.2.0), and enable VM (KVM/Qemu) live
4
+## migration. Default libvirt on Ubuntu 12.04 is 0.9.8, which does not
5
+## work well with Open vSwitch ("<virtualport type='openvswitch'/>"
6
+## cannot be added into VM xml configuration).
7
+
8
+# Install KVM, QEMU and libvirt (0.9.8, so that we have /etc/init/libvirt-bin.conf)
9
+sudo apt-get -y install \
10
+    kvm \
11
+    qemu \
12
+    libvirt-bin
13
+
14
+# Install dependencies. You can omit the libcurl4-gnutls-dev package
15
+# if you don’t want ESX support.
16
+sudo apt-get update
17
+sudo apt-get -y install \
18
+    gcc \
19
+    make \
20
+    pkg-config \
21
+    libxml2-dev \
22
+    libgnutls-dev \
23
+    libdevmapper-dev \
24
+    libcurl4-gnutls-dev \
25
+    python-dev \
26
+    libpciaccess-dev \
27
+    libxen-dev \
28
+    libyajl-dev \
29
+    libnl-dev
30
+
31
+sudo mkdir -p /opt/libvirt
32
+sudo chmod 00755 /opt/libvirt
33
+sudo chown root:root /opt/libvirt
34
+
35
+sudo chmod a+w /opt/libvirt
36
+cd /opt/libvirt
37
+wget http://libvirt.org/sources/libvirt-1.2.0.tar.gz
38
+tar xzvf libvirt-1.2.0.tar.gz
39
+mv libvirt-1.2.0 libvirt
40
+cd libvirt
41
+./configure \
42
+    --prefix=/usr \
43
+    --localstatedir=/var \
44
+    --sysconfdir=/etc \
45
+    --with-esx=yes \
46
+    --with-xen=yes # if you need Xen support, you’ll need to add
47
+		   # --with-xen=yes to the command
48
+make -j
49
+sudo make install
50
+
51
+# enable libvirt for VM live migration
52
+sudo sed -i /etc/libvirt/libvirtd.conf \
53
+    -e 's/#listen_tls = 0/listen_tls = 0/g' \
54
+    -e 's/#listen_tcp = 1/listen_tcp = 1/g' \
55
+    -e 's/#auth_tcp = "sasl"/auth_tcp = "none"/g'
56
+sudo sed -i /etc/init/libvirt-bin.conf \
57
+    -e 's/env libvirtd_opts="-d"/env libvirtd_opts="-d -l"/g'
58
+sudo sed -i /etc/default/libvirt-bin \
59
+    -e 's/libvirtd_opts="-d"/libvirtd_opts="-d -l"/g'
60
+
61
+# restart libvirt
62
+sudo service libvirt-bin restart
63
+
64
+# Remove the default network created by libvirt
65
+sudo virsh net-destroy default
66
+sudo virsh net-undefine default

Loading…
Cancel
Save