PG1X WIKI

My Knowledge Base

User Tools

Site Tools


tech:server:linux:virtualization:kvm-qemu:ubuntu-1804-kvm-qemu-setup:ubuntu-1804-kvm-qemu-setup

Setup Ubuntu Server 18.04 KVM/QEMU + Libvirt

sudo apt update
sudo apt install qemu-kvm libvirt-bin virtinst bridge-utils libosinfo-bin libguestfs-tools virt-top
wnoguchi@hotaru:~$ sudo apt install qemu-kvm libvirt-bin virtinst bridge-utils libosinfo-bin libguestfs-tools virt-top
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  adwaita-icon-theme at-spi2-core attr augeas-lenses binutils binutils-common binutils-x86-64-linux-gnu cpu-checker
  db-util db5.3-util dconf-gsettings-backend dconf-service exfat-fuse exfat-utils extlinux fontconfig
  fontconfig-config fonts-dejavu-core fonts-droid-fallback fonts-noto-mono gdisk genisoimage ghostscript
  gir1.2-freedesktop gir1.2-libosinfo-1.0 glib-networking glib-networking-common glib-networking-services
  gsettings-desktop-schemas gsfonts gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x
  gtk-update-icon-cache hfsplus hicolor-icon-theme humanity-icon-theme ibverbs-providers icoutils ipxe-qemu
  ipxe-qemu-256k-compat-efi-roms ldmtool libaa1 libafflib0v5 libaio1 libasound2 libasound2-data libasyncns0
  libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libaugeas0 libauthen-sasl-perl libavahi-client3
  libavahi-common-data libavahi-common3 libavc1394-0 libbfio1 libbinutils libbluetooth3 libbrlapi0.6 libcaca0
  libcacard0 libcairo-gobject2 libcairo2 libcdparanoia0 libcolord2 libconfig9 libcroco3 libcups2 libcupsfilters1
  libcupsimage2 libdata-dump-perl libdate-manip-perl libdatrie1 libdconf1 libdv4 libencode-locale-perl libepoxy0
  libewf2 libfdt1 libfile-listing-perl libflac8 libfont-afm-perl libfontconfig1 libgdk-pixbuf2.0-0
  libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgovirt-common libgovirt2 libgraphite2-3 libgs9 libgs9-common
  libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin
  libgtk-3-common libgtk-vnc-2.0-0 libgudev-1.0-0 libguestfs-hfsplus libguestfs-perl libguestfs-reiserfs
  libguestfs-xfs libguestfs0 libgvnc-1.0-0 libharfbuzz0b libhfsp0 libhivex0 libhtml-form-perl libhtml-format-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
  libhttp-message-perl libhttp-negotiate-perl libibverbs1 libiec61883-0 libijs-0.35 libintl-perl libintl-xs-perl
  libio-html-perl libio-socket-ssl-perl libiscsi7 libjack-jackd2-0 libjbig0 libjbig2dec0 libjpeg-turbo8 libjpeg8
  libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libldm-1.0-0 liblwp-mediatypes-perl liblwp-protocol-https-perl
  libmailtools-perl libmp3lame0 libmpg123-0 libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libnetcf1
  libnetpbm10 libnl-route-3-200 libnspr4 libnss3 libogg0 libopus0 liborc-0.4-0 libosinfo-1.0-0 libpango-1.0-0
  libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpciaccess0 libphodav-2.0-0 libphodav-2.0-common
  libpixman-1-0 libproxy1v5 libpulse-mainloop-glib0 libpulse0 libpython-stdlib libpython2.7 libpython2.7-minimal
  libpython2.7-stdlib librados2 libraw1394-11 librbd1 librdmacm1 librest-0.7-0 librsvg2-2 librsvg2-common
  libsamplerate0 libsdl1.2debian libshout3 libsndfile1 libsoup-gnome2.4-1 libsoup2.4-1 libspeex1
  libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libspice-server1 libstring-shellquote-perl libsys-virt-perl
  libtag1v5 libtag1v5-vanilla libthai-data libthai0 libtheora0 libtiff5 libtimedate-perl libtry-tiny-perl libtsk13
  libtwolame0 liburi-perl libusbredirhost1 libusbredirparser1 libv4l-0 libv4lconvert0 libvirt-clients libvirt-daemon
  libvirt-daemon-driver-storage-rbd libvirt-daemon-system libvirt-glib-1.0-0 libvirt0 libvisual-0.4-0 libvorbis0a
  libvorbisenc2 libvpx5 libwavpack1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwin-hivex-perl
  libwww-perl libwww-robotrules-perl libxcb-render0 libxcb-shm0 libxcomposite1 libxcursor1 libxdamage1 libxen-4.9
  libxenstore3.0 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxml-parser-perl libxml-xpath-perl libxml2-utils
  libxrandr2 libxrender1 libxtst6 libxv1 libyajl2 lsscsi lzop msr-tools mtools netpbm osinfo-db perl-openssl-defaults
  poppler-data python python-asn1crypto python-certifi python-cffi-backend python-chardet python-cryptography
  python-enum34 python-gi python-idna python-ipaddr python-ipaddress python-libvirt python-libxml2 python-minimal
  python-openssl python-pkg-resources python-requests python-six python-urllib3 python2.7 python2.7-minimal
  qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils reiserfsprogs scrub seabios sgabios sharutils
  sleuthkit spice-client-glib-usb-acl-helper supermin syslinux syslinux-common ubuntu-mono virt-viewer x11-common
Suggested packages:
  augeas-doc binutils-doc ifupdown fonts-noto wodim cdrkit-doc ghostscript-x gvfs libterm-readline-gnu-perl
  | libterm-readline-perl-perl libasound2-plugins alsa-utils augeas-tools libdigest-hmac-perl libgssapi-perl colord
  cups-common libdv-bin oss-compat libvisual-0.4-plugins gstreamer1.0-tools libguestfs-gfs2 libguestfs-jfs
  libguestfs-nilfs libguestfs-rescue libguestfs-rsync libguestfs-zfs jackd2 liblcms2-utils libcrypt-ssleay-perl
  opus-tools libosinfo-l10n pulseaudio libraw1394-doc librsvg2-bin speex gstreamer1.0-plugins-bad gstreamer1.0-libav
  libvirt-daemon-driver-storage-gluster libvirt-daemon-driver-storage-sheepdog libvirt-daemon-driver-storage-zfs numad
  radvd auditd systemtap nfs-common zfsutils pm-utils libauthen-ntlm-perl floppyd poppler-utils fonts-japanese-mincho
  | fonts-ipafont-mincho fonts-japanese-gothic | fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum
  python-doc python-tk python-cryptography-doc python-cryptography-vectors python-enum34-doc python-gi-cairo
  python-openssl-doc python-openssl-dbg python-setuptools python-socks python-ntlm python2.7-doc binfmt-support samba
  vde2 ovmf debootstrap sharutils-doc bsd-mailx | mailx autopsy mac-robber
The following NEW packages will be installed:
  adwaita-icon-theme at-spi2-core attr augeas-lenses binutils binutils-common binutils-x86-64-linux-gnu bridge-utils
  cpu-checker db-util db5.3-util dconf-gsettings-backend dconf-service exfat-fuse exfat-utils extlinux fontconfig
  fontconfig-config fonts-dejavu-core fonts-droid-fallback fonts-noto-mono gdisk genisoimage ghostscript
  gir1.2-freedesktop gir1.2-libosinfo-1.0 glib-networking glib-networking-common glib-networking-services
  gsettings-desktop-schemas gsfonts gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x
  gtk-update-icon-cache hfsplus hicolor-icon-theme humanity-icon-theme ibverbs-providers icoutils ipxe-qemu
  ipxe-qemu-256k-compat-efi-roms ldmtool libaa1 libafflib0v5 libaio1 libasound2 libasound2-data libasyncns0
  libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libaugeas0 libauthen-sasl-perl libavahi-client3
  libavahi-common-data libavahi-common3 libavc1394-0 libbfio1 libbinutils libbluetooth3 libbrlapi0.6 libcaca0
  libcacard0 libcairo-gobject2 libcairo2 libcdparanoia0 libcolord2 libconfig9 libcroco3 libcups2 libcupsfilters1
  libcupsimage2 libdata-dump-perl libdate-manip-perl libdatrie1 libdconf1 libdv4 libencode-locale-perl libepoxy0
  libewf2 libfdt1 libfile-listing-perl libflac8 libfont-afm-perl libfontconfig1 libgdk-pixbuf2.0-0
  libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgovirt-common libgovirt2 libgraphite2-3 libgs9 libgs9-common
  libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin
  libgtk-3-common libgtk-vnc-2.0-0 libgudev-1.0-0 libguestfs-hfsplus libguestfs-perl libguestfs-reiserfs
  libguestfs-tools libguestfs-xfs libguestfs0 libgvnc-1.0-0 libharfbuzz0b libhfsp0 libhivex0 libhtml-form-perl
  libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
  libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libibverbs1 libiec61883-0
  libijs-0.35 libintl-perl libintl-xs-perl libio-html-perl libio-socket-ssl-perl libiscsi7 libjack-jackd2-0 libjbig0
  libjbig2dec0 libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libldm-1.0-0
  liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libmp3lame0 libmpg123-0 libnet-http-perl
  libnet-smtp-ssl-perl libnet-ssleay-perl libnetcf1 libnetpbm10 libnl-route-3-200 libnspr4 libnss3 libogg0 libopus0
  liborc-0.4-0 libosinfo-1.0-0 libosinfo-bin libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils
  libpaper1 libpciaccess0 libphodav-2.0-0 libphodav-2.0-common libpixman-1-0 libproxy1v5 libpulse-mainloop-glib0
  libpulse0 libpython-stdlib libpython2.7 libpython2.7-minimal libpython2.7-stdlib librados2 libraw1394-11 librbd1
  librdmacm1 librest-0.7-0 librsvg2-2 librsvg2-common libsamplerate0 libsdl1.2debian libshout3 libsndfile1
  libsoup-gnome2.4-1 libsoup2.4-1 libspeex1 libspice-client-glib-2.0-8 libspice-client-gtk-3.0-5 libspice-server1
  libstring-shellquote-perl libsys-virt-perl libtag1v5 libtag1v5-vanilla libthai-data libthai0 libtheora0 libtiff5
  libtimedate-perl libtry-tiny-perl libtsk13 libtwolame0 liburi-perl libusbredirhost1 libusbredirparser1 libv4l-0
  libv4lconvert0 libvirt-bin libvirt-clients libvirt-daemon libvirt-daemon-driver-storage-rbd libvirt-daemon-system
  libvirt-glib-1.0-0 libvirt0 libvisual-0.4-0 libvorbis0a libvorbisenc2 libvpx5 libwavpack1 libwayland-client0
  libwayland-cursor0 libwayland-egl1 libwin-hivex-perl libwww-perl libwww-robotrules-perl libxcb-render0 libxcb-shm0
  libxcomposite1 libxcursor1 libxdamage1 libxen-4.9 libxenstore3.0 libxfixes3 libxi6 libxinerama1 libxkbcommon0
  libxml-parser-perl libxml-xpath-perl libxml2-utils libxrandr2 libxrender1 libxtst6 libxv1 libyajl2 lsscsi lzop
  msr-tools mtools netpbm osinfo-db perl-openssl-defaults poppler-data python python-asn1crypto python-certifi
  python-cffi-backend python-chardet python-cryptography python-enum34 python-gi python-idna python-ipaddr
  python-ipaddress python-libvirt python-libxml2 python-minimal python-openssl python-pkg-resources python-requests
  python-six python-urllib3 python2.7 python2.7-minimal qemu-block-extra qemu-kvm qemu-system-common qemu-system-x86
  qemu-utils reiserfsprogs scrub seabios sgabios sharutils sleuthkit spice-client-glib-usb-acl-helper supermin
  syslinux syslinux-common ubuntu-mono virt-top virt-viewer virtinst x11-common
0 upgraded, 294 newly installed, 0 to remove and 0 not upgraded.
Need to get 83.1 MB of archives.
After this operation, 359 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

(snip)



wnoguchi@hotaru:~$ lsmod | grep vhost 
wnoguchi@hotaru:~$ sudo lsmod | grep vhost 
wnoguchi@hotaru:~$ sudo modprobe vhost_net
wnoguchi@hotaru:~$ lsmod | grep vhost 
vhost_net              24576  0
vhost                  45056  1 vhost_net
tap                    24576  1 vhost_net
wnoguchi@hotaru:~$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

wnoguchi@hotaru:~$ echo vhost_net | sudo tee -a /etc/modules
vhost_net
wnoguchi@hotaru:~$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

vhost_net
wnoguchi@hotaru:~$ sudo mkdir -p /root/original/etc/netplan
wnoguchi@hotaru:~$ sudo cp -p /etc/netplan/01-netcfg.yaml /root/original/etc/netplan/
wnoguchi@hotaru:~$ sudo diff -u /root/original/etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml
wnoguchi@hotaru:~$ sudo vim /etc/netplan/01-netcfg.yaml
/etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      dhcp4: yes
      dhcp6: yes

rewrite following

/etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces: [ eno2 ]
      dhcp4: no
      dhcp6: no
      parameters:
        stp: false
      addresses: [ 10.0.4.193/24, '2001:db8:1:2::194/64' ]
      gateway4: 10.0.4.1
      gateway6: 'fe80::1234:56ff:fe78:9abc'
      nameservers:
        addresses: [ 8.8.8.8, 8.8.4.4, '2001:db8:11:22::53', '2001:db8:33:44::53' ]
wnoguchi@hotaru:~$ sudo diff -u /root/original/etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml
--- /root/original/etc/netplan/01-netcfg.yaml	2019-08-13 16:11:18.607661919 +0900
+++ /etc/netplan/01-netcfg.yaml	2019-08-13 19:27:41.502103527 +0900
@@ -5,5 +5,18 @@
   renderer: networkd
   ethernets:
     eno2:
-      dhcp4: yes
-      dhcp6: yes
+      dhcp4: no
+      dhcp6: no
+  bridges:
+    br0:
+      interfaces: [ eno2 ]
+      dhcp4: no
+      dhcp6: no
+      parameters:
+        stp: false
+      addresses: [ 10.0.4.194/24, '240d:1a:640:9b00::194/64' ]
+      gateway4: 10.0.4.1
+      gateway6: 'fe80::e67e:66ff:fe30:2a85'
+      nameservers:
+        addresses: [ 8.8.8.8, 8.8.4.4, '2001:db8:11:22::53', '2001:db8:33:44::53' ]
+

References

tech/server/linux/virtualization/kvm-qemu/ubuntu-1804-kvm-qemu-setup/ubuntu-1804-kvm-qemu-setup.txt · Last modified: 2019/08/13 20:35 by wnoguchi